diff options
author | Michael Brown | 2012-07-03 19:47:50 +0200 |
---|---|---|
committer | Michael Brown | 2012-07-03 19:58:43 +0200 |
commit | bc93e8ab41b7641d5ebb89f35340a17445cd994e (patch) | |
tree | 226609e8e1041a47caa907108bb1a03d1084c334 /src/util | |
parent | [menu] Truncate menu title when necessary (diff) | |
download | ipxe-bc93e8ab41b7641d5ebb89f35340a17445cd994e.tar.gz ipxe-bc93e8ab41b7641d5ebb89f35340a17445cd994e.tar.xz ipxe-bc93e8ab41b7641d5ebb89f35340a17445cd994e.zip |
[util] Avoid compiler warning on gcc 4.6
Commit 196751c ("[build] Enable warnings when building utilities")
revealed a previously hidden compiler warning in util/nrv2b.c
regarding an out-of-bounds array subscript in the code
#if defined(SWD_BEST_OFF)
if (s->best_pos[2] == 0)
s->best_pos[2] = key + 1;
#endif
where best_pos[] is defined by
#define SWD_BEST_OFF 1
#if defined(SWD_BEST_OFF)
unsigned int best_off[ SWD_BEST_OFF ];
unsigned int best_pos[ SWD_BEST_OFF ];
#endif
With SWD_BEST_OFF set to 1, it can be proven that all code paths
referring to s->best_off[] and s->best_pos[] will never be executed,
with the exception of the two lines above. Since these two lines
alone can have no effect on execution, we can safely undefine
SWD_BEST_OFF.
Verified by comparing md5sums of bin/undionly.kpxe before and after
the change.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/nrv2b.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/util/nrv2b.c b/src/util/nrv2b.c index cbb94c0e..031f5d9c 100644 --- a/src/util/nrv2b.c +++ b/src/util/nrv2b.c @@ -209,7 +209,7 @@ struct ucl_compress #define SWD_HSIZE 16384 #define SWD_MAX_CHAIN 2048 -#define SWD_BEST_OFF 1 +#undef SWD_BEST_OFF #define HEAD3(b,p) \ (((0x9f5f*(((((uint32_t)b[p]<<5)^b[p+1])<<5)^b[p+2]))>>5) & (SWD_HSIZE-1)) |