diff options
author | Sami Kerola | 2012-06-17 15:01:34 +0200 |
---|---|---|
committer | Sami Kerola | 2012-06-17 18:00:00 +0200 |
commit | 327b7c5bfb3761a8125a41e6a059cb6a5ba5cc3d (patch) | |
tree | a3328194e18035225b740153380c4c612e4fcb4a /text-utils | |
parent | more: fix search repetition regression (diff) | |
download | kernel-qcow2-util-linux-327b7c5bfb3761a8125a41e6a059cb6a5ba5cc3d.tar.gz kernel-qcow2-util-linux-327b7c5bfb3761a8125a41e6a059cb6a5ba5cc3d.tar.xz kernel-qcow2-util-linux-327b7c5bfb3761a8125a41e6a059cb6a5ba5cc3d.zip |
more: fix pointer wrap around compiler warnings
more.c:318:5: warning: assuming pointer wraparound does not occur when comparing P +- C1 with P +- C2 [-Wstrict-overflow]
more.c:362:3: warning: assuming pointer wraparound does not occur when comparing P +- C1 with P +- C2 [-Wstrict-overflow]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'text-utils')
-rw-r--r-- | text-utils/more.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/text-utils/more.c b/text-utils/more.c index acd58c8b0..4cf090fd6 100644 --- a/text-utils/more.c +++ b/text-utils/more.c @@ -318,7 +318,6 @@ static void __attribute__ ((__noreturn__)) usage(FILE *out) int main(int argc, char **argv) { FILE *f; char *s; - char *p; int ch; int left; int prnames = 0; @@ -326,7 +325,7 @@ int main(int argc, char **argv) { int srchopt = 0; int clearit = 0; int initline = 0; - char initbuf[INIT_BUF]; + char *initbuf = NULL; setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); @@ -359,9 +358,7 @@ int main(int argc, char **argv) { s = *fnames; if (*++s == '/') { srchopt++; - for (++s, p = initbuf; p < initbuf + (INIT_BUF - 1) && *s != '\0';) - *p++ = *s++; - *p = '\0'; + initbuf = xstrdup(s + 1); } else { initopt++; @@ -496,6 +493,7 @@ int main(int argc, char **argv) { firstf = 0; } free (previousre); + free (initbuf); reset_tty (); exit(EXIT_SUCCESS); } |