]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
ss: Remove unnecessary stack variable 'p' in user_ent_hash_build()
authorPeilin Ye <peilin.ye@bytedance.com>
Wed, 25 May 2022 02:52:09 +0000 (19:52 -0700)
committerDavid Ahern <dsahern@kernel.org>
Mon, 30 May 2022 15:53:55 +0000 (09:53 -0600)
Commit 116ac9270b6d ("ss: Add support for retrieving SELinux contexts")
added an unnecessary stack variable, 'char *p', in
user_ent_hash_build().  Delete it for readability.

Signed-off-by: Peilin Ye <peilin.ye@bytedance.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
misc/ss.c

index 251172f15eadacc6aaebc0ed136f4a894f20f070..c65795ebd461ad764a24b3b770d35ac6400b731c 100644 (file)
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -618,7 +618,6 @@ static void user_ent_hash_build(void)
        while ((d = readdir(dir)) != NULL) {
                struct dirent *d1;
                char process[16];
-               char *p;
                int pid, pos;
                DIR *dir1;
 
@@ -636,7 +635,6 @@ static void user_ent_hash_build(void)
                }
 
                process[0] = '\0';
-               p = process;
 
                while ((d1 = readdir(dir1)) != NULL) {
                        const char *pattern = "socket:[";
@@ -667,18 +665,18 @@ static void user_ent_hash_build(void)
                        if (getfilecon(tmp, &sock_context) <= 0)
                                sock_context = strdup(no_ctx);
 
-                       if (*p == '\0') {
+                       if (process[0] == '\0') {
                                FILE *fp;
 
                                snprintf(tmp, sizeof(tmp), "%s/%d/stat",
                                        root, pid);
                                if ((fp = fopen(tmp, "r")) != NULL) {
-                                       if (fscanf(fp, "%*d (%[^)])", p) < 1)
+                                       if (fscanf(fp, "%*d (%[^)])", process) < 1)
                                                ; /* ignore */
                                        fclose(fp);
                                }
                        }
-                       user_ent_add(ino, p, pid, fd,
+                       user_ent_add(ino, process, pid, fd,
                                        pid_context, sock_context);
                        freecon(sock_context);
                }