[PATCH 1/2] Remove unused C macros
Also, pacify ‘gcc -Wunused-macros’, which was employed to find these unused macros. * localtime.c (NETBSD_INSPIRED_EXTERN): Define only if STD_INSPIRED is defined. * private.h (sys_time) [!TZ_TIME_T]: Inspect LOCALTIME_IMPLEMENTATION. * zdump.c (MAX_STRING_LENGTH): * zic.c (PRIdZIC): Remove these macros, which are no longer used. --- localtime.c | 16 ++++++++-------- private.h | 7 ++++--- zdump.c | 4 ---- zic.c | 1 - 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/localtime.c b/localtime.c index d3e406b..82a3b70 100644 --- a/localtime.c +++ b/localtime.c @@ -28,14 +28,6 @@ static int lock(void) { return 0; } static void unlock(void) { } #endif -/* NETBSD_INSPIRED_EXTERN functions are exported to callers if - NETBSD_INSPIRED is defined, and are private otherwise. */ -#if NETBSD_INSPIRED -# define NETBSD_INSPIRED_EXTERN -#else -# define NETBSD_INSPIRED_EXTERN static -#endif - #ifndef TZ_ABBR_MAX_LEN #define TZ_ABBR_MAX_LEN 16 #endif /* !defined TZ_ABBR_MAX_LEN */ @@ -2247,6 +2239,14 @@ leapcorr(struct state const *sp, time_t t) #ifdef STD_INSPIRED +/* NETBSD_INSPIRED_EXTERN functions are exported to callers if + NETBSD_INSPIRED is defined, and are private otherwise. */ +# if NETBSD_INSPIRED +# define NETBSD_INSPIRED_EXTERN +# else +# define NETBSD_INSPIRED_EXTERN static +# endif + /* ** IEEE Std 1003.1 (POSIX) says that 536457599 ** shall correspond to "Wed Dec 31 23:59:59 UTC 1986", which diff --git a/private.h b/private.h index 9efcd78..a919e4f 100644 --- a/private.h +++ b/private.h @@ -418,10 +418,11 @@ typedef unsigned long uintmax_t; # define TZ_TIME_T 0 #endif -#if TZ_TIME_T -# ifdef LOCALTIME_IMPLEMENTATION +#if defined LOCALTIME_IMPLEMENTATION && TZ_TIME_T static time_t sys_time(time_t *x) { return time(x); } -# endif +#endif + +#if TZ_TIME_T typedef time_tz tz_time_t; diff --git a/zdump.c b/zdump.c index b532fe3..57e363e 100644 --- a/zdump.c +++ b/zdump.c @@ -42,10 +42,6 @@ #define ZDUMP_HI_YEAR 2500 #endif /* !defined ZDUMP_HI_YEAR */ -#ifndef MAX_STRING_LENGTH -#define MAX_STRING_LENGTH 1024 -#endif /* !defined MAX_STRING_LENGTH */ - #define SECSPERNYEAR (SECSPERDAY * DAYSPERNYEAR) #define SECSPERLYEAR (SECSPERNYEAR + SECSPERDAY) #define SECSPER400YEARS (SECSPERNYEAR * (intmax_t) (300 + 3) \ diff --git a/zic.c b/zic.c index b37cdc9..51977b2 100644 --- a/zic.c +++ b/zic.c @@ -21,7 +21,6 @@ typedef int_fast64_t zic_t; #define ZIC_MIN INT_FAST64_MIN #define ZIC_MAX INT_FAST64_MAX -#define PRIdZIC PRIdFAST64 #define SCNdZIC SCNdFAST64 #ifndef ZIC_MAX_ABBR_LEN_WO_WARN -- 2.27.0
* Makefile (GCC_DEBUG_FLAGS): Modify options to match GCC 10 instead of GCC 8. Omit GCC 10’s -fanalyzer flag, though, as it’s just too slow. And remove -Wjump-misses-init as that’s really a C++-ism. --- Makefile | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 1136af9..3f4b123 100644 --- a/Makefile +++ b/Makefile @@ -257,22 +257,26 @@ LDLIBS= GCC_INSTRUMENT = \ -fsanitize=undefined -fsanitize-address-use-after-scope \ -fsanitize-undefined-trap-on-error -fstack-protector +# Omit -fanalyzer from GCC_DEBUG_FLAGS, as it makes GCC too slow. GCC_DEBUG_FLAGS = -DGCC_LINT -g3 -O3 -fno-common \ $(GCC_INSTRUMENT) \ -Wall -Wextra \ -Walloc-size-larger-than=100000 -Warray-bounds=2 \ -Wbad-function-cast -Wcast-align=strict -Wdate-time \ -Wdeclaration-after-statement -Wdouble-promotion \ + -Wduplicated-branches -Wduplicated-cond \ -Wformat=2 -Wformat-overflow=2 -Wformat-signedness -Wformat-truncation \ - -Winit-self -Wjump-misses-init -Wlogical-op \ + -Winit-self -Wlogical-op \ -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \ + -Wnull-dereference \ -Wold-style-definition -Woverlength-strings -Wpointer-arith \ - -Wshadow -Wshift-overflow=2 -Wstrict-prototypes -Wstringop-overflow=4 \ + -Wshadow -Wshift-overflow=2 -Wstrict-overflow \ + -Wstrict-prototypes -Wstringop-overflow=4 \ -Wstringop-truncation -Wsuggest-attribute=cold \ -Wsuggest-attribute=const -Wsuggest-attribute=format \ -Wsuggest-attribute=malloc \ -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure \ - -Wtrampolines -Wundef -Wuninitialized -Wunused \ + -Wtrampolines -Wundef -Wuninitialized -Wunused-macros \ -Wvariadic-macros -Wvla -Wwrite-strings \ -Wno-address -Wno-format-nonliteral -Wno-sign-compare \ -Wno-type-limits -Wno-unused-parameter -- 2.27.0
participants (1)
-
Paul Eggert