netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH - diffstat only] include/net: Remove extern from function prototypes
@ 2013-07-23 17:58 Joe Perches
  2013-07-25  1:27 ` Cong Wang
  2013-07-30  7:10 ` [RFC PATCH - diffstat only] include/net: Remove extern from function prototypes David Miller
  0 siblings, 2 replies; 10+ messages in thread
From: Joe Perches @ 2013-07-23 17:58 UTC (permalink / raw)
  To: netdev; +Cc: LKML

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(-)

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [RFC PATCH - diffstat only] include/net: Remove extern from function prototypes
  2013-07-23 17:58 [RFC PATCH - diffstat only] include/net: Remove extern from function prototypes Joe Perches
@ 2013-07-25  1:27 ` Cong Wang
  2013-07-25  1:41   ` Joe Perches
  2013-07-30  7:10 ` [RFC PATCH - diffstat only] include/net: Remove extern from function prototypes David Miller
  1 sibling, 1 reply; 10+ messages in thread
From: Cong Wang @ 2013-07-25  1:27 UTC (permalink / raw)
  To: linux-kernel; +Cc: netdev

On Tue, 23 Jul 2013 at 17:58 GMT, Joe Perches <joe@perches.com> wrote:
> 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.

...
>
> I believe it makes grepping for extern useful as
> all the matches are actual variables and structs.
>

You need a semantic tool.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [RFC PATCH - diffstat only] include/net: Remove extern from function prototypes
  2013-07-25  1:27 ` Cong Wang
@ 2013-07-25  1:41   ` Joe Perches
  2013-07-25  1:47     ` Hannes Frederic Sowa
  0 siblings, 1 reply; 10+ messages in thread
From: Joe Perches @ 2013-07-25  1:41 UTC (permalink / raw)
  To: Cong Wang; +Cc: linux-kernel, netdev

On Thu, 2013-07-25 at 01:27 +0000, Cong Wang wrote:
> On Tue, 23 Jul 2013 at 17:58 GMT, Joe Perches <joe@perches.com> wrote:

You dropped the author from the cc list.
Always reply to the author.

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

> Having "extern" doesn't harm
> readability, instead it probably helps.

Sure, just like auto does.  Why isn't that used?

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [RFC PATCH - diffstat only] include/net: Remove extern from function prototypes
  2013-07-25  1:41   ` Joe Perches
@ 2013-07-25  1:47     ` Hannes Frederic Sowa
  2013-07-25  2:59       ` [PATCH] checkpatch: Warn when using extern with function prototypes in .h files Joe Perches
  2013-08-01 12:21       ` David Howells
  0 siblings, 2 replies; 10+ messages in thread
From: Hannes Frederic Sowa @ 2013-07-25  1:47 UTC (permalink / raw)
  To: Joe Perches; +Cc: Cong Wang, linux-kernel, netdev

On Wed, Jul 24, 2013 at 06:41:20PM -0700, Joe Perches wrote:
> On Thu, 2013-07-25 at 01:27 +0000, Cong Wang wrote:
> > On Tue, 23 Jul 2013 at 17:58 GMT, Joe Perches <joe@perches.com> wrote:
> 
> You dropped the author from the cc list.
> Always reply to the author.
> 
> > > 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?

Greetings,

  Hannes

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH] checkpatch: Warn when using extern with function prototypes in .h files
  2013-07-25  1:47     ` Hannes Frederic Sowa
@ 2013-07-25  2:59       ` Joe Perches
  2013-08-01 12:21       ` David Howells
  1 sibling, 0 replies; 10+ messages in thread
From: Joe Perches @ 2013-07-25  2:59 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Andy Whitcroft, Hannes Frederic Sowa, Cong Wang, linux-kernel, netdev

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 <hannes@stressinduktion.org>
Signed-off-by: Joe Perches <joe@perches.com>
---
On Thu, 2013-07-25 at 03:47 +0200, Hannes Frederic Sowa wrote:
> On Wed, Jul 24, 2013 at 06:41:20PM -0700, Joe Perches wrote:
> > On Thu, 2013-07-25 at 01:27 +0000, Cong Wang wrote:
> > > On Tue, 23 Jul 2013 at 17:58 GMT, Joe Perches <joe@perches.com> wrote:
> > > > 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(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 6918517..23126d4 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -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)
-- 
1.8.1.2.459.gbcd45b4.dirty

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [RFC PATCH - diffstat only] include/net: Remove extern from function prototypes
  2013-07-23 17:58 [RFC PATCH - diffstat only] include/net: Remove extern from function prototypes Joe Perches
  2013-07-25  1:27 ` Cong Wang
