pmap: Remove dead code in mapping_name().

If "cp = strrchr(mapbuf_b, '/')" then this function returns, and
otherwise there is no '/' in mapbuf_b and "cp = strchr(mapbuf_b, '/')"
is always false: remove this second block, since it is never entered.
Also, constify a few things in this function.
This commit is contained in:
Qualys Security Advisory 1970-01-01 00:00:00 +00:00 committed by Craig Small
parent c9241d85ac
commit 32e57dbb88

12
pmap.c
View File

@ -208,12 +208,12 @@ out_destroy:
return; return;
} }
static char *mapping_name(proc_t * p, unsigned KLONG addr, static const char *mapping_name(const proc_t * p, unsigned KLONG addr,
unsigned KLONG len, const char *mapbuf_b, unsigned KLONG len, const char *mapbuf_b,
unsigned showpath, unsigned dev_major, unsigned showpath, unsigned dev_major,
unsigned dev_minor, unsigned long long inode) unsigned dev_minor, unsigned long long inode)
{ {
char *cp; const char *cp;
if (!dev_major && dev_minor == shm_minor && strstr(mapbuf_b, "/SYSV")) { if (!dev_major && dev_minor == shm_minor && strstr(mapbuf_b, "/SYSV")) {
static char shmbuf[64]; static char shmbuf[64];
@ -228,14 +228,6 @@ static char *mapping_name(proc_t * p, unsigned KLONG addr,
return cp[1] ? cp + 1 : cp; return cp[1] ? cp + 1 : cp;
} }
cp = strchr(mapbuf_b, '/');
if (cp) {
if (showpath)
return cp;
/* it WILL succeed */
return strrchr(cp, '/') + 1;
}
cp = _(" [ anon ]"); cp = _(" [ anon ]");
if ((p->start_stack >= addr) && (p->start_stack <= addr + len)) if ((p->start_stack >= addr) && (p->start_stack <= addr + len))
cp = _(" [ stack ]"); cp = _(" [ stack ]");