From 7d3b4bcaf2275eb2172069547d7cd4cfec18f6f0 Mon Sep 17 00:00:00 2001 From: Qualys Security Advisory Date: Thu, 1 Jan 1970 00:00:00 +0000 Subject: [PATCH] 0093-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. Signed-off-by: Craig Small --- pmap.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/pmap.c b/pmap.c index d9bcece0..f2bb555c 100644 --- a/pmap.c +++ b/pmap.c @@ -212,12 +212,12 @@ out_destroy: return; } -static char *mapping_name(struct pids_stack *p, unsigned long addr, +static const char *mapping_name(struct pids_stack *p, unsigned long addr, unsigned long 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]; @@ -232,14 +232,6 @@ static char *mapping_name(struct pids_stack *p, unsigned long 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 (PIDS_VAL(start_stack, ul_int, p, Pids_info) >= addr && (PIDS_VAL(start_stack, ul_int, p, Pids_info) <= addr + len))