From 14338cca996b3d2c361d679d5859389305ddc5b3 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Tue, 28 Nov 2023 13:02:02 +0900 Subject: [PATCH] core/cgroup: fix compile error MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit With gcc-13, ``` CFLAGS="-O3 -fno-semantic-interposition" meson setup build ``` triggers the following error: ``` ../src/core/cgroup.c: In function ‘cgroup_context_dump’: ../src/core/cgroup.c:633:44: error: ‘%s’ directive argument is null [-Werror=format-overflow=] 633 | "%sDeviceAllow: %s %s\n", | ^~ cc1: some warnings being treated as errors ``` Fixes #30223. --- src/core/cgroup.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/cgroup.c b/src/core/cgroup.c index 10678dc..e1bf90d 100644 --- a/src/core/cgroup.c +++ b/src/core/cgroup.c @@ -629,11 +629,12 @@ void cgroup_context_dump(Unit *u, FILE* f, const char *prefix) { prefix, FORMAT_TIMESPAN(c->memory_pressure_threshold_usec, 1)); LIST_FOREACH(device_allow, a, c->device_allow) + /* strna() below should be redundant, for avoiding -Werror=format-overflow= error. See #30223. */ fprintf(f, "%sDeviceAllow: %s %s\n", prefix, a->path, - cgroup_device_permissions_to_string(a->permissions)); + strna(cgroup_device_permissions_to_string(a->permissions))); LIST_FOREACH(device_weights, iw, c->io_device_weights) fprintf(f, -- 2.7.4