diff --git a/src/screencast/wlr_screencast.c b/src/screencast/wlr_screencast.c index 1bc8439e..77da0959 100644 --- a/src/screencast/wlr_screencast.c +++ b/src/screencast/wlr_screencast.c @@ -357,7 +357,6 @@ static bool wlr_output_chooser(struct xdpw_output_chooser *chooser, struct xdpw_wlr_output *out; size_t name_size = 0; char *name = NULL; - FILE *f = NULL; *output = NULL; int chooser_in[2]; //p -> c @@ -381,8 +380,8 @@ static bool wlr_output_chooser(struct xdpw_output_chooser *chooser, } switch (chooser->type) { - case XDPW_CHOOSER_DMENU: - f = fdopen(chooser_in[1], "w"); + case XDPW_CHOOSER_DMENU:; + FILE *f = fdopen(chooser_in[1], "w"); if (f == NULL) { perror("fdopen pipe chooser_in"); logprint(ERROR, "Failed to create stream writing to pipe chooser_in"); @@ -402,7 +401,7 @@ static bool wlr_output_chooser(struct xdpw_output_chooser *chooser, goto end; } - f = fdopen(chooser_out[0], "r"); + FILE *f = fdopen(chooser_out[0], "r"); if (f == NULL) { perror("fdopen pipe chooser_out"); logprint(ERROR, "Failed to create stream reading from pipe chooser_out"); @@ -475,20 +474,18 @@ static struct xdpw_wlr_output *wlr_output_chooser_default(struct wl_list *output } struct xdpw_wlr_output *xdpw_wlr_output_chooser(struct xdpw_screencast_context *ctx) { - struct xdpw_wlr_output *output = NULL; switch (ctx->state->config->screencast_conf.chooser_type) { case XDPW_CHOOSER_DEFAULT: - output = wlr_output_chooser_default(&ctx->output_list); - break; + return wlr_output_chooser_default(&ctx->output_list); case XDPW_CHOOSER_NONE: if (ctx->state->config->screencast_conf.output_name) { - output = xdpw_wlr_output_find_by_name(&ctx->output_list, ctx->state->config->screencast_conf.output_name); + return xdpw_wlr_output_find_by_name(&ctx->output_list, ctx->state->config->screencast_conf.output_name); } else { - output = xdpw_wlr_output_first(&ctx->output_list); + return xdpw_wlr_output_first(&ctx->output_list); } - break; case XDPW_CHOOSER_DMENU: - case XDPW_CHOOSER_SIMPLE: + case XDPW_CHOOSER_SIMPLE:; + struct xdpw_wlr_output *output = NULL; if (!ctx->state->config->screencast_conf.chooser_cmd) { logprint(ERROR, "wlroots: no output chooser given"); goto end; @@ -501,7 +498,6 @@ struct xdpw_wlr_output *xdpw_wlr_output_chooser(struct xdpw_screencast_context * bool ret = wlr_output_chooser(&chooser, &ctx->output_list, &output); if (!ret) { logprint(ERROR, "wlroots: output chooser %s failed", chooser.cmd); - output = NULL; goto end; } if (output) { @@ -509,10 +505,10 @@ struct xdpw_wlr_output *xdpw_wlr_output_chooser(struct xdpw_screencast_context * } else { logprint(DEBUG, "wlroots: output chooser canceled"); } - break; + return output; } end: - return output; + return NULL; } struct xdpw_wlr_output *xdpw_wlr_output_first(struct wl_list *output_list) {