public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Question on coding style in networking code
@ 2001-08-19 16:44 chuckw
  2001-08-20  4:56 ` Alexander Viro
  0 siblings, 1 reply; 4+ messages in thread
From: chuckw @ 2001-08-19 16:44 UTC (permalink / raw)
  To: linux-kernel

Hello All,
	First off, this is probably a straight C question, but here goes...

	I was looking at the kernel code, and in protocol.c the protocol structures are
instansiated and filled.  Now, I have seen/used the following syntax:
	struct x y = { x, y, z };
	
I have not seen the following:
	struct x y = {
		member1: x,
		member2: y,
		member3: z
	};

What is the deal with this?  Does the second way have any advantage over the previous?

Thanks in advance,
Chuck
		

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

* Re: Question on coding style in networking code
  2001-08-20  4:56 ` Alexander Viro
@ 2001-08-19 17:11   ` chuckw
  2001-08-20 15:51     ` george anzinger
  0 siblings, 1 reply; 4+ messages in thread
From: chuckw @ 2001-08-19 17:11 UTC (permalink / raw)
  To: linux-kernel

	Thank you for the reply.

	I absolutely agree that it is much easier to read and figure out what is
going on.  You don't have to keep going back to the struct declaration to
find out what the fields are.  

Thanks again,
Chuck

On Mon, Aug 20, 2001 at 12:56:53AM -0400, Alexander Viro wrote:
> 
> 
> On Sun, 19 Aug 2001 chuckw@ieee.org wrote:
> 
> > 	struct x y = {
> > 		member1: x,
> > 		member2: y,
> > 		member3: z
> > 	};
> > 
> > What is the deal with this?  Does the second way have any advantage over the previous?
> 
> _Much_ easier to grep for. Less pain in the ass when fields are added/removed/
> reordered.
> 
> For anything with many fields (usually method tables) it's more convenient.
> And no, it's not just networking - filesystem-related code, etc. uses it
> all over the place.
> 
> -
> 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] 4+ messages in thread

* Re: Question on coding style in networking code
  2001-08-19 16:44 Question on coding style in networking code chuckw
@ 2001-08-20  4:56 ` Alexander Viro
  2001-08-19 17:11   ` chuckw
  0 siblings, 1 reply; 4+ messages in thread
From: Alexander Viro @ 2001-08-20  4:56 UTC (permalink / raw)
  To: chuckw; +Cc: linux-kernel



On Sun, 19 Aug 2001 chuckw@ieee.org wrote:

> 	struct x y = {
> 		member1: x,
> 		member2: y,
> 		member3: z
> 	};
> 
> What is the deal with this?  Does the second way have any advantage over the previous?

_Much_ easier to grep for. Less pain in the ass when fields are added/removed/
reordered.

For anything with many fields (usually method tables) it's more convenient.
And no, it's not just networking - filesystem-related code, etc. uses it
all over the place.


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

* Re: Question on coding style in networking code
  2001-08-19 17:11   ` chuckw
@ 2001-08-20 15:51     ` george anzinger
  0 siblings, 0 replies; 4+ messages in thread
From: george anzinger @ 2001-08-20 15:51 UTC (permalink / raw)
  To: chuckw; +Cc: linux-kernel

chuckw@ieee.org wrote:
> 
>         Thank you for the reply.
> 
>         I absolutely agree that it is much easier to read and figure out what is
> going on.  You don't have to keep going back to the struct declaration to
> find out what the fields are.
> 
> Thanks again,
> Chuck
> 
> On Mon, Aug 20, 2001 at 12:56:53AM -0400, Alexander Viro wrote:
> >
> >
> > On Sun, 19 Aug 2001 chuckw@ieee.org wrote:
> >
> > >     struct x y = {
> > >             member1: x,
> > >             member2: y,
> > >             member3: z
> > >     };
> > >
> > > What is the deal with this?  Does the second way have any advantage over the previous?
> >
> > _Much_ easier to grep for. Less pain in the ass when fields are added/removed/
> > reordered.
> >
> > For anything with many fields (usually method tables) it's more convenient.
> > And no, it's not just networking - filesystem-related code, etc. uses it
> > all over the place.
> >
For large structures it is a pure joy to work with.  Check out sched.h
and the "task_struct" where many of the fields come and go with "CONFIG"
options.

George

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

end of thread, other threads:[~2001-08-20 15:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-08-19 16:44 Question on coding style in networking code chuckw
2001-08-20  4:56 ` Alexander Viro
2001-08-19 17:11   ` chuckw
2001-08-20 15:51     ` george anzinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox