Re: style(5) proposal: forbid extern in .c

2023-03-28 Thread Jason Thorpe
> On Mar 28, 2023, at 5:53 PM, Roland Illig wrote: > > Am 15.03.2023 um 16:40 schrieb Jason Thorpe: >> >>> On Mar 15, 2023, at 4:23 AM, Taylor R Campbell >>> wrote: >>> >>> Proposal: Forbid extern declarations in .c files. >>> >>> extern declarations in .c files invite easily avoided

Re: style(5) proposal: forbid extern in .c

2023-03-28 Thread Roland Illig
Am 15.03.2023 um 16:40 schrieb Jason Thorpe: On Mar 15, 2023, at 4:23 AM, Taylor R Campbell wrote: Proposal: Forbid extern declarations in .c files. extern declarations in .c files invite easily avoided bugs where the definition and use have mismatched types, because the compiler doesn't

Re: style(5) proposal: forbid extern in .c

2023-03-18 Thread Mouse
>>> extern struct netif_stats le_stats[]; >>> ... >>> struct netif_stats le_stats[NLE_IFS]; >> [riastradh@ and I say to s/extern/static/ and add static to the >> later declaration, if le_stats can be file-local] > Thanks, using 'static' as a forward declaration just works. I may be misreading

Re: style(5) proposal: forbid extern in .c

2023-03-18 Thread Izumi Tsutsui
> > extern struct netif_stats le_stats[]; > > > > static struct netif_dif le_ifs[] = { > > /* dif_unitdif_nseldif_stats dif_private */ > > { 0, NLE0CONF, _stats[0], le0conf,}, > > }; > > #define NLE_IFS (sizeof(le_ifs) /

Re: style(5) proposal: forbid extern in .c

2023-03-16 Thread Roland Illig
It should be easy to add this check to lint by adding a new message. There are several recent commits that add a message to lint1/err.c. Whoever wants to add this check, feel free to do so. For external code and a few other files, the newly added message will need to be excluded by

Re: style(5) proposal: forbid extern in .c

2023-03-15 Thread Robert Elz
Date:Thu, 16 Mar 2023 05:21:47 +1100 From:matthew green Message-ID: <6173.1678904...@splode.eterna.com.au> | doing this should never be more than a quick hack | and not in the commited treed. It probably also needs to exclude machine generated code, eg: yacc

re: style(5) proposal: forbid extern in .c

2023-03-15 Thread matthew green
> Pretty simple. Any objections? yes please. doing this should never be more than a quick hack and not in the commited treed. thanks. .mrg.

Re: style(5) proposal: forbid extern in .c

2023-03-15 Thread Valery Ushakov
On Wed, Mar 15, 2023 at 11:23:05 +, Taylor R Campbell wrote: > Proposal: Forbid extern declarations in .c files. > > extern declarations in .c files invite easily avoided bugs where the > definition and use have mismatched types, because the compiler doesn't > have an opportunity to check

Re: style(5) proposal: forbid extern in .c

2023-03-15 Thread Mouse
> [...] I wonder how we can resolve this case: > extern struct netif_stats le_stats[]; > > static struct netif_dif le_ifs[] = { > /*dif_unitdif_nseldif_stats dif_private */ > { 0, NLE0CONF, _stats[0], le0conf,}, > }; > #define

Re: style(5) proposal: forbid extern in .c

2023-03-15 Thread Taylor R Campbell
> Date: Thu, 16 Mar 2023 01:58:48 +0900 > From: Izumi Tsutsui > > > Proposal: Forbid extern declarations in .c files. > : > > Pretty simple. Any objections? > > No objection, but I wonder how we can resolve this case: > >

Re: style(5) proposal: forbid extern in .c

2023-03-15 Thread Izumi Tsutsui
> Proposal: Forbid extern declarations in .c files. : > Pretty simple. Any objections? No objection, but I wonder how we can resolve this case: https://nxr.netbsd.org/xref/src/sys/arch/hp300/stand/common/if_le.c?r=1.14#101 --- extern struct netif_stats le_stats[]; static struct

Re: style(5) proposal: forbid extern in .c

2023-03-15 Thread Manuel Bouyer
On Wed, Mar 15, 2023 at 11:23:05AM +, Taylor R Campbell wrote: > Proposal: Forbid extern declarations in .c files. > > extern declarations in .c files invite easily avoided bugs where the > definition and use have mismatched types, because the compiler doesn't > have an opportunity to check

Re: style(5) proposal: forbid extern in .c

2023-03-15 Thread Paul Goyette
On Wed, 15 Mar 2023, Taylor R Campbell wrote: Proposal: Forbid extern declarations in .c files. extern declarations in .c files invite easily avoided bugs where the definition and use have mismatched types, because the compiler doesn't have an opportunity to check them. Fix: Always put the

Re: style(5) proposal: forbid extern in .c

2023-03-15 Thread Jason Thorpe
> On Mar 15, 2023, at 4:23 AM, Taylor R Campbell > wrote: > > Proposal: Forbid extern declarations in .c files. > > extern declarations in .c files invite easily avoided bugs where the > definition and use have mismatched types, because the compiler doesn't > have an opportunity to check

style(5) proposal: forbid extern in .c

2023-03-15 Thread Taylor R Campbell
Proposal: Forbid extern declarations in .c files. extern declarations in .c files invite easily avoided bugs where the definition and use have mismatched types, because the compiler doesn't have an opportunity to check them. Fix: Always put the extern declaration in a .h file shared by the .c