From 23bbea75793621e6b21fbb13c00d8223113cf7b5 Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Sat, 22 Jun 2013 15:04:44 +0100 Subject: [PATCH] Use the shiny new `mLib' warning-control macros. --- configure.ac | 2 +- debian/control | 2 +- key/key-data.h | 21 +++------------------ math/group-test.c | 5 +++-- math/mpint.h | 24 +++++++++--------------- math/mpx.c | 12 ++---------- progs/pixie.c | 6 +++--- pub/keycheck.h | 5 +++-- symm/des-mktab.c | 4 +++- symm/square.c | 16 ++++------------ 10 files changed, 32 insertions(+), 65 deletions(-) diff --git a/configure.ac b/configure.ac index 7c66807..fbbb12e 100644 --- a/configure.ac +++ b/configure.ac @@ -155,7 +155,7 @@ dnl Memory locking support. AC_CHECK_FUNCS([mlock]) dnl Necessary support libraries. -PKG_CHECK_MODULES([mLib], [mLib >= 2.0.4]) +PKG_CHECK_MODULES([mLib], [mLib >= 2.2.1]) AM_CFLAGS="$AM_CFLAGS $mLib_CFLAGS" dnl-------------------------------------------------------------------------- diff --git a/debian/control b/debian/control index 4c332e4..507a222 100644 --- a/debian/control +++ b/debian/control @@ -1,7 +1,7 @@ Source: catacomb Section: libs Priority: extra -Build-Depends: mlib-dev (>= 2.0.2), debhelper (>= 8) +Build-Depends: mlib-dev (>= 2.2.1), debhelper (>= 9) Maintainer: Mark Wooding Standards-Version: 3.1.1 diff --git a/key/key-data.h b/key/key-data.h index cfeff82..8071116 100644 --- a/key/key-data.h +++ b/key/key-data.h @@ -38,6 +38,7 @@ #include #include +#include #include #ifndef CATACOMB_KEY_ERROR_H @@ -160,26 +161,10 @@ typedef struct key_filter { unsigned m; } key_filter; -/* --- Matching aginst key selection --- * - * - * GCC will warn about constant addresses in this test, which is rather - * unfortunate. Muffle the warning. This is rather hideous because of the - * way GCC's parser handles pragmata. - */ - -#if __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) -# define KEY_MATCH_MUFFLE_WARNING(x) __extension__ ({ \ - _Pragma("GCC diagnostic push") \ - _Pragma("GCC diagnostic ignored \"-Waddress\"") \ - (x); \ - _Pragma("GCC diagnostic pop") \ - }) -#else -# define KEY_MATCH_MUFFLE_WARNING(x) (x) -#endif +/* --- Matching aginst key selection --- */ #define KEY_MATCH(kd, kf) \ - (KEY_MATCH_MUFFLE_WARNING(!(kf)) || \ + (MUFFLE_WARNINGS_EXPR(GCC_WARNING("-Waddress"), !(kf)) || \ ((kd)->e & KF_ENCMASK) == KENC_STRUCT || \ ((kd)->e & (kf)->m) == (kf)->f) diff --git a/math/group-test.c b/math/group-test.c index 7cd0cd2..8541b48 100644 --- a/math/group-test.c +++ b/math/group-test.c @@ -75,8 +75,9 @@ static void showmp(const char *p, mp *x, int r) { putc('\n', stderr); } -static int check(const char *op, const char *gd, group *g, - ge *r, ge *c, ...) { +static int EXECL_LIKE(0) + check(const char *op, const char *gd, group *g, ge *r, ge *c, ...) +{ va_list ap; if (G_EQ(g, r, c)) return (1); diff --git a/math/mpint.h b/math/mpint.h index f551980..e351b05 100644 --- a/math/mpint.h +++ b/math/mpint.h @@ -36,6 +36,8 @@ #include +#include + #ifndef CATACOMB_MP_H # include "mp.h" #endif @@ -46,21 +48,9 @@ * * GCC (at least) isn't clever enough to work out that the division in * @MP_FROMINT@ is actually safe (since it will only be executed if @_i > - * MPW_MAX@, which would prove that @(type)MPW_MAX + 1 != 0@). So here's - * some machinery to shut it up. + * MPW_MAX@, which would prove that @(type)MPW_MAX + 1 != 0@). */ -#if __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) -# define MP_FROMINT_MUFFLE_WARNING(x) do { \ - _Pragma("GCC diagnostic push") \ - _Pragma("GCC diagnostic ignored \"-Wdiv-by-zero\"") \ - x \ - _Pragma("GCC diagnostic pop") \ - } while (0) -#else -# define MP_FROMINT_MUFFLE_WARNING(x) do { x } while (0) -#endif - /* --- @MP_FROMINT@ --- * * * Arguments: @d@ = destination multiprecision integer @@ -90,7 +80,9 @@ if (_i <= MPW_MAX) \ break; \ else \ - MP_FROMINT_MUFFLE_WARNING({ _i /= (type)MPW_MAX + 1; }); \ + MUFFLE_WARNINGS_STMT(GCC_WARNING("-Wdiv-by-zero"), { \ + _i /= (type)MPW_MAX + 1; \ + }); \ } \ } else { \ _d->f |= MP_NEG; \ @@ -103,7 +95,9 @@ if (_i >= -MPW_MAX) \ break; \ else \ - MP_FROMINT_MUFFLE_WARNING({ _i /= (type)MPW_MAX + 1; }); \ + MUFFLE_WARNINGS_STMT(GCC_WARNING("-Wdiv-by-zero"), { \ + _i /= (type)MPW_MAX + 1; \ + }); \ } \ } \ \ diff --git a/math/mpx.c b/math/mpx.c index 37a8a4e..5a9a176 100644 --- a/math/mpx.c +++ b/math/mpx.c @@ -33,6 +33,7 @@ #include #include +#include #include "mptypes.h" #include "mpx.h" @@ -661,12 +662,6 @@ done:; * Use; Provides the dyadic boolean functions. */ -/* GCC complains about the generated code, so try to silence it. */ -#if __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wunused-but-set-variable" -#endif - #define MPX_BITBINOP(string) \ \ void mpx_bit##string(mpw *dv, mpw *dvl, const mpw *av, const mpw *avl, \ @@ -680,15 +675,12 @@ void mpx_bit##string(mpw *dv, mpw *dvl, const mpw *av, const mpw *avl, \ a = (av < avl) ? *av++ : 0; \ b = (bv < bvl) ? *bv++ : 0; \ *dv++ = B##string(a, b); \ + IGNORE(a); IGNORE(b); \ } \ } MPX_DOBIN(MPX_BITBINOP) -#if __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) -# pragma GCC diagnostic pop -#endif - void mpx_not(mpw *dv, mpw *dvl, const mpw *av, const mpw *avl) { MPX_SHRINK(av, avl); diff --git a/progs/pixie.c b/progs/pixie.c index 667a588..c501236 100644 --- a/progs/pixie.c +++ b/progs/pixie.c @@ -96,7 +96,7 @@ static unsigned flags = 0; * Use: Writes out a timestamped log message. */ -static void pxlog(const char *p, ...) +static void PRINTF_LIKE(1, 2) pxlog(const char *p, ...) { dstr d = DSTR_INIT; va_list ap; @@ -592,7 +592,7 @@ static void pixserv_expire(struct timeval *tv, void *p) * Use: Formats a string and emits it to the output file. */ -static void pixserv_write(pixserv *px, const char *p, ...) +static void PRINTF_LIKE(2, 3) pixserv_write(pixserv *px, const char *p, ...) { dstr d = DSTR_INIT; va_list ap; @@ -706,7 +706,7 @@ OK\n\ struct timeval tv; gettimeofday(&tv, 0); TV_SUB(&tv, &p->timer.tv, &tv); - pixserv_write(px, "ITEM %s %i\n", p->tag, tv.tv_sec); + pixserv_write(px, "ITEM %s %lu\n", p->tag, (unsigned long)tv.tv_sec); } } pixserv_write(px, "OK\n"); diff --git a/pub/keycheck.h b/pub/keycheck.h index f6b3388..db50e3f 100644 --- a/pub/keycheck.h +++ b/pub/keycheck.h @@ -73,8 +73,9 @@ typedef struct keycheck_reportctx { * Use: Reports a message to the user function. */ -extern int keycheck_report(keycheck */*kc*/, unsigned /*sev*/, - const char */*msg*/, ...); +extern int PRINTF_LIKE(3, 4) + keycheck_report(keycheck */*kc*/, unsigned /*sev*/, + const char */*msg*/, ...); /* --- @keycheck_init@ --- * * diff --git a/symm/des-mktab.c b/symm/des-mktab.c index 7dad026..aa01a9c 100644 --- a/symm/des-mktab.c +++ b/symm/des-mktab.c @@ -33,6 +33,7 @@ #include #include +#include /*----- Static variables --------------------------------------------------*/ @@ -120,7 +121,8 @@ static char p[32] = { * unique. */ -static int unique(const char *t, int base, int sz, const char *name, ...) +static int PRINTF_LIKE(4, 5) + unique(const char *t, int base, int sz, const char *name, ...) { char u[32]; char nbuf[128]; diff --git a/symm/square.c b/symm/square.c index 73b22bb..888d495 100644 --- a/symm/square.c +++ b/symm/square.c @@ -31,6 +31,7 @@ #include #include +#include #include "blkc.h" #include "gcipher.h" @@ -94,20 +95,11 @@ void square_init(square_ctx *k, const void *buf, size_t sz) /* --- GCC complains about an out-of-bounds subscript here --- * * - * This is impossible. Thanks to @KSZ_ASSERT@, we know that @sz <= 16@ and - * hence @i <= nk <= 4@; but @SQUARE_KWORDS == 36@. + * This is impossible. Thanks to @KSZ_ASSERT@, we know that @4 <= sz <= + * 16@ and hence @1 <= i <= nk <= 4@; but @SQUARE_KWORDS == 36@. */ -#if __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Warray-bounds" -#endif - - ww = kk[i - 1]; - -#if __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) -# pragma GCC diagnostic pop -#endif + ww = MUFFLE_WARNINGS_EXPR(GCC_WARNING("-Warray-bounds"), kk[i - 1]); /* --- Expand this material to fill the rest of the table --- */ -- 2.11.0