From bc318926d701befde030b77948c343bb337b0713 Mon Sep 17 00:00:00 2001 From: Aleksa Sarai Date: Fri, 28 Oct 2022 12:27:57 +1100 Subject: [PATCH] cgroups: fix -Waddress warning MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- src/lxc/cgroups/cgfsng.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lxc/cgroups/cgfsng.c b/src/lxc/cgroups/cgfsng.c index d90e5385e..9293f6dbd 100644 --- a/src/lxc/cgroups/cgfsng.c +++ b/src/lxc/cgroups/cgfsng.c @@ -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) { -- 2.47.2