From: Tobin C. Harding Date: Mon, 20 Aug 2018 06:31:33 +0000 (+1000) Subject: cmd: Reduce scope of 'count' variable X-Git-Tag: lxc-3.1.0~144^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aac44dc4ff44a70689f657829ccda2b3aeeb595f;p=thirdparty%2Flxc.git 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 --- 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;