Skip to content
This repository was archived by the owner on Jun 16, 2025. It is now read-only.

Commit 19d0620

Browse files
committed
Replace NoP and NOT_USED with UNUSED
Compilers and various lint tools complain about the existing macros for indicating a function argument is deliberately, explicitly, not used. The fact there are different macros for doing the same thing is also a problem. So replace them with the macro I wrote for the Fish shell project.
1 parent 8a5b18a commit 19d0620

Some content is hidden

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

59 files changed

+178
-135
lines changed

src/cmd/coshell/cotest.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@
2626
State_t state;
2727

2828
void shellclose(Coshell_t *a, int b) {
29-
NoP(a);
30-
NoP(b);
29+
UNUSED(a);
30+
UNUSED(b);
3131
}
3232

33-
void jobcheck(Coshell_t *a) { NoP(a); }
33+
void jobcheck(Coshell_t *a) { UNUSED(a); }
3434

3535
static void init(void) {
3636
register int n;
@@ -80,8 +80,8 @@ int main(int argc, char **argv) {
8080
register int op;
8181
Coattr_t attr;
8282

83-
NoP(argc);
84-
NoP(argv);
83+
UNUSED(argc);
84+
UNUSED(argv);
8585
error(-1, "debug");
8686
init();
8787
while ((s = sfgetr(sfstdin, '\n', 0)) && sfvalue(sfstdin) > 1)

src/cmd/coshell/event.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ static const char ident_name[] = "EVEN";
124124
#if !_use_ndbm
125125

126126
int main(int argc, char **argv) {
127-
NoP(argc);
128-
NoP(argv);
127+
UNUSED(argc);
128+
UNUSED(argv);
129129
error(3, "<ndbm.h> library required");
130130
return 1;
131131
}
@@ -849,8 +849,8 @@ static void confree(Dt_t *dt, void *obj, Dtdisc_t *disc) {
849849
State_t *state = (State_t *)((char *)disc - offsetof(State_t, condisc));
850850
Connection_t *con = (Connection_t *)obj;
851851

852-
NoP(dt);
853-
NoP(disc);
852+
UNUSED(dt);
853+
UNUSED(disc);
854854
state->active--;
855855
if (con->waiting) dtclose(con->waiting);
856856
log(state, con, 'S', "drop connection -- %d active", state->active);
@@ -862,8 +862,8 @@ static void confree(Dt_t *dt, void *obj, Dtdisc_t *disc) {
862862
*/
863863

864864
static void eventfree(Dt_t *dt, void *obj, Dtdisc_t *disc) {
865-
NoP(dt);
866-
NoP(disc);
865+
UNUSED(dt);
866+
UNUSED(disc);
867867
free(obj);
868868
}
869869

@@ -875,7 +875,7 @@ static void waitfree(Dt_t *dt, void *obj, Dtdisc_t *disc) {
875875
State_t *state = (State_t *)((char *)disc - offsetof(State_t, waitdisc));
876876
Waiting_t *p = (Waiting_t *)obj;
877877

878-
NoP(dt);
878+
UNUSED(dt);
879879
if (--p->event->waiting == 0) dtdelete(state->events, p->event);
880880
free(obj);
881881
}
@@ -939,7 +939,7 @@ int main(int argc, char **argv) {
939939

940940
static State_t state;
941941

942-
NoP(argc);
942+
UNUSED(argc);
943943
setlocale(LC_ALL, "");
944944
opt_info.argv = argv;
945945
state.log = 1;

src/cmd/coshell/main.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ static void *init(void *handle, int fdmax) {
9898
register int n;
9999
register char *s;
100100

101-
NoP(handle);
101+
UNUSED(handle);
102102
message((-1, "init pid=%d", getpid()));
103103
state.clock = state.start = state.toss = cs.time;
104104
for (n = 0; n < 10; n++) TOSS;
@@ -211,10 +211,10 @@ static void *init(void *handle, int fdmax) {
211211
*/
212212

213213
static int user(void *handle, int fd, Cs_id_t *id, int clone, char **argv) {
214-
NoP(handle);
215-
NoP(id);
216-
NoP(clone);
217-
NoP(argv);
214+
UNUSED(handle);
215+
UNUSED(id);
216+
UNUSED(clone);
217+
UNUSED(argv);
218218
if (state.indirect.con) {
219219
state.con[fd].type = INIT;
220220
state.con[fd].info.user.fds[0] = fd;
@@ -266,7 +266,7 @@ static int service(void *handle, register int fd) {
266266
int fds[5];
267267
char cmd[256];
268268

269-
NoP(handle);
269+
UNUSED(handle);
270270
switch (state.con[fd].type) {
271271
case ANON:
272272
case SHELL:
@@ -667,7 +667,7 @@ static int service(void *handle, register int fd) {
667667
*/
668668

669669
static int wakeup(void *handle) {
670-
NoP(handle);
670+
UNUSED(handle);
671671
shellcheck();
672672
jobcheck(NULL);
673673
return (0);
@@ -680,7 +680,7 @@ static int wakeup(void *handle) {
680680
static void *indirect(void *handle, int fdmax) {
681681
int *pass;
682682

683-
NoP(handle);
683+
UNUSED(handle);
684684
if (!(pass = newof(0, int, fdmax, 0))) error(3, "out of space [pass]");
685685
csfd(state.indirect.con, CS_POLL_READ);
686686
pass[state.indirect.con] = state.indirect.msg;
@@ -731,7 +731,7 @@ int main(int argc, char **argv) {
731731
char *t;
732732
int fds[4];
733733

734-
NoP(argc);
734+
UNUSED(argc);
735735
setlocale(LC_ALL, "");
736736
opt_info.argv = argv;
737737
error_info.id = CO_ID;

src/cmd/ksh93/bltins/cd_pwd.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@
4242
//
4343
static void invalidate(Namval_t *np, void *data) {
4444
Pathcomp_t *pp = (Pathcomp_t *)np->nvalue.cp;
45-
NOT_USED(data);
45+
UNUSED(data);
46+
4647
if (pp && *pp->name != '/') _nv_unset(np, 0);
4748
}
4849

@@ -292,7 +293,7 @@ int b_pwd(int argc, char *argv[], Shbltin_t *context) {
292293
Shell_t *shp = context->shp;
293294
bool pflag = false;
294295
int n, ffd = -1;
295-
NOT_USED(argc);
296+
UNUSED(argc);
296297

297298
while ((n = optget(argv, sh_optpwd))) {
298299
switch (n) {

src/cmd/ksh93/bltins/hist.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ int b_hist(int argc, char *argv[], Shbltin_t *context) {
5353
int pflag = 0;
5454
#endif
5555
Histloc_t location;
56-
NOT_USED(argc);
56+
UNUSED(argc);
5757

5858
if (!sh_histinit((void *)shp)) errormsg(SH_DICT, ERROR_system(1), e_histopen);
5959
hp = shp->gd->hist_ptr;

src/cmd/ksh93/bltins/misc.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ int b_exec(int argc, char *argv[], Shbltin_t *context) {
9494
}
9595

9696
static void noexport(Namval_t *np, void *data) {
97-
NOT_USED(data);
97+
UNUSED(data);
9898
nv_offattr(np, NV_EXPORT);
9999
}
100100

@@ -157,7 +157,8 @@ int b_let(int argc, char *argv[], Shbltin_t *context) {
157157
int r;
158158
char *arg;
159159
Shell_t *shp = context->shp;
160-
NOT_USED(argc);
160+
UNUSED(argc);
161+
161162
while ((r = optget(argv, sh_optlet))) {
162163
switch (r) {
163164
case ':': {
@@ -180,7 +181,8 @@ int b_let(int argc, char *argv[], Shbltin_t *context) {
180181
int b_eval(int argc, char *argv[], Shbltin_t *context) {
181182
int r;
182183
Shell_t *shp = context->shp;
183-
NOT_USED(argc);
184+
UNUSED(argc);
185+
184186
while ((r = optget(argv, sh_opteval))) {
185187
switch (r) {
186188
case ':': {
@@ -316,19 +318,19 @@ int b_dot_cmd(int n, char *argv[], Shbltin_t *context) {
316318
// Builtins `:` and `true`.
317319
//
318320
int b_true(int argc, char *argv[], Shbltin_t *context) {
319-
NOT_USED(argc);
320-
NOT_USED(argv[0]);
321-
NOT_USED(context);
321+
UNUSED(argc);
322+
UNUSED(argv[0]);
323+
UNUSED(context);
322324
return 0;
323325
}
324326

325327
//
326328
// Builtin `false`.
327329
//
328330
int b_false(int argc, char *argv[], Shbltin_t *context) {
329-
NOT_USED(argc);
330-
NOT_USED(argv[0]);
331-
NOT_USED(context);
331+
UNUSED(argc);
332+
UNUSED(argv[0]);
333+
UNUSED(context);
332334
return 1;
333335
}
334336

@@ -472,7 +474,8 @@ int b_jobs(int n, char *argv[], Shbltin_t *context) {
472474
int b_universe(int argc, char *argv[], Shbltin_t *context) {
473475
char *arg;
474476
int n;
475-
NOT_USED(context);
477+
UNUSED(context);
478+
476479
while ((n = optget(argv, sh_optuniverse))) {
477480
switch (n) {
478481
case ':': {

src/cmd/ksh93/bltins/mkservice.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,8 @@ int b_mkservice(int argc, char **argv, Shbltin_t *context) {
347347
Service_t *sp;
348348
int fd;
349349
Shell_t *shp = context->shp;
350+
UNUSED(argc);
350351

351-
NOT_USED(argc);
352352
for (;;) {
353353
switch (optget(argv, mkservice_usage)) {
354354
case 0: {
@@ -405,7 +405,8 @@ int b_mkservice(int argc, char **argv, Shbltin_t *context) {
405405
//
406406
int b_eloop(int argc, char **argv, Shbltin_t *context) {
407407
long timeout = -1;
408-
NOT_USED(argc);
408+
UNUSED(argc);
409+
409410
for (;;) {
410411
switch (optget(argv, eloop_usage)) {
411412
case 0: {

src/cmd/ksh93/bltins/print.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ int B_echo(int argc, char *argv[], Shbltin_t *context) {
9898
prdata.options = sh_optecho + 5;
9999
prdata.raw = prdata.echon = 0;
100100
prdata.sh = context->shp;
101-
NOT_USED(argc);
101+
UNUSED(argc);
102+
102103
// This mess is because /bin/echo on BSD is different.
103104
if (!prdata.sh->universe) {
104105
char *universe;
@@ -132,7 +133,8 @@ int B_echo(int argc, char *argv[], Shbltin_t *context) {
132133
//
133134
int b_printf(int argc, char *argv[], Shbltin_t *context) {
134135
struct print prdata;
135-
NOT_USED(argc);
136+
UNUSED(argc);
137+
136138
memset(&prdata, 0, sizeof(prdata));
137139
prdata.sh = context->shp;
138140
prdata.options = sh_optprintf;

src/cmd/ksh93/bltins/trap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ int b_trap(int argc, char *argv[], Shbltin_t *context) {
4242
int sig, clear;
4343
bool pflag = false, dflag = false, aflag = false, lflag = false;
4444
Shell_t *shp = context->shp;
45-
NOT_USED(argc);
45+
UNUSED(argc);
4646

4747
while ((sig = optget(argv, sh_opttrap))) {
4848
switch (sig) {
@@ -188,7 +188,7 @@ int b_kill(int argc, char *argv[], Shbltin_t *context) {
188188
int sig = SIGTERM, flag = 0, n;
189189
Shell_t *shp = context->shp;
190190
int usemenu = 0;
191-
NOT_USED(argc);
191+
UNUSED(argc);
192192

193193
while ((n = optget(argv, sh_optkill))) {
194194
switch (n) {

src/cmd/ksh93/bltins/typeset.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ int b_readonly(int argc, char *argv[], Shbltin_t *context) {
8282
int flag;
8383
char *command = argv[0];
8484
struct tdata tdata;
85-
NOT_USED(argc);
85+
UNUSED(argc);
8686

8787
memset((void *)&tdata, 0, sizeof(tdata));
8888
tdata.sh = context->shp;
@@ -135,7 +135,7 @@ int b_alias(int argc, char *argv[], Shbltin_t *context) {
135135
Dt_t *troot;
136136
int n;
137137
struct tdata tdata;
138-
NOT_USED(argc);
138+
UNUSED(argc);
139139

140140
memset((void *)&tdata, 0, sizeof(tdata));
141141
tdata.sh = context->shp;
@@ -212,7 +212,7 @@ int b_typeset(int argc, char *argv[], Shbltin_t *context) {
212212
#if SHOPT_BASH
213213
bool local = *argv[0] == 'l' && strcmp(argv[0], "local") == 0;
214214
#endif // SHOPT_BASH
215-
NOT_USED(argc);
215+
UNUSED(argc);
216216

217217
memset((void *)&tdata, 0, sizeof(tdata));
218218
tdata.sh = context->shp;
@@ -915,7 +915,8 @@ int b_builtin(int argc, char *argv[], Shbltin_t *context) {
915915
#ifdef SH_PLUGIN_VERSION
916916
int list = 0;
917917
#endif // SH_PLUGIN_VERSION
918-
NOT_USED(argc);
918+
UNUSED(argc);
919+
919920
memset(&tdata, 0, sizeof(tdata));
920921
tdata.sh = context->shp;
921922
stkp = tdata.sh->stk;
@@ -1113,7 +1114,8 @@ static int unall(int argc, char **argv, Dt_t *troot, Shell_t *shp) {
11131114
Dt_t *dp;
11141115
int nflag = 0, all = 0, isfun, jmpval;
11151116
struct checkpt buff;
1116-
NOT_USED(argc);
1117+
UNUSED(argc);
1118+
11171119
if (troot == shp->alias_tree) {
11181120
name = sh_optunalias;
11191121
if (shp->subshell) troot = sh_subaliastree(shp, 0);

0 commit comments

Comments
 (0)