[PATCH] fixup! commands: add new bthread test command

Ahmad Fatoum ahmad at a3f.at
Tue Mar 16 08:20:34 GMT 2021


GCC whines about casting int to pointer, which aren't always the same
size in barebox. Use long instead to avoid the warning.

Signed-off-by: Ahmad Fatoum <ahmad at a3f.at>
---
 commands/bthread.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/commands/bthread.c b/commands/bthread.c
index 05dfa68cc597..964a1044c58b 100644
--- a/commands/bthread.c
+++ b/commands/bthread.c
@@ -66,15 +66,15 @@ static int bthread_isolated_time(void)
 static int bthread_printer(void *arg)
 {
 	volatile u64 start;
-	volatile int i = 0;
+	volatile unsigned long i = 0;
 	start = get_time_ns();
 
 	while (!bthread_should_stop()) {
 		if (!is_timeout_non_interruptible(start, 225 * MSECOND))
 			continue;
 
-		if ((long)arg == i++)
-			printf("%s yield #%d\n", bthread_name(current), i);
+		if ((unsigned long)arg == i++)
+			printf("%s yield #%lu\n", bthread_name(current), i);
 		start = get_time_ns();
 	}
 
@@ -87,14 +87,14 @@ static int bthread_spawner(void *arg)
 {
 	struct bthread *bthread[4];
 	volatile u64 start;
-	volatile int i = 0;
+	volatile unsigned long i = 0;
 	int ret = 0;
 	int ecode;
 
 	start = get_time_ns();
 
 	for (i = 0; i < ARRAY_SIZE(bthread); i++) {
-		bthread[i] = bthread_run(bthread_printer, (void *)i,
+		bthread[i] = bthread_run(bthread_printer, (void *)(long)i,
 					 "%s-bthread%u", bthread_name(current), i+1);
 		if (!bthread[i]) {
 			ret = -ENOMEM;
-- 
2.30.0




More information about the barebox mailing list