[U-Boot] [PATCH RESEND] Fix misuse of calloc() in linux/compat.h header

Marek Vasut marex at denx.de
Sat Jun 9 01:48:40 CEST 2012


Dear Wolfgang Denk,

> Dear Marek Vasut,
> 
> In message <1339176514-13137-1-git-send-email-marex at denx.de> you wrote:
> > -#define kzalloc(size, flags)	calloc(size, 1)
> > +#define kzalloc(size, flags)	calloc(1, size)
> 
> Does this make any practical difference?
> 
> I mean, are you aware of any problem that gets fixed by this patch, or
> even any kind of performance degradation?

No, I just blindly found it out when I was enraged and was hacking on filesystem 
code.

> "common/dlmalloc.src" says:
> 
> 	calloc(size_t unit, size_t quantity);
> 	   Returns a pointer to quantity * unit bytes, with all locations
> 	   set to zero.
> 
> Multiplication being commutative, I see zero effect in this patch?

Weeeeell, not in every algebraic system. It has zero effect, it's only about 
correctness [1]. Will applying this break anything?

[1] http://pubs.opengroup.org/onlinepubs/009695399/functions/calloc.html
> Best regards,
> 
> Wolfgang Denk

Best regards,
Marek Vasut


More information about the U-Boot mailing list