]> granicus.if.org Git - procps-ng/commitdiff
pmap: ensure arg1 is not null, and set qualifers to match with usage [smatch scan]
authorSami Kerola <kerolasa@iki.fi>
Sun, 5 Feb 2012 20:43:36 +0000 (21:43 +0100)
committerSami Kerola <kerolasa@iki.fi>
Sun, 5 Feb 2012 20:43:36 +0000 (21:43 +0100)
pmap.c:436 main(59) error: we previously assumed 'arg1' could be null (see line 427)
pmap.c:136:3: warning: return discards 'const' qualifier from pointer target type [enabled by default]
pmap.c:142:4: warning: return discards 'const' qualifier from pointer target type [enabled by default]
pmap.c:150:2: warning: return discards 'const' qualifier from pointer target type [enabled by default]
pmap.c:300:8: warning: assignment discards 'const' qualifier from pointer target type [enabled by default]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
pmap.c

diff --git a/pmap.c b/pmap.c
index 3296ea704ae7496eb3174b3e1604a0d1cc02479f..e0801eff4817cc392d08611a0f729ba27330eee1 100644 (file)
--- a/pmap.c
+++ b/pmap.c
@@ -116,12 +116,12 @@ static void discover_shm_minor(void)
        return;
 }
 
-static const char *mapping_name(proc_t * p, unsigned KLONG addr,
+static char *mapping_name(proc_t * p, unsigned KLONG addr,
                                unsigned KLONG len, const char *mapbuf,
                                unsigned showpath, unsigned dev_major,
                                unsigned dev_minor, unsigned long long inode)
 {
-       const char *cp;
+       char *cp;
 
        if (!dev_major && dev_minor == shm_minor && strstr(mapbuf, "/SYSV")) {
                static char shmbuf[64];
@@ -433,11 +433,11 @@ int main(int argc, char **argv)
                                if(arg2) ++arg2;
                                else arg2 = arg1;
 
-                               if (*arg1)
+                               if (arg1 && *arg1)
                                        range_low = STRTOUKL(arg1, &arg1, 16);
                                if (*arg2)
                                        range_high = STRTOUKL(arg2, &arg2, 16);
-                               if (*arg1 || *arg2)
+                               if (arg1 && (*arg1 || *arg2))
                                        usage(stderr);
                        }
                        break;