Use the shiny new `mLib' warning-control macros.
authorMark Wooding <mdw@distorted.org.uk>
Sat, 22 Jun 2013 14:04:44 +0000 (15:04 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Fri, 28 Jun 2013 23:31:50 +0000 (00:31 +0100)
configure.ac
debian/control
key/key-data.h
math/group-test.c
math/mpint.h
math/mpx.c
progs/pixie.c
pub/keycheck.h
symm/des-mktab.c
symm/square.c

index 7c66807..fbbb12e 100644 (file)
@@ -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--------------------------------------------------------------------------
index 4c332e4..507a222 100644 (file)
@@ -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 <mdw@distorted.org.uk>
 Standards-Version: 3.1.1
 
index cfeff82..8071116 100644 (file)
@@ -38,6 +38,7 @@
 
 #include <mLib/bits.h>
 #include <mLib/dstr.h>
+#include <mLib/macros.h>
 #include <mLib/sym.h>
 
 #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)
 
index 7cd0cd2..8541b48 100644 (file)
@@ -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);
index f551980..e351b05 100644 (file)
@@ -36,6 +36,8 @@
 
 #include <limits.h>
 
+#include <mLib/macros.h>
+
 #ifndef CATACOMB_MP_H
 #  include "mp.h"
 #endif
  *
  * 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;                                                   \
       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;                                      \
+       });                                                             \
     }                                                                  \
   }                                                                    \
                                                                        \
index 37a8a4e..5a9a176 100644 (file)
@@ -33,6 +33,7 @@
 #include <string.h>
 
 #include <mLib/bits.h>
+#include <mLib/macros.h>
 
 #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);
index 667a588..c501236 100644 (file)
@@ -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");
index f6b3388..db50e3f 100644 (file)
@@ -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@ --- *
  *
index 7dad026..aa01a9c 100644 (file)
@@ -33,6 +33,7 @@
 #include <string.h>
 
 #include <mLib/bits.h>
+#include <mLib/macros.h>
 
 /*----- 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];
index 73b22bb..888d495 100644 (file)
@@ -31,6 +31,7 @@
 #include <stdio.h>
 
 #include <mLib/bits.h>
+#include <mLib/macros.h>
 
 #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 --- */