aboutsummaryrefslogtreecommitdiff
path: root/input.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2020-07-22 18:01:59 +0000
committerDaniel Eklöf <daniel@ekloef.se>2020-07-22 18:01:59 +0000
commit6b6db610cc847129b23dea3403ca16901f776ca2 (patch)
tree1f285ea96bc2188396eab798c86a05c2b1029666 /input.c
parentmeson/pkgbuild: bump version to 1.4.0, require fcft 2.2.2 (diff)
parentinput: pipe: avoid goto's where variables may be uninitialized (diff)
Merge branch 'master' into releases/1.4
Diffstat (limited to 'input.c')
-rw-r--r--input.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/input.c b/input.c
index 0e4cb675..442cd322 100644
--- a/input.c
+++ b/input.c
@@ -151,29 +151,32 @@ execute_binding(struct seat *seat, struct terminal *term,
struct pipe_context *ctx = NULL;
+ int pipe_fd[2] = {-1, -1};
+ int stdout_fd = -1;
+ int stderr_fd = -1;
+
+ char *text = NULL;
+ size_t len = 0;
+
char *cmd = strdup(pipe_cmd);
char **argv = NULL;
if (!tokenize_cmdline(cmd, &argv))
goto pipe_err;
- int pipe_fd[2] = {-1, -1};
if (pipe(pipe_fd) < 0) {
LOG_ERRNO("failed to create pipe");
goto pipe_err;
}
- int stdout_fd = open("/dev/null", O_WRONLY);
- int stderr_fd = open("/dev/null", O_WRONLY);
+ stdout_fd = open("/dev/null", O_WRONLY);
+ stderr_fd = open("/dev/null", O_WRONLY);
if (stdout_fd < 0 || stderr_fd < 0) {
LOG_ERRNO("failed to open /dev/null");
goto pipe_err;
}
- char *text;
- size_t len;
-
bool success = action == BIND_ACTION_PIPE_SCROLLBACK
? term_scrollback_to_text(term, &text, &len)
: term_view_to_text(term, &text, &len);