Hi,
On Wed, Apr 13 2011, John Calixto wrote:
> Out of curiosity, why is:
>
> memset(&cmd, 0, sizeof(struct mmc_command));
>
> preferred over:
>
> struct mmc_command cmd = {0};
Thanks for the question. I asked around, the verdict seems to be that
it *isn't* preferred, that the compiler can actually (theoretically)
do better with the zero initializer, and the memsets are probably
just holdover from when dynamic initialization of aggregates wasn't
available in C.
An even stronger benefit of the zero initializer is, of course, that
you can do a single-line grep to find out whether someone forgot to
initialize any of them. (And it's a line shorter, too.)
So, now I'm thinking about a patch to convert all of our uses of
memset(.., 0, struct ..) over to { 0 } initializers. Yell if
anyone has strong opinions.
Thanks,
- Chris.
--
Chris Ball <[email protected]> <http://printf.net/>
One Laptop Per Child
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html