Skip to content

Commit c466298

Browse files
committed
More really boring maintenance
This fixes a selection of the compiler warnings obtained from clang 19.1.6 (Linux arm64) with the flags -Wall -Wextra -pedantic. Loads of files: - Remove unused function parameters where possible. - Mark many other unused function parameters with NOT_USED to silence the -Wextra warnings. src/cmd/ksh93/bltins/cd_pwd.c, src/cmd/ksh93/sh/path.c: - Typecast void pointers returned by stkfreeze to char* before adding PATH_OFFSET, because pointer arithmetic with void pointers is technically undefined behaviour (though widely supported in practice). So yes, there was a minor problem following a45a0eb after all. src/cmd/ksh93/sh/waitevent.c, src/cmd/ksh93/include/shell.h, src/cmd/ksh93/shell.3: - Fix overly complicated typing of sh_waitnotify to avoid complaints about converting between void pointers and function pointers; the Shwait_f type is declared everywhere, so just use it.
1 parent bedba24 commit c466298

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+277
-132
lines changed

src/cmd/INIT/mamake.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ static const char usage[] =
106106
#else
107107

108108
#define elementsof(x) (sizeof(x)/sizeof(x[0]))
109+
#define NOT_USED(x) do (void)(x); while(0)
109110

110111
/*
111112
* For compatibility with compiler flags such as -std=c99, feature macros
@@ -502,7 +503,7 @@ static char *appendn(Buf_t *buf, char *str, size_t n)
502503
{
503504
size_t m, i;
504505

505-
if ((n + 1) >= (buf->end - buf->nxt))
506+
if ((n + 1) >= (size_t)(buf->end - buf->nxt))
506507
{
507508
i = buf->nxt - buf->buf;
508509
m = (((buf->end - buf->buf) + n + CHUNK + 1) / CHUNK) * CHUNK;
@@ -2767,6 +2768,8 @@ int main(int argc, char **argv)
27672768
Buf_t *tmp;
27682769
int c;
27692770

2771+
NOT_USED(argc);
2772+
27702773
/*
27712774
* initialize the state
27722775
*/

src/cmd/builtin/pty.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* *
33
* This software is part of the ast package *
44
* Copyright (c) 1992-2013 AT&T Intellectual Property *
5-
* Copyright (c) 2020-2024 Contributors to ksh 93u+m *
5+
* Copyright (c) 2020-2025 Contributors to ksh 93u+m *
66
* and is licensed under the *
77
* Eclipse Public License, Version 2.0 *
88
* *
@@ -382,6 +382,8 @@ process(Sfio_t* mp, Sfio_t* lp, int delay, int timeout)
382382
struct stat dst;
383383
struct stat fst;
384384

385+
NOT_USED(lp);
386+
NOT_USED(delay);
385387
ip = sfstdin;
386388
if (!fstat(sffileno(ip), &dst) && !stat("/dev/null", &fst) && dst.st_dev == fst.st_dev && dst.st_ino == fst.st_ino)
387389
ip = 0;

src/cmd/ksh93/bltins/cd_pwd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ int b_cd(int argc, char *argv[],Shbltin_t *context)
277277
}
278278
stkseek(sh.stk,dir-stkptr(sh.stk,0));
279279
}
280-
dir = stkfreeze(sh.stk,1)+PATH_OFFSET;
280+
dir = (char*)stkfreeze(sh.stk,1) + PATH_OFFSET;
281281
if(*dp && (*dp!='.'||dp[1]) && strchr(dir,'/'))
282282
sfputr(sfstdout,dir,'\n');
283283
nv_putval(opwdnod,oldpwd,NV_RDONLY);

