[Libvir] begin conversion to safer use of sizeof: exposes a harmless bug

Jim Meyering jim at meyering.net
Wed Dec 12 07:24:43 UTC 2007


"Daniel P. Berrange" <berrange at redhat.com> wrote:
> On Tue, Dec 11, 2007 at 07:57:51PM +0100, Jim Meyering wrote:
>> Subject: [PATCH] Use a variable name as sizeof argument, not a type name.
>>
>> Given code like: T *var = calloc (n, sizeof (T));
>> Convert to this: T *var = calloc (n, sizeof (*var));
>> This first-cut change adjusts all malloc, calloc, and
>> realloc statements.
...
> ACK.

Thanks.
Committed.

> Should we add a 'HACKING' file which mentions this coding standard and any of
> the others we generally have for the benefit of anyone submitting patches
> in the future

Yes.  I'll propose one along with a separate Makefile rule
to check for this sort of policy.




More information about the libvir-list mailing list