run-command: use BUG() to report bugs, not die()
The slightly misleading name die_bug() of the function intended to report a bug is actually called always, and only reports a bug if the passed-in parameter `err` is non-zero. It uses die_errno() to report the bug, to helpfully include the error message corresponding to `err`. However, as these messages indicate bugs, we really should use BUG(). And as BUG() is a macro to be able to report the exact file and line number, we need to convert die_bug() to a macro instead of only replacing the die_errno() by a call to BUG(). While at it, use a name more indicative of the purpose: CHECK_BUG(). Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
							parent
							
								
									a86303cb5d
								
							
						
					
					
						commit
						dde74d732f
					
				|  | @ -471,15 +471,12 @@ struct atfork_state { | ||||||
| 	sigset_t old; | 	sigset_t old; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| #ifndef NO_PTHREADS | #define CHECK_BUG(err, msg) \ | ||||||
| static void bug_die(int err, const char *msg) | 	do { \ | ||||||
| { | 		int e = (err); \ | ||||||
| 	if (err) { | 		if (e) \ | ||||||
| 		errno = err; | 			BUG("%s: %s", msg, strerror(e)); \ | ||||||
| 		die_errno("BUG: %s", msg); | 	} while(0) | ||||||
| 	} |  | ||||||
| } |  | ||||||
| #endif |  | ||||||
|  |  | ||||||
| static void atfork_prepare(struct atfork_state *as) | 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)) | 	if (sigprocmask(SIG_SETMASK, &all, &as->old)) | ||||||
| 		die_errno("sigprocmask"); | 		die_errno("sigprocmask"); | ||||||
| #else | #else | ||||||
| 	bug_die(pthread_sigmask(SIG_SETMASK, &all, &as->old), | 	CHECK_BUG(pthread_sigmask(SIG_SETMASK, &all, &as->old), | ||||||
| 		"blocking all signals"); | 		"blocking all signals"); | ||||||
| 	bug_die(pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &as->cs), | 	CHECK_BUG(pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &as->cs), | ||||||
| 		"disabling cancellation"); | 		"disabling cancellation"); | ||||||
| #endif | #endif | ||||||
| } | } | ||||||
|  | @ -504,9 +501,9 @@ static void atfork_parent(struct atfork_state *as) | ||||||
| 	if (sigprocmask(SIG_SETMASK, &as->old, NULL)) | 	if (sigprocmask(SIG_SETMASK, &as->old, NULL)) | ||||||
| 		die_errno("sigprocmask"); | 		die_errno("sigprocmask"); | ||||||
| #else | #else | ||||||
| 	bug_die(pthread_setcancelstate(as->cs, NULL), | 	CHECK_BUG(pthread_setcancelstate(as->cs, NULL), | ||||||
| 		"re-enabling cancellation"); | 		"re-enabling cancellation"); | ||||||
| 	bug_die(pthread_sigmask(SIG_SETMASK, &as->old, NULL), | 	CHECK_BUG(pthread_sigmask(SIG_SETMASK, &as->old, NULL), | ||||||
| 		"restoring signal mask"); | 		"restoring signal mask"); | ||||||
| #endif | #endif | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 Johannes Schindelin
						Johannes Schindelin