diff options
author | Drew DeVault <sir@cmpwn.com> | 2017-11-11 10:54:32 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-11 10:54:32 -0500 |
commit | c9916b998c90ea935c79f4fb93fd10f57e488a50 (patch) | |
tree | aa4a4885530df34ce465e017276655882abe1090 /examples/screenshot.c | |
parent | a538ef33c1f27d5180117933bee40ecd93fbea7a (diff) | |
parent | 029f2c05bbe701d27dae7402902256955ca6eb8d (diff) |
Merge pull request #410 from turlando/fix/unused-result
Fix unused-result error while building with PKGBUILD
Diffstat (limited to 'examples/screenshot.c')
-rw-r--r-- | examples/screenshot.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/examples/screenshot.c b/examples/screenshot.c index 2a3b74aa..fc7f3cb3 100644 --- a/examples/screenshot.c +++ b/examples/screenshot.c @@ -187,7 +187,10 @@ static void write_image(const char *filename, int width, int height) { sprintf(size, "%dx%d+0", width, height); int fd[2]; - pipe(fd); + if (pipe(fd) != 0) { + fprintf(stderr, "cannot create pipe: %s\n", strerror(errno)); + exit(EXIT_FAILURE); + } pid_t child = fork(); if (child < 0) { @@ -195,7 +198,10 @@ static void write_image(const char *filename, int width, int height) { exit(EXIT_FAILURE); } else if (child != 0) { close(fd[0]); - write(fd[1], data, buffer_stride * height); + if (write(fd[1], data, buffer_stride * height) < 0) { + fprintf(stderr, "write() failed: %s\n", strerror(errno)); + exit(EXIT_FAILURE); + } close(fd[1]); free(data); waitpid(child, NULL, 0); |