[PATCH v4 next 10/23] tools/nolibc: Rename the 'errnum' parameter to strerror()

david.laight.linux@gmail.com posted 23 patches 1 month, 1 week ago
There is a newer version of this series
[PATCH v4 next 10/23] tools/nolibc: Rename the 'errnum' parameter to strerror()
Posted by david.laight.linux@gmail.com 1 month, 1 week ago
From: David Laight <david.laight.linux@gmail.com>

Change the parameter variable name from 'errno' to 'errnum'.
Matches any documentation and avoids any issues that might happen
if errno is actually a #define (which is not uncommon).

Signed-off-by: David Laight <david.laight.linux@gmail.com>
---

v4:
- split from the previous patch.

 tools/include/nolibc/stdio.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/include/nolibc/stdio.h b/tools/include/nolibc/stdio.h
index 03fcd0229f90..a567b9a5c31e 100644
--- a/tools/include/nolibc/stdio.h
+++ b/tools/include/nolibc/stdio.h
@@ -730,7 +730,7 @@ int strerror_r(int errnum, char *buf, size_t buflen __attribute__((unused)))
 }
 
 static __attribute__((unused))
-const char *strerror(int errno)
+const char *strerror(int errnum)
 {
 	static char buf[18];
 	char *b = buf;
@@ -739,7 +739,7 @@ const char *strerror(int errno)
 	_NOLIBC_OPTIMIZER_HIDE_VAR(b);
 
 	/* Use strerror_r() to avoid having the only .data in small programs. */
-	strerror_r(errno, b, sizeof(buf));
+	strerror_r(errnum, b, sizeof(buf));
 
 	return b;
 }
-- 
2.39.5
Re: [PATCH v4 next 10/23] tools/nolibc: Rename the 'errnum' parameter to strerror()
Posted by Willy Tarreau 1 month ago
On Mon, Mar 02, 2026 at 10:18:02AM +0000, david.laight.linux@gmail.com wrote:
> From: David Laight <david.laight.linux@gmail.com>
> 
> Change the parameter variable name from 'errno' to 'errnum'.
> Matches any documentation and avoids any issues that might happen
> if errno is actually a #define (which is not uncommon).

Good point! And more importantly, shadowing the real errno is super
risky in case we'd call a macro that accesses it from that function.
> 
> Signed-off-by: David Laight <david.laight.linux@gmail.com>

Acked-by: Willy Tarreau <w@1wt.eu>

Willy