aboutsummaryrefslogtreecommitdiffstats
path: root/shared.c
diff options
context:
space:
mode:
authorJohn Keeping2013-05-18 16:21:36 +0100
committerJason A. Donenfeld2013-05-22 12:53:06 +0200
commit1e9f1ee64e5f8f75a361260a2165996bc137b961 (patch)
treee8ce7148ac4ad40dc703b0c48ba7e3aa67843357 /shared.c
parent1fec7cd6f817e52a6e55458d584a7a5092ba6aed (diff)
downloadcgit-1e9f1ee64e5f8f75a361260a2165996bc137b961.tar.gz
cgit-1e9f1ee64e5f8f75a361260a2165996bc137b961.tar.bz2
cgit-1e9f1ee64e5f8f75a361260a2165996bc137b961.zip
shared.c: use die_errno() where appropriate
This replaces some code that is re-implementing die_errno by just calling the function. Signed-off-by: John Keeping <john@keeping.me.uk>
Diffstat (limited to 'shared.c')
-rw-r--r--shared.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/shared.c b/shared.c
index 4369378..919a99e 100644
--- a/shared.c
+++ b/shared.c
@@ -15,21 +15,21 @@ struct cgit_context ctx;
15int chk_zero(int result, char *msg) 15int chk_zero(int result, char *msg)
16{ 16{
17 if (result != 0) 17 if (result != 0)
18 die("%s: %s", msg, strerror(errno)); 18 die_errno("%s", msg);
19 return result; 19 return result;
20} 20}
21 21
22int chk_positive(int result, char *msg) 22int chk_positive(int result, char *msg)
23{ 23{
24 if (result <= 0) 24 if (result <= 0)
25 die("%s: %s", msg, strerror(errno)); 25 die_errno("%s", msg);
26 return result; 26 return result;
27} 27}
28 28
29int chk_non_negative(int result, char *msg) 29int chk_non_negative(int result, char *msg)
30{ 30{
31 if (result < 0) 31 if (result < 0)
32 die("%s: %s", msg, strerror(errno)); 32 die_errno("%s", msg);
33 return result; 33 return result;
34} 34}
35 35
@@ -468,8 +468,7 @@ int cgit_open_filter(struct cgit_filter *filter)
468 chk_non_negative(dup2(filter->pipe_fh[0], STDIN_FILENO), 468 chk_non_negative(dup2(filter->pipe_fh[0], STDIN_FILENO),
469 "Unable to use pipe as STDIN"); 469 "Unable to use pipe as STDIN");
470 execvp(filter->cmd, filter->argv); 470 execvp(filter->cmd, filter->argv);
471 die("Unable to exec subprocess %s: %s (%d)", filter->cmd, 471 die_errno("Unable to exec subprocess %s", filter->cmd);
472 strerror(errno), errno);
473 } 472 }
474 close(filter->pipe_fh[0]); 473 close(filter->pipe_fh[0]);
475 chk_non_negative(dup2(filter->pipe_fh[1], STDOUT_FILENO), 474 chk_non_negative(dup2(filter->pipe_fh[1], STDOUT_FILENO),