[PATCH] don't name parameter "errno"

Denys Vlasenko dvlasenk at redhat.com
Tue May 24 20:41:31 UTC 2011


"The <errno.h> header shall provide a declaration or definition for
errno. The symbol errno shall expand to a modifiable lvalue of type int.
It is unspecified whether errno is a macro or an identifier declared
with external linkage. If a macro definition is suppressed in order to
access an actual object, or a program defines an identifier with the
name errno, the behavior is undefined."

strace source does use identifier "errno" at a parameter of one
function. I propose to rename it, so that we don't risk
getting build breakage here on obscure platforms or libcs.


diff -d -urpN strace.5/strace.c strace.6/strace.c
--- strace.5/strace.c	2011-05-24 22:32:51.170636309 +0200
+++ strace.6/strace.c	2011-05-24 20:38:49.135180797 +0200
@@ -1949,15 +1949,15 @@ extern char *sys_errlist[];
 const char *
-strerror(int errno)
+strerror(int err_no)
 	static char buf[64];
-	if (errno < 1 || errno >= sys_nerr) {
-		sprintf(buf, "Unknown error %d", errno);
+	if (err_no < 1 || err_no >= sys_nerr) {
+		sprintf(buf, "Unknown error %d", err_no);
 		return buf;
-	return sys_errlist[errno];
+	return sys_errlist[err_no];
 #endif /* HAVE_STERRROR */

More information about the Strace-devel mailing list