mirror of
git://git.sv.gnu.org/coreutils.git
synced 2026-07-28 19:39:52 +02:00
expr: lint cleanup, and introducing main_exit
This introduces a new macro main_exit, which is useful for pacifying gcc -fsanitizer=lint and in some cases means we can remove some ‘IF_LINT’ and ‘ifdef lint’ code. * src/expr.c (main): Use main_exit, not return. (docolon): Omit an IF_LINT that GCC no longer needs. * src/system.h (main_exit): New macro.
This commit is contained in:
+2
-2
@@ -357,7 +357,7 @@ main (int argc, char **argv)
|
||||
|
||||
printv (v);
|
||||
|
||||
return null (v);
|
||||
main_exit (null (v));
|
||||
}
|
||||
|
||||
/* Return a VALUE for I. */
|
||||
@@ -585,7 +585,7 @@ trace (fxn)
|
||||
static VALUE *
|
||||
docolon (VALUE *sv, VALUE *pv)
|
||||
{
|
||||
VALUE *v IF_LINT ( = NULL);
|
||||
VALUE *v;
|
||||
char const *errmsg;
|
||||
struct re_pattern_buffer re_buffer;
|
||||
char fastmap[UCHAR_MAX + 1];
|
||||
|
||||
+13
-1
@@ -465,13 +465,25 @@ enum
|
||||
# define PID_T_MAX TYPE_MAXIMUM (pid_t)
|
||||
#endif
|
||||
|
||||
/* Use this to suppress gcc's '...may be used before initialized' warnings. */
|
||||
/* Use this to suppress gcc warnings. */
|
||||
#ifdef lint
|
||||
# define IF_LINT(Code) Code
|
||||
#else
|
||||
# define IF_LINT(Code) /* empty */
|
||||
#endif
|
||||
|
||||
/* main_exit should be called only from the main function. It is
|
||||
equivalent to 'exit'. When checking for lint it calls 'exit', to
|
||||
pacify gcc -fsanitize=lint which would otherwise have false alarms
|
||||
for pointers in the main function's activation record. Otherwise
|
||||
it simply returns from 'main'; this used to be what gcc's static
|
||||
checking preferred and may yet be again. */
|
||||
#ifdef lint
|
||||
# define main_exit(status) exit (status)
|
||||
#else
|
||||
# define main_exit(status) return status
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
# define LIKELY(cond) __builtin_expect ((cond), 1)
|
||||
# define UNLIKELY(cond) __builtin_expect ((cond), 0)
|
||||
|
||||
Reference in New Issue
Block a user