From b4def29b8a9745ca45601058e76401a29db9dd2d Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 13 Dec 2017 08:41:11 +0100 Subject: [PATCH] tree-wide: use STRLEN() to allocate buffer of constant size Using strlen() to declare a buffer results in a variable-length array, even if the compiler likely optimizes it to be a compile time constant. When building with -Wvla, certain versions of gcc complain about such buffers. Compiling with -Wvla has the advantage of preventing variably length array, which defeat static asserts that are implemented by declaring an array of negative length. --- src/basic/fd-util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/basic/fd-util.c b/src/basic/fd-util.c index 565902c7b..a2d51d807 100644 --- a/src/basic/fd-util.c +++ b/src/basic/fd-util.c @@ -368,7 +368,7 @@ bool fdname_is_valid(const char *s) { } int fd_get_path(int fd, char **ret) { - char procfs_path[strlen("/proc/self/fd/") + DECIMAL_STR_MAX(int)]; + char procfs_path[STRLEN("/proc/self/fd/") + DECIMAL_STR_MAX(int)]; int r; xsprintf(procfs_path, "/proc/self/fd/%i", fd); -- 2.30.2