From: Aleksa Sarai Date: Fri, 28 Oct 2022 01:27:57 +0000 (+1100) Subject: cgroups: fix -Waddress warning X-Git-Tag: lxc-5.0.2~53^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2a9743bba63903b66331b0b90fe2c25784585b89;p=thirdparty%2Flxc.git cgroups: fix -Waddress warning 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 --- diff --git a/src/lxc/cgroups/cgfsng.c b/src/lxc/cgroups/cgfsng.c index ee4fc052f..0c70095b1 100644 --- a/src/lxc/cgroups/cgfsng.c +++ b/src/lxc/cgroups/cgfsng.c @@ -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) {