From aac44dc4ff44a70689f657829ccda2b3aeeb595f Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Mon, 20 Aug 2018 16:31:33 +1000 Subject: [PATCH] cmd: Reduce scope of 'count' variable Variable is used in one plaice only within a nested statement block. The code is cleaner if the variable is declared near where it is used. Found using cppcheck. Reduce the scope of 'count' variable. Signed-off-by: Tobin C. Harding --- src/lxc/cmd/lxc_user_nic.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lxc/cmd/lxc_user_nic.c b/src/lxc/cmd/lxc_user_nic.c index cc7312447..f107f6249 100644 --- a/src/lxc/cmd/lxc_user_nic.c +++ b/src/lxc/cmd/lxc_user_nic.c @@ -707,7 +707,6 @@ static char *get_nic_if_avail(int fd, struct alloted_s *names, int pid, char nicname[IFNAMSIZ]; struct stat sb; struct alloted_s *n; - int count = 0; char *buf = NULL; for (n = names; n != NULL; n = n->next) @@ -735,6 +734,8 @@ static char *get_nic_if_avail(int fd, struct alloted_s *names, int pid, owner = NULL; for (n = names; n != NULL; n = n->next) { + int count; + count = count_entries(buf, sb.st_size, n->name, intype, br); if (count >= n->allowed) continue; -- 2.47.2