summaryrefslogtreecommitdiff
path: root/run-command.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2018-05-30 05:04:07 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-05-30 05:04:07 (GMT)
commit50f08db5941755b69012378bfc86f6b8ee98edf4 (patch)
treed403a1dbf522fdaab4cf6b9b508a08b3965828e2 /run-command.c
parentbef896e4ab414312cdca493e0306d66ec7246b01 (diff)
parent746ea4adc6cd88ad5f5af6beebace581fe489b2f (diff)
downloadgit-50f08db5941755b69012378bfc86f6b8ee98edf4.zip
git-50f08db5941755b69012378bfc86f6b8ee98edf4.tar.gz
git-50f08db5941755b69012378bfc86f6b8ee98edf4.tar.bz2
Merge branch 'js/use-bug-macro'
Developer support update, by using BUG() macro instead of die() to mark codepaths that should not happen more clearly. * js/use-bug-macro: BUG_exit_code: fix sparse "symbol not declared" warning Convert remaining die*(BUG) messages Replace all die("BUG: ...") calls by BUG() ones run-command: use BUG() to report bugs, not die() test-tool: help verifying BUG() code paths
Diffstat (limited to 'run-command.c')
-rw-r--r--run-command.c33
1 files changed, 15 insertions, 18 deletions
diff --git a/run-command.c b/run-command.c
index 12c94c1..84b883c 100644
--- a/run-command.c
+++ b/run-command.c
@@ -245,7 +245,7 @@ int sane_execvp(const char *file, char * const argv[])
static const char **prepare_shell_cmd(struct argv_array *out, const char **argv)
{
if (!argv[0])
- die("BUG: shell command is empty");
+ BUG("shell command is empty");
if (strcspn(argv[0], "|&;<>()$`\\\"' \t\n*?[#~=%") != strlen(argv[0])) {
#ifndef GIT_WINDOWS_NATIVE
@@ -383,7 +383,7 @@ static void child_err_spew(struct child_process *cmd, struct child_err *cerr)
static void prepare_cmd(struct argv_array *out, const struct child_process *cmd)
{
if (!cmd->argv[0])
- die("BUG: command is empty");
+ BUG("command is empty");
/*
* Add SHELL_PATH so in the event exec fails with ENOEXEC we can
@@ -471,15 +471,12 @@ struct atfork_state {
sigset_t old;
};
-#ifndef NO_PTHREADS
-static void bug_die(int err, const char *msg)
-{
- if (err) {
- errno = err;
- die_errno("BUG: %s", msg);
- }
-}
-#endif
+#define CHECK_BUG(err, msg) \
+ do { \
+ int e = (err); \
+ if (e) \
+ BUG("%s: %s", msg, strerror(e)); \
+ } while(0)
static void atfork_prepare(struct atfork_state *as)
{
@@ -491,9 +488,9 @@ static void atfork_prepare(struct atfork_state *as)
if (sigprocmask(SIG_SETMASK, &all, &as->old))
die_errno("sigprocmask");
#else
- bug_die(pthread_sigmask(SIG_SETMASK, &all, &as->old),
+ CHECK_BUG(pthread_sigmask(SIG_SETMASK, &all, &as->old),
"blocking all signals");
- bug_die(pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &as->cs),
+ CHECK_BUG(pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &as->cs),
"disabling cancellation");
#endif
}
@@ -504,9 +501,9 @@ static void atfork_parent(struct atfork_state *as)
if (sigprocmask(SIG_SETMASK, &as->old, NULL))
die_errno("sigprocmask");
#else
- bug_die(pthread_setcancelstate(as->cs, NULL),
+ CHECK_BUG(pthread_setcancelstate(as->cs, NULL),
"re-enabling cancellation");
- bug_die(pthread_sigmask(SIG_SETMASK, &as->old, NULL),
+ CHECK_BUG(pthread_sigmask(SIG_SETMASK, &as->old, NULL),
"restoring signal mask");
#endif
}
@@ -967,7 +964,7 @@ int run_command(struct child_process *cmd)
int code;
if (cmd->out < 0 || cmd->err < 0)
- die("BUG: run_command with a pipe can cause deadlock");
+ BUG("run_command with a pipe can cause deadlock");
code = start_command(cmd);
if (code)
@@ -1557,7 +1554,7 @@ static void pp_init(struct parallel_processes *pp,
pp->data = data;
if (!get_next_task)
- die("BUG: you need to specify a get_next_task function");
+ BUG("you need to specify a get_next_task function");
pp->get_next_task = get_next_task;
pp->start_failure = start_failure ? start_failure : default_start_failure;
@@ -1619,7 +1616,7 @@ static int pp_start_one(struct parallel_processes *pp)
if (pp->children[i].state == GIT_CP_FREE)
break;
if (i == pp->max_processes)
- die("BUG: bookkeeping is hard");
+ BUG("bookkeeping is hard");
code = pp->get_next_task(&pp->children[i].process,
&pp->children[i].err,