cpulimit: fix build with gcc-15

* to fix: Error occurs in gcc 15.0.1 environment.
busy.c: In function 'main':
busy.c:20:58: error: passing argument 3 of 'pthread_create' from incompatible pointer type [-Wincompatible-pointer-types]
   20 |                 if ((ret = pthread_create(&thread, NULL, loop, NULL)) != 0)
      |                                                          ^~~~
      |                                                          |
      |                                                          void * (*)(void)
In file included from busy.c:3:
recipe-sysroot/usr/include/pthread.h:204:36: note: expected 'void * (*)(void *)' but argument is of type 'void * (*)(void)'
  204 |                            void *(*__start_routine) (void *),
      |                            ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
busy.c:6:7: note: 'loop' declared here
    6 | void *loop()
      |       ^~~~

Signed-off-by: mark.yang <mark.yang@lge.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
This commit is contained in:
mark.yang 2025-03-26 16:34:09 +09:00 committed by Khem Raj
parent 950b33eebf
commit 1de4965018
No known key found for this signature in database
GPG Key ID: BB053355919D3314
2 changed files with 52 additions and 0 deletions

View File

@ -0,0 +1,51 @@
From 86b71c49a373f78920d78c0e88f530f476b4fe70 Mon Sep 17 00:00:00 2001
From: "mark.yang" <mark.yang@lge.com>
Date: Wed, 26 Mar 2025 15:57:54 +0900
Subject: [PATCH] busy.c: Fix incompatible pointer type error.
Error occurs in gcc 15.0.1 environment.
busy.c: In function 'main':
busy.c:20:58: error: passing argument 3 of 'pthread_create' from incompatible pointer type [-Wincompatible-pointer-types]
20 | if ((ret = pthread_create(&thread, NULL, loop, NULL)) != 0)
| ^~~~
| |
| void * (*)(void)
In file included from busy.c:3:
recipe-sysroot/usr/include/pthread.h:204:36: note: expected 'void * (*)(void *)' but argument is of type 'void * (*)(void)'
204 | void *(*__start_routine) (void *),
| ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
busy.c:6:7: note: 'loop' declared here
6 | void *loop()
| ^~~~
Set loop parameter to void* since it requires void* type argument.
Signed-off-by: mark.yang <mark.yang@lge.com>
Upstream-Status: Inactive-Upstream [lastcommit: 9 Years ago and lastrelease: 9 Years ago]
---
tests/busy.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/busy.c b/tests/busy.c
index b3afb7c..2d726eb 100644
--- a/tests/busy.c
+++ b/tests/busy.c
@@ -3,7 +3,7 @@
#include <pthread.h>
#include <unistd.h>
-void *loop()
+void *loop(void *arg)
{
while(1);
}
@@ -23,7 +23,7 @@ int main(int argc, char **argv) {
exit(1);
}
}
- loop();
+ loop(NULL);
return 0;
}

View File

@ -7,6 +7,7 @@ SRCREV ?= "f4d2682804931e7aea02a869137344bb5452a3cd"
SRC_URI = "git://github.com/opsengine/cpulimit.git;protocol=https;branch=master \
file://0001-Remove-sys-sysctl.h-and-add-missing-libgen.h-include.patch \
file://0002-busy.c-Fix-incompatible-pointer-type-error.patch \
"
S = "${WORKDIR}/git"