unsigned m;
} key_filter;
-/* --- Matching aginst key selection --- */
+/* --- 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
#define KEY_MATCH(kd, kf) \
- (!(kf) || \
+ (KEY_MATCH_MUFFLE_WARNING(!(kf)) || \
((kd)->e & KF_ENCMASK) == KENC_STRUCT || \
((kd)->e & (kf)->m) == (kf)->f)
/*----- Generic translation macros ----------------------------------------*/
+/* --- Warning damage control --- *
+ *
+ * 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.
+ */
+
+#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
if (_i <= MPW_MAX) \
break; \
else \
- _i /= (type)MPW_MAX + 1; \
+ MP_FROMINT_MUFFLE_WARNING({ _i /= (type)MPW_MAX + 1; }); \
} \
} else { \
_d->f |= MP_NEG; \
if (_i >= -MPW_MAX) \
break; \
else \
- _i /= (type)MPW_MAX + 1; \
+ MP_FROMINT_MUFFLE_WARNING({ _i /= (type)MPW_MAX + 1; }); \
} \
} \
\
* 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, \
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);
{
pgen_simulctx *ss = p;
pgen_simulprime *sp;
- int rc;
+ int rc = -1;
unsigned i;
mp *m;
octet *d = dest;
if (!d)
- RC4_OPEN(ctx, while (sz) { unsigned x; RC4_BYTE(x); sz--; });
+ RC4_OPEN(ctx, while (sz) { unsigned x; RC4_BYTE(x); (void)x; sz--; });
else if (!s)
RC4_OPEN(ctx, while (sz) { RC4_BYTE(*d++); sz--; });
else
* Use: Initializes a SEAL key table.
*/
-static void gamma(uint32 *p, size_t sz, const void *k, unsigned i)
+static void sealgamma(uint32 *p, size_t sz, const void *k, unsigned i)
{
uint32 buf[80] = { 0 };
const octet *kk = k;
/* --- Expand the key to fit the various tables --- */
- gamma(k->t, 512, k->k, 0);
- gamma(k->s, 256, k->k, 0x1000);
- gamma(k->r, SEAL_R, k->k, 0x2000);
+ sealgamma(k->t, 512, k->k, 0);
+ sealgamma(k->s, 256, k->k, 0x1000);
+ sealgamma(k->r, SEAL_R, k->k, 0x2000);
}
/* --- @seal_reset@ --- *
/* --- Initialize the new chaining variables --- */
if (c->l >= SEAL_R) {
- gamma(c->rbuf, SEAL_R, k->k, c->ri);
+ sealgamma(c->rbuf, SEAL_R, k->k, c->ri);
c->ri += SEAL_R;
c->l = 0;
c->r = c->rbuf;
}
nr = 8;
+ /* --- 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@.
+ */
+
+#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
+
/* --- Expand this material to fill the rest of the table --- */
nw = (nr + 1) * 4;
- ww = kk[i - 1];
p = RCON;
for (; i < nw; i++) {
uint32 w = kk[i - nk];