chiark / gitweb /
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 7c66807198bbf4680bc4d4295bea254d0de29b45..fbbb12e7d440ab215447fda8faffd97c7c6502ff 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 4c332e4273b50eb1ae72ec50f3f34c54b9bbeed5..507a22287b9f37bc32c489fbe4e55746169f4e1a 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 cfeff8208b9bee10f2ab201b9d03d14ef4ae74cf..8071116a95c20a8f6fb29877c7b85385ab09b6ce 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 7cd0cd2574ada784f0b9061186ef2e61834e0a15..8541b48530ab6ea0191e8809f6d669de9f7bf9d2 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 f551980a4ae119090f0c89b6eb26a5ea149deccb..e351b0567e9c8d24d0853d0871d840838629f5a1 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 37a8a4e56b7d31764b51d44a82fc4d61688c908a..5a9a1760ba29a8b0f57c08f201f8ed4f4b458b3e 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 667a588c3bc3908be5dfc2a153f2f4b818ffb649..c501236fd5b1facfb2a3ecf826839df8a86e01de 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 f6b3388711b0f2cf0549398001a6da65b9083288..db50e3ffb377f90e9351bcb4240366e1e6de44d9 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 7dad026d3b45340a9692bd9cc54cb4ae444fb0bd..aa01a9c3e2aea3abe056deec5f642c7cdae38ca6 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 73b22bb6aa0e030bba812e30e50b86732f69bb8c..888d4957dd33a0daecb195ac23ceca31d1215efa 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 --- */