@ 2013-07-30  7:10 ` David Miller
  2013-07-30  7:38   ` Stephen Rothwell
  1 sibling, 1 reply; 10+ messages in thread
From: David Miller @ 2013-07-30  7:10 UTC (permalink / raw)
  To: joe; +Cc: netdev, linux-kernel

From: Joe Perches <joe@perches.com>
Date: Tue, 23 Jul 2013 10:58:11 -0700

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

No objections from me.

Please submit a small number at a time so that my already overflowing
backlog isn't overwhelmed even more.

Thanks.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [RFC PATCH - diffstat only] include/net: Remove extern from function prototypes
  2013-07-30  7:10 ` [RFC PATCH - diffstat only] include/net: Remove extern from function prototypes David Miller
@ 2013-07-30  7:38   ` Stephen Rothwell
  2013-07-30  7:49     ` David Miller
  0 siblings, 1 reply; 10+ messages in thread
From: Stephen Rothwell @ 2013-07-30  7:38 UTC (permalink / raw)
  To: Joe Perches; +Cc: David Miller, netdev, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1123 bytes --]

Hi Joe,

On Tue, 30 Jul 2013 00:10:01 -0700 (PDT) David Miller <davem@davemloft.net> wrote:
>
> From: Joe Perches <joe@perches.com>
> Date: Tue, 23 Jul 2013 10:58:11 -0700
> 
> > 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.
> 
> 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 :-(

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [RFC PATCH - diffstat only] include/net: Remove extern from function prototypes
  2013-07-30  7:38   ` Stephen Rothwell
@ 2013-07-30  7:49     ` David Miller
  0 siblings, 0 replies; 10+ messages in thread
From: David Miller @ 2013-07-30  7:49 UTC (permalink / raw)
  To: sfr; +Cc: joe, netdev, linux-kernel

From: Stephen Rothwell <sfr@canb.auug.org.au>
Date: Tue, 30 Jul 2013 17:38:00 +1000

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] checkpatch: Warn when using extern with function prototypes in .h files
  2013-07-25  1:47     ` Hannes Frederic Sowa
  2013-07-25  2:59       ` [PATCH] checkpatch: Warn when using extern with function prototypes in .h files Joe Perches
@ 2013-08-01 12:21       ` David Howells
  2013-08-01 13:00         ` Arend van Spriel
  1 sibling, 1 reply; 10+ messages in thread
From: David Howells @ 2013-08-01 12:21 UTC (permalink / raw)
  To: Joe Perches
  Cc: dhowells, Andrew Morton, Andy Whitcroft, Hannes Frederic Sowa,
	Cong Wang, linux-kernel, netdev

Joe Perches <joe@perches.com> wrote:

> 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 <hannes@stressinduktion.org>
> Signed-off-by: Joe Perches <joe@perches.com>

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] checkpatch: Warn when using extern with function prototypes in .h files
  2013-08-01 12:21       ` David Howells
@ 2013-08-01 13:00         ` Arend van Spriel
  0 siblings, 0 replies; 10+ messages in thread
From: Arend van Spriel @ 2013-08-01 13:00 UTC (permalink / raw)
  To: David Howells
  Cc: Joe Perches, Andrew Morton, Andy Whitcroft, Hannes Frederic Sowa,
	Cong Wang, linux-kernel, netdev

On 08/01/2013 02:21 PM, David Howells wrote:
> Joe Perches <joe@perches.com> wrote:
>
>> 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 <hannes@stressinduktion.org>
>> Signed-off-by: Joe Perches <joe@perches.com>
>
> 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

> 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 majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
>

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2013-08-01 13:00 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-23 17:58 [RFC PATCH - diffstat only] include/net: Remove extern from function prototypes Joe Perches
2013-07-25  1:27 ` Cong Wang
2013-07-25  1:41   ` Joe Perches
2013-07-25  1:47     ` Hannes Frederic Sowa
2013-07-25  2:59       ` [PATCH] checkpatch: Warn when using extern with function prototypes in .h files Joe Perches
2013-08-01 12:21       ` David Howells
2013-08-01 13:00         ` Arend van Spriel
2013-07-30  7:10 ` [RFC PATCH - diffstat only] include/net: Remove extern from function prototypes David Miller
2013-07-30  7:38   ` Stephen Rothwell
2013-07-30  7:49     ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).