pmap: ensure arg1 is not null, and set qualifers to match with usage [smatch scan]

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>
This commit is contained in:
Sami Kerola 2012-02-05 21:43:36 +01:00
parent b2ebca4a60
commit cbb9e54587

8
pmap.c
View File

@ -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;