[PATCH] don't name parameter "errno"

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


http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/errno.h.html
says:

"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.

-- 
vda


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[];
 #endif /* HAVE_DECL_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