diff options
author | Thomas Haller <thaller@redhat.com> | 2017-12-13 08:41:11 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2017-12-13 11:12:19 +0100 |
commit | dbcb4a900ef7e9673604caabc1e1842309b7fd73 (patch) | |
tree | 60ef21f2f084efa72e0284b0efdc433193158f96 /src/basic/fd-util.c | |
parent | 6febe75da76517a69f073fb50abffc5c2c7d58cd (diff) | |
download | systemd-dbcb4a900ef7e9673604caabc1e1842309b7fd73.tar.gz |
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.
Diffstat (limited to 'src/basic/fd-util.c')
-rw-r--r-- | src/basic/fd-util.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/basic/fd-util.c b/src/basic/fd-util.c index f3863722ee..a0820a9667 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); |