Fixed all known static analysis bugs, with checker-279 on macOS.

This commit is contained in:
Ryan C. Gordon
2016-11-24 21:41:09 -05:00
parent fd250bd636
commit fb5fd67ccb
8 changed files with 159 additions and 88 deletions

View File

@@ -24,6 +24,8 @@ static const char rcsid[] =
#include "math_libm.h"
#include "math_private.h"
#include "SDL_assert.h"
libm_hidden_proto(fabs)
/*
@@ -189,7 +191,12 @@ __ieee754_rem_pio2(x, y)
}
tx[2] = z;
nx = 3;
while (tx[nx - 1] == zero)
/* If this assertion ever fires, here's the static analysis that warned about it:
http://buildbot.libsdl.org/sdl-static-analysis/sdl-macosx-static-analysis/sdl-macosx-static-analysis-1101/report-8c6ccb.html#EndPath */
SDL_assert((tx[0] != zero) || (tx[1] != zero) || (tx[2] != zero));
while (nx && tx[nx - 1] == zero)
nx--; /* skip zero term */
n = __kernel_rem_pio2(tx, y, e0, nx, 2, two_over_pi);
if (hx < 0) {

View File

@@ -204,8 +204,13 @@ __kernel_rem_pio2(x, y, e0, nx, prec, ipio2)
/* compute q[0],q[1],...q[jk] */
for (i = 0; i <= jk; i++) {
for (j = 0, fw = 0.0; j <= jx; j++)
fw += x[j] * f[jx + i - j];
for (j = 0, fw = 0.0; j <= jx; j++) {
const int32_t idx = jx + i - j;
SDL_assert(idx >= 0);
SDL_assert(idx < 20);
SDL_assert(idx <= m);
fw += x[j] * f[idx];
}
q[i] = fw;
}