Don't return void types from void functions.
A message that is not in the archive (sent off-list or not yet received): [email protected]
drivers/net/tokenring/olympic.c line 1810
Quoted 10 lines · Linux Kernel Mailing List
diff -Nru
a/drivers/net/tokenring/olympic.cb/drivers/net/tokenring/olympic.cdrivers/net/tokenring/olympic.c +1
-1@@ -1806,7 +1806,7 @@ static void __exit olympic_pci_cleanup(void) { -return pci_unregister_driver (&olympic_driver) ; +pci_unregister_driver (&olympic_driver) ; }
Can we make gcc error out when it finds this?
Jeff
Quoted 7 lines · Jeff Garzik
Quoted 6 lines · Linux Kernel Mailing List
diff -Nru
a/drivers/net/tokenring/olympic.cb/drivers/net/tokenring/olympic.c---a/drivers/net/tokenring/olympic.c2004-05-25 23:06:49 -07:00 +++b/drivers/net/tokenring/olympic.c2004-05-25 23:06:49 -07:00 @@ -1806,7
+1806,7 @@
Quoted 7 lines
Review
Quoted 5 lines
static void
__exitolympic_pci_cleanup(void)
{(quoted diff) +1
-1- return pci_unregister_driver(&olympic_driver) ; + pci_unregister_driver(&olympic_driver) ; }Can we make gcc error out when it finds this?
AFAIK new C++ standard allows this syntax.
typedef int opaque;
opaque f();
opaque g() { return f(); }
Now imagine we need to change
-typedef int opaque;
+typedef void opaque;
Signature · 1 line
vda
Quoted 24 lines · Denis Vlasenko
Quoted 7 lines · Jeff Garzik
Quoted 6 lines · Linux Kernel Mailing List
diff -Nru
a/drivers/net/tokenring/olympic.cb/drivers/net/tokenring/olympic.c---a/drivers/net/tokenring/olympic.c2004-05-25 23:06:49 -07:00 +++b/drivers/net/tokenring/olympic.c2004-05-25 23:06:49 -07:00 @@ -1806,7
+1806,7 @@Quoted 7 lines
Review
Quoted 5 lines
static void
__exitolympic_pci_cleanup(void)
{(quoted diff) +1
-1- return pci_unregister_driver(&olympic_driver) ; + pci_unregister_driver(&olympic_driver) ; }Can we make gcc error out when it finds this?
AFAIK new C++ standard allows this syntax.
typedef int opaque;
opaque
f();
opaqueg(){ returnf(); }Now imagine we need to change
Review
Quoted 2 lines
(quoted diff) +1
-1-typedef int opaque; +typedef void opaque;
strict ISO C++ - yes,
strict ISO C - no.
# g++ -Wall -s -c void_ret.cpp -pedantic-errors
# gcc -Wall -s -c void_ret.c -pedantic-errors void_ret.c: In function `g': void_ret.c:4: error: `return' with a value, in function returning void
# gcc --version gcc (GCC) 3.4.0 SSP (PLD Linux) (...)
Signature · 2 lines
If you think of MS-DOS as mono, and Windows as stereo, then Linux is Dolby Digital and all the music is free...
Followup to: <[email protected]> By author: Jeff Garzik <[email protected]> In newsgroup: linux.dev.kernel
Quoted 7 lines
Quoted 5 lines · Linux Kernel Mailing List
diff -Nru
a/drivers/net/tokenring/olympic.cb/drivers/net/tokenring/olympic.cdrivers/net/tokenring/olympic.c +0
-0@@ -1806,7 +1806,7 @@
Quoted 9 lines
drivers/net/tokenring/olympic.c line 1810
Quoted 5 lines
drivers/net/tokenring/olympic.c +1
-1static void __exit olympic_pci_cleanup(void) { -return pci_unregister_driver (&olympic_driver) ; +pci_unregister_driver (&olympic_driver) ; }Can we make gcc error out when it finds this?
What's wrong with it? Seriously... "return foo();" is the closest thing to a tailcall syntax as C/C++ has, and I've always considered it a Total Fscking Pain in The Ass[TM] that it somehow thinks functions returning void should have a different syntax than all other functions.
-hpa