From: Sami Kerola Date: Sun, 8 Jul 2012 19:03:14 +0000 (+0200) Subject: utmpdump: fixes based on static analysis [cppcheck] X-Git-Tag: v2.22-rc1~172 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e31926b4434a4df877745039809705361d1c79e8;p=thirdparty%2Futil-linux.git utmpdump: fixes based on static analysis [cppcheck] [utmpdump.c:82]: (style) The function 'unspace' is never used [utmpdump.c:131]: (style) The scope of the variable 't' can be reduced [utmpdump.c:167]: (warning) scanf without field width limits can crash with huge input data [kzak@redhat.com: - don't use scanf field width limits for integers] Signed-off-by: Sami Kerola Signed-off-by: Karel Zak --- diff --git a/login-utils/utmpdump.c b/login-utils/utmpdump.c index a525ad1352..6c0751d575 100644 --- a/login-utils/utmpdump.c +++ b/login-utils/utmpdump.c @@ -79,15 +79,6 @@ static void xcleanse(char *s, int len) *s = '?'; } -static void unspace(char *s, int len) -{ - while (*s && *s != ' ' && len--) - ++s; - - if (len > 0) - *s = '\0'; -} - static void print_utline(struct utmp ut) { char *addr_string, *time_string; @@ -128,7 +119,6 @@ static void dump(FILE *fp, int forever) static int gettok(char *line, char *dest, int size, int eatspace) { int bpos, epos, eaten; - char *t; bpos = strchr(line, '[') - line; if (bpos < 0) @@ -143,6 +133,7 @@ static int gettok(char *line, char *dest, int size, int eatspace) eaten = bpos + epos + 1; if (eatspace) { + char *t; if ((t = strchr(line, ' '))) *t = 0; }