From: Peilin Ye Date: Wed, 25 May 2022 02:52:21 +0000 (-0700) Subject: ss: Do not call user_ent_hash_build() more than once X-Git-Tag: v6.0.0~42^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cd845a85681bf2851b38041587fa75605beebbe9;p=thirdparty%2Fiproute2.git ss: Do not call user_ent_hash_build() more than once Call user_ent_hash_build() once after the getopt_long() loop if -p, -z or -Z is used. Signed-off-by: Peilin Ye Signed-off-by: David Ahern --- diff --git a/misc/ss.c b/misc/ss.c index c65795ebd..f077bed70 100644 --- a/misc/ss.c +++ b/misc/ss.c @@ -596,13 +596,6 @@ static void user_ent_hash_build(void) char *pid_context; char *sock_context; const char *no_ctx = "unavailable"; - static int user_ent_hash_build_init; - - /* If show_users & show_proc_ctx set only do this once */ - if (user_ent_hash_build_init != 0) - return; - - user_ent_hash_build_init = 1; strlcpy(name, root, sizeof(name)); @@ -5515,7 +5508,6 @@ int main(int argc, char *argv[]) break; case 'p': show_users++; - user_ent_hash_build(); break; case 'b': show_options = 1; @@ -5650,7 +5642,6 @@ int main(int argc, char *argv[]) exit(1); } show_proc_ctx++; - user_ent_hash_build(); break; case 'N': if (netns_switch(optarg)) @@ -5685,6 +5676,9 @@ int main(int argc, char *argv[]) } } + if (show_users || show_proc_ctx || show_sock_ctx) + user_ent_hash_build(); + argc -= optind; argv += optind;