summaryrefslogtreecommitdiffstats
path: root/usr.bin/hexdump/display.c
diff options
context:
space:
mode:
authorjohan <johan@FreeBSD.org>2004-07-22 13:14:42 +0000
committerjohan <johan@FreeBSD.org>2004-07-22 13:14:42 +0000
commitf895222e8149d7dae0dcd68b1eb2a25f157d9b30 (patch)
treedc9bf06dc37064adf55d14022440d375ab9479bc /usr.bin/hexdump/display.c
parentf85b318ed67c86365b6627242dd1f5cf3196988b (diff)
downloadFreeBSD-src-f895222e8149d7dae0dcd68b1eb2a25f157d9b30.zip
FreeBSD-src-f895222e8149d7dae0dcd68b1eb2a25f157d9b30.tar.gz
display.c:
- 'savech' is only used if it is set a few lines above where it is used, initialize it to silence warning. - 'length' is either -1 or greater than 0, hence it is safe to cast it to unsigned when comparing it here. odsyntax.c: - 'p' is assigned either (*argvp)[0] or (*argvp)[1] which both are char *. 'num' and 'end' are assigned values based on 'p'. Hence use char * instead of unsigned char * for these variables. '&end' as the second argument to strtoll does not need to be casted to char** any more. This solves a 'dereferencing type-punned pointer will break strict-aliasing rules' warning when compiling with -O2. parse.c: - 'prec' is only used when sokay == USEPREC and sokay = USEPREC when 'prec' is assigned. Hence 'prec' is not used uninitialized, initialize it to silence warning. - The code involving 'nextpr' is hard to follow, but I belive 'nextpr' will not be used unless it is initialized. Anyway, IF 'nextpr' is used uninitialized it is better to get a consistant error (seg fault, when dereferencing a NULL pointer) than potentially accessing some random memory. The above changes makes hexdump WARNS=6 clean even when compiled with -O2. Hence bump WARNS to keep it clean. Tested by: CFLAGS='-O2 -pipe' make universe
Diffstat (limited to 'usr.bin/hexdump/display.c')
-rw-r--r--usr.bin/hexdump/display.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/usr.bin/hexdump/display.c b/usr.bin/hexdump/display.c
index c9ba892..0887f05 100644
--- a/usr.bin/hexdump/display.c
+++ b/usr.bin/hexdump/display.c
@@ -68,6 +68,7 @@ display(void)
off_t saveaddress;
u_char savech, *savebp;
+ savech = 0;
while ((bp = get()))
for (fs = fshead, savebp = bp, saveaddress = address; fs;
fs = fs->nextfs, bp = savebp, address = saveaddress)
@@ -318,7 +319,7 @@ peek(u_char *buf, size_t nbytes)
size_t n, nread;
int c;
- if (length != -1 && nbytes > length)
+ if (length != -1 && nbytes > (unsigned int)length)
nbytes = length;
nread = 0;
while (nread < nbytes && (c = getchar()) != EOF) {
OpenPOWER on IntegriCloud