From 910f54c083a74496cccbcea8e77490b9ce66b456 Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Tue, 25 Nov 2025 22:51:28 +0100 Subject: [PATCH] lib/string/: strerrno(): Use statement expression to perform lvalue conversion Compound literals are lvalues. This means it's possible to take their address. That is, it would be possible (albeit nonsensical) to do &strerrno(); It is also possible to assign to them (albeit also nonsensical): strerrno() = NULL; The statement expression performs lvalue conversion, which turns the lvalue into an "rvalue", as expected, and disallows all those issues. Signed-off-by: Alejandro Colomar --- lib/string/strerrno.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/string/strerrno.h b/lib/string/strerrno.h index b82e1015c..9f28a86a4 100644 --- a/lib/string/strerrno.h +++ b/lib/string/strerrno.h @@ -13,7 +13,7 @@ // strerrno - string errno -#define strerrno() ((const char *){strerror(errno)}) +#define strerrno() ({(const char *){strerror(errno)};}) #endif // include guard -- 2.47.3