Skip to content

Various fixes for gcc 15.x#43

Open
bkuhls wants to merge 6 commits intointel:masterfrom
bkuhls:fixgcc
Open

Various fixes for gcc 15.x#43
bkuhls wants to merge 6 commits intointel:masterfrom
bkuhls:fixgcc

Conversation

@bkuhls
Copy link
Copy Markdown
Contributor

@bkuhls bkuhls commented Dec 5, 2025

No description provided.

@GitBisho
Copy link
Copy Markdown

GitBisho commented Dec 31, 2025

This should be merged. Master branch failed to compile with gcc 15.2.1 and these changes fixed all issues on my machine

charlie-rivos and others added 6 commits April 8, 2026 12:16
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>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 int parameter (as required by signal(2)/sigaction(2) handlers).
  • Replaced K&R-style function definitions/prototypes with ANSI C prototypes (notably in lat_rpc.c and lmdd.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.

Comment on lines +244 to 246
bool_t (*xdr_argument)(XDR *, char *), (*xdr_result)(XDR *, char *);
char *(*local)(char *, struct svc_req *);

Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copilot uses AI. Check for mistakes.
Comment on lines +272 to 273
result = (*local)((char *)&argument, rqstp);
if (result != NULL && !svc_sendreply(transp, (xdrproc_t)xdr_result, result)) {
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copilot uses AI. Check for mistakes.
Comment on lines 73 to 75
struct _state* pState = (struct _state*)cookie;
void exit();
void exit(int);

Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.

void die()
void die(int signum)
{
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;).

Suggested change
{
{
(void)signum;

Copilot uses AI. Check for mistakes.
void
done(void)
done(int signum)
{
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
{
{
(void)signum;

Copilot uses AI. Check for mistakes.
void
timeout()
timeout(int signum)
{
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
{
{
(void)signum;

Copilot uses AI. Check for mistakes.
@rli9
Copy link
Copy Markdown
Contributor

rli9 commented Apr 8, 2026

@bkuhls thanks for the patch, would you mind do a check for the comments from copilot?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants