Skip to content

Commit c6fc522

Browse files
committed
lib/misc.c: fix build against -std=c23 (void (*)()) changed the meaning)
gcc-15 switched to -std=c23 by default: https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=55e3bd376b2214e200fa76d12b67ff259b06c212 As a result `lsof` fails the build as: misc.c:390:26: error: too many arguments to function 'r_fn' 390 | rv = r_fn(r_arg, r.r_rbuf, r_rbln); | ^~~~ Before C23 `int (*)()` meant any function that returns `int`. In `C23` if means only `int (*)(void)`. But `lsof` alwaus uses `int (*)(char *path, char *buf, int len)` in that place. Switched to explicit function type instead.
1 parent 96f4cc5 commit c6fc522

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

lib/misc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ static void closePipes(void);
5656
static int dolstat(char *path, char *buf, int len);
5757
static int dostat(char *path, char *buf, int len);
5858
static int doreadlink(char *path, char *buf, int len);
59-
static int doinchild(struct lsof_context *ctx, int (*fn)(), char *fp,
59+
static int doinchild(struct lsof_context *ctx, int (*fn)(char *path, char *buf, int len), char *fp,
6060
char *rbuf, int rbln);
6161

6262
#if defined(HASINTSIGNAL)
@@ -259,7 +259,7 @@ void closefrom_shim(struct lsof_context *ctx, int low) {
259259
*/
260260

261261
static int doinchild(struct lsof_context *ctx,
262-
int (*fn)(), /* function to perform */
262+
int (*fn)(char *path, char *buf, int len), /* function to perform */
263263
char *fp, /* function parameter */
264264
char *rbuf, /* response buffer */
265265
int rbln) /* response buffer length */
@@ -321,7 +321,7 @@ static int doinchild(struct lsof_context *ctx,
321321
*/
322322
struct stat _;
323323
} r;
324-
int (*r_fn)();
324+
int (*r_fn)(char *path, char *buf, int len);
325325
/*
326326
* Close sufficient open file descriptors except Pipes[0] and
327327
* Pipes[3].

0 commit comments

Comments
 (0)