]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
cgroups: fix -Waddress warning
authorAleksa Sarai <cyphar@cyphar.com>
Fri, 28 Oct 2022 01:27:57 +0000 (12:27 +1100)
committerAleksa Sarai <cyphar@cyphar.com>
Sun, 30 Oct 2022 13:07:53 +0000 (00:07 +1100)
While in principle the pointer could overflow, GCC 12 considers this to
not be possible and issues the following warning:

  ../src/lxc/cgroups/cgfsng.c: In function ‘__cgfsng_delegate_controllers’:
  ../src/lxc/cgroups/cgfsng.c:3306:21: warning: the comparison will always evaluate as ‘true’ for the pointer operand in ‘it + 8’ must not be NULL [-Waddress]
   3306 |                 if ((it + 1) && *(it + 1))
        |                     ^

This removes the only build warning triggered when building on openSUSE.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
src/lxc/cgroups/cgfsng.c

index d90e5385e1774405da80580ff4f30d8f01598e15..9293f6dbd4fc95e37a13e02d12721e06813de113 100644 (file)
@@ -3303,7 +3303,7 @@ static bool __cgfsng_delegate_controllers(struct cgroup_ops *ops, const char *cg
                (void)strlcat(add_controllers, "+", full_len + 1);
                (void)strlcat(add_controllers, *it, full_len + 1);
 
-               if ((it + 1) && *(it + 1))
+               if (*(it + 1))
                        (void)strlcat(add_controllers, " ", full_len + 1);
        }
 
@@ -3756,7 +3756,7 @@ static int __initialize_cgroups(struct cgroup_ops *ops, bool relative,
         * from the layout bitmask we created when parsing the cgroups.
         *
         * Keep the ordering in the switch otherwise the bistmask-based
-        * matching won't work. 
+        * matching won't work.
         */
        if (ops->cgroup_layout == CGROUP_LAYOUT_UNKNOWN) {
                switch (layout_mask) {