Conversation
|
This should be merged. Master branch failed to compile with gcc 15.2.1 and these changes fixed all issues on my machine |
A signal handler is required to have a signum parameter that is an integer. This patch is used by buildroot for GCC 15.x compatibility: https://gitlab.com/buildroot.org/buildroot/-/commit/6fd3e498af1bf837f3318eb0d47f27ac6901e7dc Signed-off-by: Charlie Jenkins <charlie@rivosinc.com> Signed-off-by: Bernd Kuhls <bernd@kuhls.net>
GCC-15 requires function declarations to be properly typed. This patch is used by buildroot for GCC 15.x compatibility: https://gitlab.com/buildroot.org/buildroot/-/commit/6fd3e498af1bf837f3318eb0d47f27ac6901e7dc Signed-off-by: Charlie Jenkins <charlie@rivosinc.com> Signed-off-by: Bernd Kuhls <bernd@kuhls.net>
lat_sig.c:42:31: error: assignment to '__sighandler_t' {aka 'void (*)(int)'} from incompatible pointer type 'void (*)(void)' [-Wincompatible-pointer-types]
42 | sa.sa_handler = handler;
| ^
lat_sig.c:23:9: note: 'handler' declared here
23 | void handler() { }
lat_sig.c:95:23: error: assignment to '__sighandler_t' {aka 'void (*)(int)'} from incompatible pointer type 'void (*)(void)' [-Wincompatible-pointer-types]
95 | sa.sa_handler = prot;
| ^
lat_sig.c:72:1: note: 'prot' declared here
72 | prot() {
Signed-off-by: Bernd Kuhls <bernd@kuhls.net>
memsize.c:167:23: error: assignment to '__sighandler_t' {aka 'void (*)(int)'} from incompatible pointer type 'void (*)(void)' [-Wincompatible-pointer-types]
167 | sa.sa_handler = gotalarm;
| ^
memsize.c:154:1: note: 'gotalarm' declared here
154 | gotalarm()
Signed-off-by: Bernd Kuhls <bernd@kuhls.net>
lat_unix.c:85:17: error: too many arguments to function 'exit'; expected 0, have 1
85 | exit(1);
| ^~~~ ~
lat_unix.c:74:17: note: declared here
74 | void exit();
Signed-off-by: Bernd Kuhls <bernd@kuhls.net>
lat_usleep.c:125:19: error: assignment to '__sighandler_t' {aka 'void (*)(int)'} from incompatible pointer type 'void (*)(void)' [-Wincompatible-pointer-types]
125 | sa.sa_handler = interval;
| ^
lat_usleep.c:102:1: note: 'interval' declared here
102 | interval()
Signed-off-by: Bernd Kuhls <bernd@kuhls.net>
There was a problem hiding this comment.
Pull request overview
This PR updates several C sources to use modern (prototype) function declarations and correct signal-handler signatures, addressing GCC 15.x strictness around old-style K&R declarations and incompatible function pointer types.
Changes:
- Updated multiple signal handlers and callbacks to accept an
intparameter (as required bysignal(2)/sigaction(2)handlers). - Replaced K&R-style function definitions/prototypes with ANSI C prototypes (notably in
lat_rpc.candlmdd.c). - Tightened RPC-related function pointer and XDR prototype declarations to reduce compiler diagnostics.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/memsize.c | Updates SIGALRM handler signature used with sigaction(). |
| src/lmhttp.c | Updates die() prototype/definition to match signal-handler signature. |
| src/lmdd.c | Adds prototypes for getarg, chkarg, and updates done() to accept a signal number; updates call sites accordingly. |
| src/lat_usleep.c | Updates SIGALRM handler signature used with sigaction(). |
| src/lat_unix.c | Updates local exit prototype to match signal() handler signature. |
| src/lat_udp.c | Updates SIGALRM handler signature used with signal(). |
| src/lat_sig.c | Updates handler signatures to accept a signal number. |
| src/lat_rpc.c | Converts K&R-style RPC dispatch/service routines to prototype form and adjusts function pointer typing/casts. |
| src/bench.h | Updates exported RPC function prototypes to ANSI style. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| bool_t (*xdr_argument)(XDR *, char *), (*xdr_result)(XDR *, char *); | ||
| char *(*local)(char *, struct svc_req *); | ||
|
|
There was a problem hiding this comment.
rpc_xact_1 is declared/defined as char *rpc_xact_1(char *msg, SVCXPRT *transp), but local is typed as taking (char *, struct svc_req *). This forces an incompatible function-pointer cast later and makes the subsequent indirect call undefined behavior. Make the local function pointer type and call site match the actual server procedure signature (either change local to take SVCXPRT * and pass transp, or change rpc_xact_1 to take struct svc_req * and update its prototype accordingly).
| result = (*local)((char *)&argument, rqstp); | ||
| if (result != NULL && !svc_sendreply(transp, (xdrproc_t)xdr_result, result)) { |
There was a problem hiding this comment.
This indirect call passes rqstp as the second argument to local, but the service routine you assign (rpc_xact_1) is declared with a second parameter of type SVCXPRT *. Even if it “works” because the parameter is unused, it’s still undefined behavior. Align the parameter types and pass the correct argument (transp if keeping the current rpc_xact_1 signature).
| struct _state* pState = (struct _state*)cookie; | ||
| void exit(); | ||
| void exit(int); | ||
|
|
There was a problem hiding this comment.
Declaring exit locally is redundant (it’s already declared via <stdlib.h> through bench.h) and using exit directly as a signal() handler is not async-signal-safe. Prefer a dedicated static void on_sigterm(int signo) handler that calls _exit() (or sets a flag) and register that instead; then drop this local prototype.
|
|
||
| void die() | ||
| void die(int signum) | ||
| { |
There was a problem hiding this comment.
die(int signum) doesn’t use signum, which will trigger -Wunused-parameter under common warning settings (e.g., the Makefile’s -Wall build). Either omit the parameter name (die(int)) or explicitly mark it unused (e.g., (void)signum;).
| { | |
| { | |
| (void)signum; |
| void | ||
| done(void) | ||
| done(int signum) | ||
| { |
There was a problem hiding this comment.
done(int signum) doesn’t use signum, which can introduce -Wunused-parameter warnings in -Wall builds. Either remove the parameter name (done(int)) or mark it unused inside the function.
| { | |
| { | |
| (void)signum; |
| void | ||
| timeout() | ||
| timeout(int signum) | ||
| { |
There was a problem hiding this comment.
timeout(int signum) doesn’t use signum, which can cause -Wunused-parameter warnings in -Wall builds. Consider changing the signature to timeout(int) or explicitly marking the parameter unused.
| { | |
| { | |
| (void)signum; |
|
@bkuhls thanks for the patch, would you mind do a check for the comments from copilot? |
No description provided.