From: Markus Armbruster Date: Fri, 15 Jan 2010 19:02:11 +0000 (+0100) Subject: Make CANT_HAPPEN() more obvious for static analysis X-Git-Tag: v4.3.24~16 X-Git-Url: http://git.pond.sub.org/?p=empserver;a=commitdiff_plain;h=9061ae7b9d397cfbc8c96ae45e126d49e6bdb2f2 Make CANT_HAPPEN() more obvious for static analysis Local analysis can now easily find out what's up. Before, whole-program analysis was required. The Clang Static Analyzer complained about code that is actually fine. --- diff --git a/include/misc.h b/include/misc.h index 32817f825..8c4095b55 100644 --- a/include/misc.h +++ b/include/misc.h @@ -70,15 +70,15 @@ * Return EXPR != 0. * Usage: if (CANT_HAPPEN(...)) ; */ -#define CANT_HAPPEN(expr) ((expr) ? oops(#expr, __FILE__, __LINE__) : 0) +#define CANT_HAPPEN(expr) ((expr) ? oops(#expr, __FILE__, __LINE__), 1 : 0) /* * Report internal error. * Usage: CANT_REACH(); ; */ -#define CANT_REACH() (void)oops(NULL, __FILE__, __LINE__) +#define CANT_REACH() oops(NULL, __FILE__, __LINE__) -extern int oops(char *, char *, int); +extern void oops(char *, char *, int); extern void (*oops_handler)(void); void exit_nomem(void) ATTRIBUTE((noreturn)); diff --git a/src/lib/gen/log.c b/src/lib/gen/log.c index a76b857e3..8b205a77c 100644 --- a/src/lib/gen/log.c +++ b/src/lib/gen/log.c @@ -126,16 +126,13 @@ logerror(char *format, ...) } /* - * Log internal error MSG occured in FILE:LINE. - * Call oops handler, and if it returns, return 1. - * Oops handler defaults to abort(). + * Log internal error MSG occured in FILE:LINE, call oops handler. */ -int +void oops(char *msg, char *file, int line) { logerror("Oops: %s in %s:%d", msg ? msg : "bug", file, line); oops_handler(); - return 1; } /*