]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
cmd: Reduce scope of 'count' variable 2552/head
authorTobin C. Harding <me@tobin.cc>
Mon, 20 Aug 2018 06:31:33 +0000 (16:31 +1000)
committerTobin C. Harding <me@tobin.cc>
Mon, 20 Aug 2018 23:25:30 +0000 (09:25 +1000)
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 <me@tobin.cc>
src/lxc/cmd/lxc_user_nic.c

index cc73124476e782d6eaedcfe0b5f62b1921a331c2..f107f6249e6652d3412b16663c4450034b6bf0c1 100644 (file)
@@ -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;