src/cmd/ksh93/bltins/enum.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* *
33
* This software is part of the ast package *
44
* Copyright (c) 1982-2012 AT&T Intellectual Property *
5-
* Copyright (c) 2020-2024 Contributors to ksh 93u+m *
5+
* Copyright (c) 2020-2025 Contributors to ksh 93u+m *
66
* and is licensed under the *
77
* Eclipse Public License, Version 2.0 *
88
* *
@@ -122,6 +122,7 @@ static int enuminfo(Opt_t* op, Sfio_t *out, const char *str, Optdisc_t *fp)
122122
struct Enum *ep;
123123
int n=0;
124124
const char *v;
125+
NOT_USED(op);
125126
np = *(Namval_t**)(fp+1);
126127
ep = (struct Enum*)np->nvfun;
127128
if(!ep)
@@ -151,6 +152,9 @@ static int enuminfo(Opt_t* op, Sfio_t *out, const char *str, Optdisc_t *fp)
151152
static Namfun_t *clone_enum(Namval_t* np, Namval_t *mp, int flags, Namfun_t *fp)
152153
{
153154
struct Enum *ep, *pp=(struct Enum*)fp;
155+
NOT_USED(np);
156+
NOT_USED(mp);
157+
NOT_USED(flags);
154158
ep = sh_newof(0,struct Enum,1,pp->nelem*sizeof(char*));
155159
memcpy(ep,pp,sizeof(struct Enum)+pp->nelem*sizeof(char*));
156160
return &ep->hdr;

src/cmd/ksh93/bltins/getopts.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* *
33
* This software is part of the ast package *
44
* Copyright (c) 1982-2012 AT&T Intellectual Property *
5-
* Copyright (c) 2020-2024 Contributors to ksh 93u+m *
5+
* Copyright (c) 2020-2025 Contributors to ksh 93u+m *
66
* and is licensed under the *
77
* Eclipse Public License, Version 2.0 *
88
* *
@@ -34,6 +34,8 @@
3434
static int infof(Opt_t* op, Sfio_t* sp, const char* s, Optdisc_t* dp)
3535
{
3636
Stk_t *stkp = sh.stk;
37+
NOT_USED(op);
38+
NOT_USED(dp);
3739
#if SHOPT_NAMESPACE
3840
if((sh.namespace && sh_fsearch(s,0)) || nv_search(s,sh.fun_tree,0))
3941
#else
@@ -61,6 +63,8 @@ int b_getopts(int argc,char *argv[],Shbltin_t *context)
6163
volatile int extended, r= -1;
6264
struct checkpt buff, *pp;
6365
Optdisc_t disc;
66+
67+
NOT_USED(context);
6468
memset(&disc, 0, sizeof(disc));
6569
disc.version = OPT_VERSION;
6670
disc.infof = infof;

src/cmd/ksh93/bltins/print.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* *
33
* This software is part of the ast package *
44
* Copyright (c) 1982-2014 AT&T Intellectual Property *
5-
* Copyright (c) 2020-2024 Contributors to ksh 93u+m *
5+
* Copyright (c) 2020-2025 Contributors to ksh 93u+m *
66
* and is licensed under the *
77
* Eclipse Public License, Version 2.0 *
88
* *
@@ -153,6 +153,9 @@ static int infof(Opt_t* op, Sfio_t* sp, const char* s, Optdisc_t* dp)
153153
{
154154
const struct printmap *pm;
155155
char c='%';
156+
NOT_USED(op);
157+
NOT_USED(s);
158+
NOT_USED(dp);
156159
for(pm=Pmap;pm->size>0;pm++)
157160
sfprintf(sp, "[+%c(%s)q?Equivalent to %s.]",c,pm->name,pm->equivalent);
158161
return 1;
@@ -750,6 +753,7 @@ static int extend(Sfio_t* sp, void* v, Sffmt_t* fe)
750753
struct printf* pp = (struct printf*)fe;
751754
char* argp = *pp->nextarg;
752755
char *w,*s;
756+
NOT_USED(sp);
753757
if(fe->n_str>0 && (format=='T'||format=='Q') && varname(fe->t_str,fe->n_str) && (!argp || varname(argp,-1)))
754758
{
755759
if(argp)

src/cmd/ksh93/bltins/test.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* *
33
* This software is part of the ast package *
44
* Copyright (c) 1982-2012 AT&T Intellectual Property *
5-
* Copyright (c) 2020-2024 Contributors to ksh 93u+m *
5+
* Copyright (c) 2020-2025 Contributors to ksh 93u+m *
66
* and is licensed under the *
77
* Eclipse Public License, Version 2.0 *
88
* *
@@ -134,6 +134,7 @@ int b_test(int argc, char *argv[],Shbltin_t *context)
134134
int not;
135135
int exitval;
136136

137+
NOT_USED(context);
137138
tdata.av = argv;
138139
tdata.ap = 1;
139140
if(c_eq(cp,'['))

src/cmd/ksh93/bltins/trap.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* *
33
* This software is part of the ast package *
44
* Copyright (c) 1982-2012 AT&T Intellectual Property *
5-
* Copyright (c) 2020-2024 Contributors to ksh 93u+m *
5+
* Copyright (c) 2020-2025 Contributors to ksh 93u+m *
66
* and is licensed under the *
77
* Eclipse Public License, Version 2.0 *
88
* *
@@ -46,6 +46,7 @@ int b_trap(int argc,char *argv[],Shbltin_t *context)
4646
char *arg = argv[1];
4747
int sig, clear = 0, dflag = 0, pflag = 0;
4848
NOT_USED(argc);
49+
NOT_USED(context);
4950
while (sig = optget(argv, sh_opttrap)) switch (sig)
5051
{
5152
case 'p':
@@ -219,6 +220,7 @@ int b_kill(int argc,char *argv[],Shbltin_t *context)
219220
int sig=SIGTERM, flag=0, n;
220221
int usemenu = 0;
221222
NOT_USED(argc);
223+
NOT_USED(context);
222224
if(**argv == 's') /* <s>top == kill -s STOP */
223225
{
224226
flag |= S_FLAG;
@@ -301,6 +303,7 @@ int b_suspend(int argc,char *argv[],Shbltin_t *context)
301303
{
302304
int n;
303305
NOT_USED(argc);
306+
NOT_USED(context);
304307
while((n = optget(argv, sh_optsuspend))) switch(n)
305308
{
306309
case ':':

src/cmd/ksh93/bltins/typeset.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* *
33
* This software is part of the ast package *
44
* Copyright (c) 1982-2012 AT&T Intellectual Property *
5-
* Copyright (c) 2020-2024 Contributors to ksh 93u+m *
5+
* Copyright (c) 2020-2025 Contributors to ksh 93u+m *
66
* and is licensed under the *
77
* Eclipse Public License, Version 2.0 *
88
* *
@@ -94,6 +94,7 @@ int b_readonly(int argc,char *argv[],Shbltin_t *context)
9494
char *command = argv[0];
9595
struct tdata tdata;
9696
NOT_USED(argc);
97+
NOT_USED(context);
9798
memset(&tdata,0,sizeof(tdata));
9899
tdata.aflag = '-';
99100
while((flag = optget(argv,*command=='e'?sh_optexport:sh_optreadonly))) switch(flag)
@@ -137,6 +138,7 @@ int b_alias(int argc,char *argv[],Shbltin_t *context)
137138
int rflag=0, xflag=0, n;
138139
struct tdata tdata;
139140
NOT_USED(argc);
141+
NOT_USED(context);
140142
memset(&tdata,0,sizeof(tdata));
141143
troot = sh.alias_tree;
142144
if(*argv[0]=='h')
@@ -1129,6 +1131,7 @@ int b_builtin(int argc,char *argv[],Shbltin_t *context)
11291131
int list = 0;
11301132
#endif
11311133
NOT_USED(argc);
1134+
NOT_USED(context);
11321135
memset(&tdata,0,sizeof(tdata));
11331136
stkp = sh.stk;
11341137
if(!sh.pathlist)
@@ -1256,6 +1259,7 @@ int b_builtin(int argc,char *argv[],Shbltin_t *context)
12561259
int b_set(int argc,char *argv[],Shbltin_t *context)
12571260
{
12581261
struct tdata tdata;
1262+
NOT_USED(context);
12591263
memset(&tdata,0,sizeof(tdata));
12601264
tdata.prefix=0;
12611265
if(argv[1])

src/cmd/ksh93/bltins/ulimit.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* *
33
* This software is part of the ast package *
44
* Copyright (c) 1982-2012 AT&T Intellectual Property *
5-
* Copyright (c) 2020-2024 Contributors to ksh 93u+m *
5+
* Copyright (c) 2020-2025 Contributors to ksh 93u+m *
66
* and is licensed under the *
77
* Eclipse Public License, Version 2.0 *
88
* *
@@ -50,6 +50,9 @@ static int infof(Opt_t* op, Sfio_t* sp, const char* s, Optdisc_t* dp)
5050
{
5151
const Limit_t* tp;
5252

53+
NOT_USED(op);
54+
NOT_USED(s);
55+
NOT_USED(dp);
5356
for (tp = shtab_limits; tp->option; tp++)
5457
{
5558
sfprintf(sp, "[%c=%d:%s?The %s", tp->option, tp - shtab_limits + 1, tp->name, tp->description);

0 commit comments

Comments
 (0)