mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH master 1/2] lib: jsmn: fix compilation error
@ 2024-09-11 11:13 Ahmad Fatoum
  2024-09-11 11:13 ` [PATCH master 2/2] include: stdlib.h: define prototypes for malloc/free Ahmad Fatoum
  2024-09-13  6:32 ` [PATCH master 1/2] lib: jsmn: fix compilation error Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2024-09-11 11:13 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

With recent restructuring of the headers, kmalloc_array was no longer
indirectly included, which broke the build.

Add the missing headers and while at it switch over to normal malloc,
because kmalloc_array() uses a bigger alignment than necessary.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 lib/jsmn.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/jsmn.c b/lib/jsmn.c
index 10a77886a8bd..10ef349fa122 100644
--- a/lib/jsmn.c
+++ b/lib/jsmn.c
@@ -7,6 +7,8 @@
 #include <string.h>
 #include <stdio.h>
 #include <jsmn.h>
+#include <linux/overflow.h>
+#include <malloc.h>
 
 /**
  * Allocates a fresh unused token from the token pool.
@@ -391,7 +393,7 @@ JSMN_API jsmntok_t *jsmn_parse_alloc(const char *js, const size_t len,
 
 	token_count = ret;
 
-	tokens = kmalloc_array(token_count, sizeof(jsmntok_t), GFP_KERNEL);
+	tokens = malloc(size_mul(token_count, sizeof(jsmntok_t)));
 	if (!tokens)
 		return NULL;
 
-- 
2.39.2




^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH master 2/2] include: stdlib.h: define prototypes for malloc/free
  2024-09-11 11:13 [PATCH master 1/2] lib: jsmn: fix compilation error Ahmad Fatoum
@ 2024-09-11 11:13 ` Ahmad Fatoum
  2024-09-13  6:32 ` [PATCH master 1/2] lib: jsmn: fix compilation error Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2024-09-11 11:13 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

malloc(), free() and friends are declared in <stdlib.h> for hosted
implementations. Given that we have the header in barebox too, we should
define malloc(), free() as users porting userspace code may expect it
there.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 include/stdlib.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/stdlib.h b/include/stdlib.h
index 0305970557df..c427cbc87f6e 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -3,6 +3,7 @@
 #define __STDLIB_H
 
 #include <types.h>
+#include <malloc.h>
 
 #define RAND_MAX 32767
 
-- 
2.39.2




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH master 1/2] lib: jsmn: fix compilation error
  2024-09-11 11:13 [PATCH master 1/2] lib: jsmn: fix compilation error Ahmad Fatoum
  2024-09-11 11:13 ` [PATCH master 2/2] include: stdlib.h: define prototypes for malloc/free Ahmad Fatoum
@ 2024-09-13  6:32 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2024-09-13  6:32 UTC (permalink / raw)
  To: barebox, Ahmad Fatoum


On Wed, 11 Sep 2024 13:13:17 +0200, Ahmad Fatoum wrote:
> With recent restructuring of the headers, kmalloc_array was no longer
> indirectly included, which broke the build.
> 
> Add the missing headers and while at it switch over to normal malloc,
> because kmalloc_array() uses a bigger alignment than necessary.
> 
> 
> [...]

Applied, thanks!

[1/2] lib: jsmn: fix compilation error
      https://git.pengutronix.de/cgit/barebox/commit/?id=7f29d811991a (link may not be stable)
[2/2] include: stdlib.h: define prototypes for malloc/free
      https://git.pengutronix.de/cgit/barebox/commit/?id=fa2b2b0be7ee (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-09-13  6:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-11 11:13 [PATCH master 1/2] lib: jsmn: fix compilation error Ahmad Fatoum
2024-09-11 11:13 ` [PATCH master 2/2] include: stdlib.h: define prototypes for malloc/free Ahmad Fatoum
2024-09-13  6:32 ` [PATCH master 1/2] lib: jsmn: fix compilation error Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox