Re: [PATCH] MMC: Fix use of uninitialized data in mmc_cmd_app.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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   <cjb@xxxxxxxxxx>   <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 majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux