Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/bench.h
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,8 @@ extern int handle_scheduler(int childno, int benchproc, int nbenchprocs);
#define XACT_VERS ((u_long)1)
#define RPC_XACT ((u_long)1)
#define RPC_EXIT ((u_long)2)
extern char *rpc_xact_1();
extern char *client_rpc_xact_1();
extern char *rpc_xact_1(char *msg, register SVCXPRT *transp);
extern char *client_rpc_xact_1(char *argp, CLIENT *clnt);

void lmbench_usage(int argc, char *argv[], char* usage);

Expand Down
18 changes: 7 additions & 11 deletions src/lat_rpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,16 +190,14 @@ client_rpc_xact_1(char *argp, CLIENT *clnt)
*/
/* ARGSUSED */
char *
rpc_xact_1(msg, transp)
char *msg;
register SVCXPRT *transp;
rpc_xact_1(char *msg, register SVCXPRT *transp)
{
static char r = 123;

return &r;
}

static void xact_prog_1();
static void xact_prog_1(struct svc_req *rqstp, register SVCXPRT *transp);

void
server_main()
Expand Down Expand Up @@ -237,16 +235,14 @@ server_main()
}

static void
xact_prog_1(rqstp, transp)
struct svc_req *rqstp;
register SVCXPRT *transp;
xact_prog_1(struct svc_req *rqstp, register SVCXPRT *transp)
{
union {
char rpc_xact_1_arg;
} argument;
char *result;
bool_t (*xdr_argument)(), (*xdr_result)();
char *(*local)();
bool_t (*xdr_argument)(XDR *, char *), (*xdr_result)(XDR *, char *);
char *(*local)(char *, struct svc_req *);

Comment on lines +244 to 246
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.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@charlie-rivos: This code was written by you, what do you think?

switch (rqstp->rq_proc) {
case NULLPROC:
Expand All @@ -256,7 +252,7 @@ xact_prog_1(rqstp, transp)
case RPC_XACT:
xdr_argument = xdr_char;
xdr_result = xdr_char;
local = (char *(*)()) rpc_xact_1;
local = (char *(*)(char *, struct svc_req *)) rpc_xact_1;
break;

case RPC_EXIT:
Expand All @@ -273,7 +269,7 @@ xact_prog_1(rqstp, transp)
svcerr_decode(transp);
return;
}
result = (*local)(&argument, rqstp);
result = (*local)((char *)&argument, rqstp);
if (result != NULL && !svc_sendreply(transp, (xdrproc_t)xdr_result, result)) {
Comment on lines +272 to 273
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.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@charlie-rivos: This code was written by you, what do you think?

svcerr_systemerr(transp);
}
Expand Down
4 changes: 2 additions & 2 deletions src/lat_sig.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ char *id = "$Id$\n";

uint64 caught, n;
double adj;
void handler() { }
void handler(int) { }
jmp_buf prot_env;

void
Expand Down Expand Up @@ -69,7 +69,7 @@ struct _state {
};

void
prot() {
prot(int) {
if (++caught == n) {
caught = 0;
n = benchmp_interval(benchmp_getstate());
Expand Down
4 changes: 2 additions & 2 deletions src/lat_udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ char *id = "$Id$\n";

void client_main(int ac, char **av);
void server_main();
void timeout();
void timeout(int signum);
void init(iter_t iterations, void* cookie);
void cleanup(iter_t iterations, void* cookie);
void doit(iter_t iterations, void* cookie);
Expand Down Expand Up @@ -164,7 +164,7 @@ cleanup(iter_t iterations, void* cookie)
}

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.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@charlie-rivos: This code was written by you, what do you think?

fprintf(stderr, "Recv timed out\n");
exit(1);
Expand Down
2 changes: 1 addition & 1 deletion src/lat_unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void
initialize(iter_t iterations, void* cookie)
{
struct _state* pState = (struct _state*)cookie;
void exit();
void exit(int);

Comment on lines 73 to 75
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.
Copy link
Copy Markdown
Contributor Author

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)

Can we drop this local prototype without any further changes? The code still compiles.

if (iterations) return;

Expand Down
2 changes: 1 addition & 1 deletion src/lat_usleep.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ bench_pselect(iter_t iterations, void *cookie)
#endif /* _POSIX_SELECT */

void
interval()
interval(int)
{
if (++caught == n) {
caught = 0;
Expand Down
18 changes: 9 additions & 9 deletions src/lmdd.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ int norepeats = -1;
bds_msg *m1, *m2;
#endif

uint64 getarg();
uint64 getarg(char *s, int ac, char **av);
int been_there(uint64 off);
int getfile(char *s, int ac, char **av);

Expand Down Expand Up @@ -156,7 +156,7 @@ char *cmds[] = {


void error(char *);
void done();
void done(int signum);
#ifdef DBG
extern int dbg;
#endif
Expand All @@ -170,7 +170,7 @@ main(int ac, char **av)
int Fork, misses, mismatch, outpat, inpat, in, timeopen, gotcnt;
int slp;
uint64 skip, size, count;
void chkarg();
void chkarg(char *arg);
int i;
uint64 off = 0;
int touch;
Expand Down Expand Up @@ -340,7 +340,7 @@ main(int ac, char **av)
register int moved;

if (gotcnt && count-- <= 0) {
done();
done(0);
}

/*
Expand Down Expand Up @@ -453,7 +453,7 @@ main(int ac, char **av)
perror("read");
}
if (moved <= 0) {
done();
done(0);
}
if (inpat != -1) {
register int foo, cnt;
Expand All @@ -466,7 +466,7 @@ main(int ac, char **av)
(uint)(off + foo*sizeof(int)),
buf[foo]);
if (mismatch != -1 && --misses == 0) {
done();
done(0);
}
}
}
Expand Down Expand Up @@ -531,7 +531,7 @@ main(int ac, char **av)
if (moved2 != moved) {
fprintf(stderr, "write: wanted=%d got=%d\n",
moved, moved2);
done();
done(0);
}
if ((Wtmax != -1) || (Wtmin != -1)) {
int mics = stop(&start_tv, &stop_tv);
Expand Down Expand Up @@ -568,7 +568,7 @@ main(int ac, char **av)
perror("write");
}
if (moved2 != moved) {
done();
done(0);
}

if (touch) {
Expand Down Expand Up @@ -634,7 +634,7 @@ chkarg(char *arg)
}

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.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@charlie-rivos: This code was written by you, what do you think?

int i;
int step;
Expand Down
4 changes: 2 additions & 2 deletions src/lmhttp.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ char *buf;
char *bufs[3];
int Dflg, dflg, nflg, lflg, fflg, zflg;
int data, logfile;
void die();
void die(int signum);
void worker();
char *http_time(void);
char *date(time_t *tt);
Expand Down Expand Up @@ -387,7 +387,7 @@ logit(int sock, char *name, int size)
nbytes += len;
}

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.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@charlie-rivos: This code was written by you, what do you think?

if (nbytes) {
write(logfile, logbuf, nbytes);
Expand Down
2 changes: 1 addition & 1 deletion src/memsize.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ test_malloc(size_t size)
}

void
gotalarm()
gotalarm(int)
{
alarm_triggered = 1;
}
Expand Down