Re: [PATCH 1/2] iWARP Connection Manager.
- From: Roland Dreier <rdreier@xxxxxxxxx>
- Date: Wed, 31 May 2006 14:54:22 -0700
This is a silly thing to argue about, but...
The preferred form for passing a size of a struct is the following:
p = kmalloc(sizeof(*p), ...);
The alternative form where struct name is spelled out hurts readability and
introduces an opportunity for a bug when the pointer variable type is changed
but the corresponding sizeof that is passed to a memory allocator is not.
I would argue that this is talking about sizeof(*p) vs. sizeof (struct foo)
rather than sizeof(*p) vs. sizeof *p.
You wouldn't write:
return(*p);
but rather
return *p;
And sizeof is an operator not a function, so I think the same usage
would apply.
With that said the prevalent kernel usage does seem to be sizeof(*foo)
(by about 10 to 1). But I can't help feeling it looks silly.
- R.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
- References:
- [PATCH 0/2][RFC] iWARP Core Support
- From: Steve Wise
- [PATCH 1/2] iWARP Connection Manager.
- From: Steve Wise
- Re: [PATCH 1/2] iWARP Connection Manager.
- From: Stephen Hemminger
- Re: [PATCH 1/2] iWARP Connection Manager.
- From: Roland Dreier
- Re: [PATCH 1/2] iWARP Connection Manager.
- From: Steve Wise
- Re: [PATCH 1/2] iWARP Connection Manager.
- From: Stephen Hemminger
- [PATCH 0/2][RFC] iWARP Core Support
- Prev by Date: Re: Adaptive Readahead V14 - statistics question...
- Next by Date: Re: 2.6.17-rc5-mm1
- Previous by thread: Re: [PATCH 1/2] iWARP Connection Manager.
- Next by thread: Re: [PATCH 1/2] iWARP Connection Manager.
- Index(es):
Relevant Pages
|