include/net: Remove extern from function prototypes
Subsystems (3)
Joe Perches
maintainerRFC PATCH 1/1 include/net: Remove extern from function prototypes
Function prototypes don't need to be declared extern in .h files. It's assumed by the compiler and is as unnecessary as using auto is when declaring automatic/local variables in a block.
I ran a script to remove these unnecessary extern uses from function prototypes in include/net/ as well as reflow the function arguments to 80 cols.
It's 370KB, far too large to submit at once.
Of course it could be broken into multiple patches for the various directories/subsystems.
I believe it makes grepping for extern useful as all the matches are actual variables and structs.
Thoughts?
---
include/net/act_api.h | 60 ++-- include/net/addrconf.h | 151 +++++----- include/net/af_rxrpc.h | 35 ++- include/net/af_unix.h | 16 +- include/net/arp.h | 30 +- include/net/ax25.h | 215 +++++++------- include/net/bluetooth/bluetooth.h | 16 +- include/net/bluetooth/hci_core.h | 20 +- include/net/bluetooth/rfcomm.h | 4 +- include/net/caif/caif_hsi.h | 2 +- include/net/cfg80211.h | 34 +-- include/net/checksum.h | 10 +- include/net/cls_cgroup.h | 2 +- include/net/compat.h | 48 ++-- include/net/dcbevent.h | 6 +- include/net/dn.h | 20 +- include/net/dn_dev.h | 30 +- include/net/dn_fib.h | 46 ++- include/net/dn_neigh.h | 12 +- include/net/dn_nsp.h | 49 ++-- include/net/dn_route.h | 13 +- include/net/dst.h | 22 +- include/net/esp.h | 2 +- include/net/fib_rules.h | 19 +- include/net/flow.h | 10 +- include/net/flow_keys.h | 2 +- include/net/garp.h | 28 +- include/net/gen_stats.h | 52 ++-- include/net/genetlink.h | 20 +- include/net/icmp.h | 10 +- include/net/inet6_connection_sock.h | 33 ++- include/net/inet6_hashtables.h | 40 +-- include/net/inet_common.h | 38 +-- include/net/inet_connection_sock.h | 80 +++--- include/net/inet_hashtables.h | 70 ++--- include/net/inet_sock.h | 4 +- include/net/inet_timewait_sock.h | 38 +-- include/net/inetpeer.h | 10 +- include/net/ip.h | 141 ++++----- include/net/ip6_fib.h | 50 ++-- include/net/ip6_route.h | 93 +++--- include/net/ip_fib.h | 58 ++-- include/net/ip_vs.h | 212 +++++++------- include/net/ipv6.h | 277 +++++++++--------- include/net/ipx.h | 12 +- include/net/irda/ircomm_tty.h | 14 +- include/net/irda/irda.h | 22 +- include/net/irda/irlap_event.h | 2 +- include/net/irda/irlap_frame.h | 4 +- include/net/iw_handler.h | 38 +-- include/net/lapb.h | 52 ++-- include/net/llc.h | 50 ++-- include/net/llc_c_ac.h | 190 ++++++------- include/net/llc_c_ev.h | 240 ++++++++-------- include/net/llc_conn.h | 38 +-- include/net/llc_if.h | 8 +- include/net/llc_pdu.h | 30 +- include/net/llc_s_ac.h | 20 +- include/net/llc_s_ev.h | 20 +- include/net/llc_sap.h | 26 +- include/net/mac80211.h | 10 +- include/net/mrp.h | 28 +- include/net/ndisc.h | 56 ++-- include/net/neighbour.h | 98 ++++--- include/net/net_namespace.h | 26 +- include/net/netevent.h | 6 +- include/net/netfilter/ipv4/nf_conntrack_ipv4.h | 6 +- include/net/netfilter/ipv4/nf_defrag_ipv4.h | 2 +- include/net/netfilter/ipv6/nf_defrag_ipv6.h | 10 +- include/net/netfilter/nf_conntrack.h | 56 ++-- include/net/netfilter/nf_conntrack_acct.h | 8 +- include/net/netfilter/nf_conntrack_core.h | 32 +-- include/net/netfilter/nf_conntrack_ecache.h | 25 +- include/net/netfilter/nf_conntrack_extend.h | 2 +- include/net/netfilter/nf_conntrack_helper.h | 32 ++- include/net/netfilter/nf_conntrack_l3proto.h | 16 +- include/net/netfilter/nf_conntrack_l4proto.h | 24 +- include/net/netfilter/nf_conntrack_timeout.h | 8 +- include/net/netfilter/nf_conntrack_timestamp.h | 8 +- include/net/netfilter/nf_nat.h | 10 +- include/net/netfilter/nf_nat_core.h | 10 +- include/net/netfilter/nf_nat_helper.h | 62 ++-- include/net/netfilter/nf_nat_l3proto.h | 26 +- include/net/netfilter/nf_nat_l4proto.h | 31 +- include/net/netfilter/nf_queue.h | 2 +- include/net/netfilter/xt_rateest.h | 4 +- include/net/netlink.h | 64 ++--- include/net/netprio_cgroup.h | 2 +- include/net/netrom.h | 90 +++--- include/net/p8022.h | 6 +- include/net/ping.h | 9 - include/net/pkt_cls.h | 36 +-- include/net/pkt_sched.h | 40 +-- include/net/protocol.h | 24 +- include/net/psnap.h | 2 +- include/net/raw.h | 6 +- include/net/rawv6.h | 4 +- include/net/request_sock.h | 12 +- include/net/rose.h | 113 ++++---- include/net/route.h | 46 +-- include/net/rtnetlink.h | 40 +-- include/net/sch_generic.h | 51 ++-- include/net/scm.h | 10 +- include/net/sctp/sctp.h | 14 +- include/net/secure_seq.h | 26 +- include/net/snmp.h | 2 +- include/net/sock.h | 240 ++++++++-------- include/net/stp.h | 4 +- include/net/tcp.h | 380 ++++++++++++------------- include/net/udp.h | 88 +++--- include/net/udplite.h | 4 +- include/net/wext.h | 16 +- include/net/wimax.h | 32 +-- include/net/x25.h | 141 ++++----- include/net/xfrm.h | 334 +++++++++++----------- 115 files changed, 2636 insertions(+), 2692 deletions(-)
Quoted 5 lines · Joe Perches
Function prototypes don't need to be declared extern in .h files. It's assumed by the compiler and is as unnecessary as using auto is when declaring automatic/local variables in a block.
Since we all know this, why bother it? Having "extern" doesn't harm readability, instead it probably helps.
...
Quoted 4 lines
I believe it makes grepping for extern useful as all the matches are actual variables and structs.
You need a semantic tool.
Joe Perches
maintainerQuoted 1 line · Cong Wang
On Tue, 23 Jul 2013 at 17:58 GMT, Joe Perches <[email protected]> wrote:
You dropped the author from the cc list.
Always reply to the author.
Quoted 6 lines
Quoted 5 lines
Function prototypes don't need to be declared extern in .h files. It's assumed by the compiler and is as unnecessary as using auto is when declaring automatic/local variables in a block.
Since we all know this, why bother it?
If everyone knew this, new ones wouldn't be added. But a lot are.
Removing extern makes prototypes shorter and more readable. More prototypes fit in a single line
More arguments fit on a multi-line prototypes.
Quoted 2 lines
Having "extern" doesn't harm
readability, instead it probably helps.
Sure, just like auto does. Why isn't that used?
Quoted 3 lines
Quoted 2 lines
I believe it makes grepping for extern useful as all the matches are actual variables and structs.
You need a semantic tool.
No, not really. I'm fairly comfortable with spatch. spatch takes a long time to run for a lot of things.
Quoted 11 lines · Joe Perches
Quoted 1 line · Cong Wang
On Tue, 23 Jul 2013 at 17:58 GMT, Joe Perches <[email protected]> wrote:
You dropped the author from the cc list.
Always reply to the author.Quoted 5 lines
Quoted 5 lines
Function prototypes don't need to be declared extern in .h files. It's assumed by the compiler and is as unnecessary as using auto is when declaring automatic/local variables in a block.
Quoted 4 lines
Quoted 1 line
Since we all know this, why bother it?
If everyone knew this, new ones wouldn't be added. But a lot are.
Couldn't checkpatch take care of these?
Greetings,
Hannes
Joe Perches
maintainerPATCH 1/1 checkpatch: Warn when using extern with function prototypes in .h files
Using the extern keyword on function prototypes is superfluous visual noise so suggest removing it.
Using extern can cause unnecessary line wrapping at 80 columns and unnecessarily long multi-line function prototypes.
---
Quoted 11 lines · Hannes Frederic Sowa
Quoted 9 lines · Joe Perches
Quoted 6 lines · Cong Wang
Quoted 4 lines · Joe Perches
Function prototypes don't need to be declared extern in .h files. It's assumed by the compiler and is as unnecessary as using auto is when declaring automatic/local variables in a block.
Since we all know this, why bother it?
If everyone knew this, new ones wouldn't be added. But a lot are.
Couldn't checkpatch take care of these?
checkpatch doesn't work well for multiple lines so this doesn't work on things like
extern unsigned long foo(type bar);
but it does for the single line function prototypes.
Using --fix removes them.
scripts/checkpatch.pl | 10 ++++++++++ 1 file changed, 10 insertions(+)
scripts/checkpatch.pl +10 -0
@@ -3866,6 +3866,16 @@ sub process { } } +# check for new externs in .h files. + if ($realfile =~ /\.h$/ && + $line =~ /^\+\s*(extern\s+)$Type\s*$Ident\s*\(/s) { + if (WARN("AVOID_EXTERNS", + "extern prototypes should be avoided in .h files\n" . $herecurr) && + $fix) { + $fixed[$linenr - 1] =~ s/(.*)\bextern\b\s*(.*)/$1$2/; + } + } + # check for new externs in .c files. if ($realfile =~ /\.c$/ && defined $stat && $stat =~ /^.\s*(?:extern\s+)?$Type\s+($Ident)(\s*)\(/s)
Signature · 1 line
1.8.1.2.459.gbcd45b4.dirty
David Howells
NAKRe: [PATCH] checkpatch: Warn when using extern with function prototypes in .h files
Quoted 8 lines · Joe Perches
Using the extern keyword on function prototypes is superfluous visual noise so suggest removing it.
Using extern can cause unnecessary line wrapping at 80 columns and unnecessarily long multi-line function prototypes.
Suggested-by Hannes Frederic Sowa <[email protected]>Signed-off-by Joe Perches <[email protected]>
Nak.
The "extern" makes it much easier to pick out at a glance.
Please standardise on there _being_ externs if you must do this.
It's gratuitous change anyway and not worth the churn.
David
Re: [PATCH] checkpatch: Warn when using extern with function prototypes in .h files
Quoted 8 lines · David Howells
Quoted 6 lines · Joe Perches
Using the extern keyword on function prototypes is superfluous visual noise so suggest removing it.
Using extern can cause unnecessary line wrapping at 80 columns and unnecessarily long multi-line function prototypes.
Quoted 6 lines
Quoted 2 lines
Suggested-by Hannes Frederic Sowa <[email protected]>Signed-off-by Joe Perches <[email protected]>Nak.
The "extern" makes it much easier to pick out at a glance.
Really? Grouping function prototypes within the header file is much more helpful for spotting them.
Regards,
Arend
Quoted 11 lines
Please standardise on there _being_ externs if you must do this.
It's gratuitous change anyway and not worth the churn.
David
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
David Miller
maintainerFrom: Joe Perches <[email protected]>
Date: Tue, 23 Jul 2013 10:58:11 -0700
Quoted 5 lines
Function prototypes don't need to be declared extern in .h files. It's assumed by the compiler and is as unnecessary as using auto is when declaring automatic/local variables in a block.
Quoted 8 lines
I ran a script to remove these unnecessary extern uses from function prototypes in
include/net/as well as reflow the function arguments to 80 cols.It's 370KB, far too large to submit at once.
Of course it could be broken into multiple patches for the various directories/subsystems.
No objections from me.
Please submit a small number at a time so that my already overflowing backlog isn't overwhelmed even more.
Thanks.
Hi Joe,
Quoted 13 lines · On Tue, 30 Jul 2013 00:10:01 -0700 (PDT) David Miller <[email protected]>…
From: Joe Perches <[email protected]>
Date: Tue, 23 Jul 2013 10:58:11 -0700Quoted 9 lines
Function prototypes don't need to be declared extern in .h files. It's assumed by the compiler and is as unnecessary as using auto is when declaring automatic/local variables in a block.
I ran a script to remove these unnecessary extern uses from function prototypes in
include/net/as well as reflow the function arguments to 80 cols.
Quoted 6 lines
Quoted 4 lines
It's 370KB, far too large to submit at once.
Of course it could be broken into multiple patches for the various directories/subsystems.
No objections from me.
I must admit I prefer the other way (i.e. with the explicit extern). If nothing else it makes it consistent with variable declarations in header files (which need the extern) and "static inlines" ...
Making these churn changes also will almost certainly cause unnecessary conflicts :-(
Signature · 2 lines
Cheers, Stephen Rothwell [email protected]
David Miller
maintainerFrom: Stephen Rothwell <[email protected]>
Date: Tue, 30 Jul 2013 17:38:00 +1000
Quoted 6 lines
I must admit I prefer the other way (i.e. with the explicit extern). If nothing else it makes it consistent with variable declarations in header files (which need the extern) and "static inlines" ...
Making these churn changes also will almost certainly cause unnecessary conflicts :-(
Regardless of preferences, the whole tree is a mix, and we should choose one way or the other consistently.
It seems like new code in other major subsystems are using the no-extern scheme, and I'm more than happy to follow suit.