]> 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>
Fri, 28 Oct 2022 03:33:20 +0000 (14:33 +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 ee4fc052fd610ef8b45c85644bfde22828d3112e..0c70095b1e1af3b8bc09002f5685db946d296c5e 100644 (file)
@@ -3302,7 +3302,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);
        }
 
@@ -3755,7 +3755,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) {