* [U-Boot] [PATCH RESEND] Fix misuse of calloc() in linux/compat.h header
@ 2012-06-08 17:28 Marek Vasut
2012-06-08 23:43 ` Wolfgang Denk
0 siblings, 1 reply; 5+ messages in thread
From: Marek Vasut @ 2012-06-08 17:28 UTC (permalink / raw)
To: u-boot
Quote from the manpage:
[...]
void *calloc(size_t nmemb, size_t size);
[...]
DESCRIPTION
[...]
The calloc() function allocates memory for an array of nmemb elements
of size bytes each and returns a pointer to the allocated memory. The
memory is set to zero. If nmemb or size is 0, then calloc() returns
either NULL, or a unique pointer value that can later be successfully
passed to free().
Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Wolfgang Denk <wd@denx.de>
---
include/linux/compat.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/compat.h b/include/linux/compat.h
index 593b07f..9a9d7b0 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -18,7 +18,7 @@
#define KERN_DEBUG
#define kmalloc(size, flags) malloc(size)
-#define kzalloc(size, flags) calloc(size, 1)
+#define kzalloc(size, flags) calloc(1, size)
#define vmalloc(size) malloc(size)
#define kfree(ptr) free(ptr)
#define vfree(ptr) free(ptr)
--
1.7.10
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH RESEND] Fix misuse of calloc() in linux/compat.h header
2012-06-08 17:28 [U-Boot] [PATCH RESEND] Fix misuse of calloc() in linux/compat.h header Marek Vasut
@ 2012-06-08 23:43 ` Wolfgang Denk
2012-06-08 23:48 ` Marek Vasut
0 siblings, 1 reply; 5+ messages in thread
From: Wolfgang Denk @ 2012-06-08 23:43 UTC (permalink / raw)
To: u-boot
Dear Marek Vasut,
In message <1339176514-13137-1-git-send-email-marex@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?
"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?
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Business is like a wheelbarrow. Nothing ever happens until you start
pushing.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH RESEND] Fix misuse of calloc() in linux/compat.h header
2012-06-08 23:43 ` Wolfgang Denk
@ 2012-06-08 23:48 ` Marek Vasut
2012-06-08 23:58 ` Wolfgang Denk
0 siblings, 1 reply; 5+ messages in thread
From: Marek Vasut @ 2012-06-08 23:48 UTC (permalink / raw)
To: u-boot
Dear Wolfgang Denk,
> Dear Marek Vasut,
>
> In message <1339176514-13137-1-git-send-email-marex@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
^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH RESEND] Fix misuse of calloc() in linux/compat.h header
2012-06-08 23:48 ` Marek Vasut
@ 2012-06-08 23:58 ` Wolfgang Denk
2012-06-09 0:04 ` Marek Vasut
0 siblings, 1 reply; 5+ messages in thread
From: Wolfgang Denk @ 2012-06-08 23:58 UTC (permalink / raw)
To: u-boot
Dear Marek Vasut,
In message <201206090148.40933.marex@denx.de> you wrote:
>
> > 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?
In which way is "a * b" more (or less?) correct than "b * a" ?
What is the difference between allocating a contiguous sequence of
4096 single bytes, or allocating a single block of size 4096?
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
The first 90% of a project takes 90% of the time, the last 10% takes
the other 90% of the time.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH RESEND] Fix misuse of calloc() in linux/compat.h header
2012-06-08 23:58 ` Wolfgang Denk
@ 2012-06-09 0:04 ` Marek Vasut
0 siblings, 0 replies; 5+ messages in thread
From: Marek Vasut @ 2012-06-09 0:04 UTC (permalink / raw)
To: u-boot
Dear Wolfgang Denk,
> Dear Marek Vasut,
>
> In message <201206090148.40933.marex@denx.de> you wrote:
> > > 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?
>
> In which way is "a * b" more (or less?) correct than "b * a" ?
In our natural integer system, it's all perfectly OK.
> What is the difference between allocating a contiguous sequence of
> 4096 single bytes, or allocating a single block of size 4096?
None.
> Best regards,
>
> Wolfgang Denk
Best regards,
Marek Vasut
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-06-09 0:04 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-08 17:28 [U-Boot] [PATCH RESEND] Fix misuse of calloc() in linux/compat.h header Marek Vasut
2012-06-08 23:43 ` Wolfgang Denk
2012-06-08 23:48 ` Marek Vasut
2012-06-08 23:58 ` Wolfgang Denk
2012-06-09 0:04 ` Marek Vasut
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox