]> granicus.if.org Git - procps-ng/commitdiff
pmap: Remove dead code in mapping_name().
authorQualys Security Advisory <qsa@qualys.com>
Thu, 1 Jan 1970 00:00:00 +0000 (00:00 +0000)
committerCraig Small <csmall@enc.com.au>
Fri, 18 May 2018 21:32:22 +0000 (07:32 +1000)
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.

pmap.c

diff --git a/pmap.c b/pmap.c
index 48a4f199aedcf1fe392679e2b4d258de74d7d2c0..ae1aea99bfea3fb5574efe7f9f13d42936db4757 100644 (file)
--- a/pmap.c
+++ b/pmap.c
@@ -208,12 +208,12 @@ out_destroy:
        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 showpath, unsigned dev_major,
                                unsigned dev_minor, unsigned long long inode)
 {
-       char *cp;
+       const char *cp;
 
        if (!dev_major && dev_minor == shm_minor && strstr(mapbuf_b, "/SYSV")) {
                static char shmbuf[64];
@@ -228,14 +228,6 @@ static char *mapping_name(proc_t * p, unsigned KLONG addr,
                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 ]");
        if ((p->start_stack >= addr) && (p->start_stack <= addr + len))
                cp = _("  [ stack ]");