From: Niels Möller Date: Thu, 14 Sep 2017 07:06:49 +0000 (+0200) Subject: Workaround to silence the clang static analyzer. X-Git-Tag: nettle_3.4rc1~25 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=90e3aee65570ec35b8f3ca5e4b8d01c2e7a0fbfe;p=thirdparty%2Fnettle.git Workaround to silence the clang static analyzer. --- diff --git a/ChangeLog b/ChangeLog index b9f597a2..8c795096 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2017-09-14 Niels Möller + + * ecc-mod.c (ecc_mod): Workaround to silence a false positive from + the clang static analyzer. + 2017-09-12 Niels Möller * testsuite/testutils.h (mpn_zero_p): Avoid redefining mpn_zero_p diff --git a/ecc-mod.c b/ecc-mod.c index 5fee4c68..4e77f0c0 100644 --- a/ecc-mod.c +++ b/ecc-mod.c @@ -51,7 +51,7 @@ ecc_mod (const struct ecc_modulo *m, mp_limb_t *rp) mp_size_t i; unsigned shift; - assert (sn > 0); + assert (bn < mn); /* FIXME: Could use mpn_addmul_2. */ /* Eliminate sn limbs at a time */ @@ -72,6 +72,12 @@ ecc_mod (const struct ecc_modulo *m, mp_limb_t *rp) } else { + /* The loop below always runs at least once. But the analyzer + doesn't realize that, and complains about hi being used later + on without a well defined value. */ +#ifdef __clang_analyzer__ + hi = 0; +#endif while (rn >= 2 * mn - bn) { rn -= sn;