Skip to contentSkip to conversation

Remove errno declaration in drivers/sbus/char/envctrl.c

PATCH In review Mathieu Chouquet-Stringer 2 participants 5 messages Aug 4, 2005 – Aug 6, 2005 SPARC + UltraSPARC (sparc/sparc64)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Remove errno declaration in drivers/sbus/char/envctrl.c

errno is already declarded in linux/errno.h:

drivers/sbus/char/envctrl.c:40: error: static declaration of 'errno' follows non-static declaration include/linux/unistd.h:4: error: previous declaration of 'errno' was here
make[3]: *** [drivers/sbus/char/envctrl.o] Error 1
make[2]: *** [drivers/sbus/char] Error 2
make[1]: *** [drivers/sbus] Error 2
make: *** [drivers] Error 2

Moreover errno isn't used in this file at all so the following patch (against latest git tree) just removes it (kernel compiles fine).

drivers/sbus/char/envctrl.c +0 -1
@@ -37,7 +37,6 @@
 #include <asm/uaccess.h>
 #include <asm/envctrl.h>
 
-static int errno;
 #include <asm/unistd.h>
 
 #define ENVCTRL_MINOR	162
maintainer
#1 lore raw

From: Mathieu Chouquet-Stringer <[email protected]>
Subject: [PATCH] Remove errno declaration in drivers/sbus/char/envctrl.c
Date: Thu, 04 Aug 2005 09:48:03 -0400

Quoted 1 line

errno is already declarded in linux/errno.h:

Where? It _is_ defined in linux/unistd.h and the fact that we're indirectly getting that header file somehow is the source of the problem.

Quoted 2 lines

Moreover errno isn't used in this file at all so the following patch (against latest git tree) just removes it (kernel compiles fine).

It is used implicitly by the system call macros inside of asm-*/unistd.h, for example in the _syscall?() macros.

And we do call execve() in envctrl.c which expands to one of those macros (specifically, _syscall3()).

So you patch is not correct.

Probably the best version of the fix would be to include linux/unistd.h instead of asm/unistd.h, so you might want to code that up and test it out.

#2 lore raw
In reply to Mathieu Chouquet-Stringer
Quoted 3 lines · David S. Miller

Where? It _is_ defined in linux/unistd.h and the fact that we're indirectly getting that header file somehow is the source of the problem.

Yeah, I guess I shouldn't send emails early in the morning... :-)

Quoted 6 lines

[snip]
So you patch is not correct.

Probably the best version of the fix would be to include linux/unistd.h instead of asm/unistd.h, so you might want to code that up and test it out.

Ok, trying this out...

Signature · 1 line
Mathieu Chouquet-Stringer
#3 lore raw
In reply to Mathieu Chouquet-Stringer
Quoted 4 lines · David S. Miller

[snip]
Probably the best version of the fix would be to include linux/unistd.h instead of asm/unistd.h, so you might want to code that up and test it out.

Thanks for the feedback, what about the following then? It's compiled and booted and I've realized than bbc_envctrl.c suffers from the same thing, so here you go. Let me know if it makes sense...

drivers/sbus/char/envctrl.c +1 -3
@@ -32,14 +32,12 @@
 #include <linux/mm.h>
 #include <linux/slab.h>
 #include <linux/kernel.h>
+#include <linux/unistd.h>
 
 #include <asm/ebus.h>
 #include <asm/uaccess.h>
 #include <asm/envctrl.h>
 
-static int errno;
-#include <asm/unistd.h>
-
 #define ENVCTRL_MINOR	162
 
 #define PCF8584_ADDRESS	0x55
drivers/sbus/char/bbc_envctrl.c +1 -2
@@ -10,10 +10,9 @@
 #include <linux/sched.h>
 #include <linux/slab.h>
 #include <linux/delay.h>
+#include <linux/unistd.h>
 #include <asm/oplib.h>
 #include <asm/ebus.h>
-static int errno;
-#include <asm/unistd.h>
 
 #include "bbc_i2c.h"
 #include "max1617.h"
Signature · 1 line
Mathieu Chouquet-Stringer                   E-Mail: [email protected]