]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
utmpdump: fixes based on static analysis [cppcheck]
authorSami Kerola <kerolasa@iki.fi>
Sun, 8 Jul 2012 19:03:14 +0000 (21:03 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 10 Jul 2012 06:56:22 +0000 (08:56 +0200)
[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 <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
login-utils/utmpdump.c

index a525ad13528878401896fd6f7dce7db3b1ba06ad..6c0751d57561175c405d993df9bff219fc48228d 100644 (file)
@@ -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;
        }