From d28a95513e4fc1bb11dedba7ea7a8eabf79fbfe4 Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Tue, 18 Apr 2023 11:27:29 -0700 Subject: [PATCH] mail: Use a C89 function pointer type for command functions. The command function is defined to always take a void *. Functions which accept a pointer to an array of pointers use a local temporary 'argv' assigned from the void *arg. Reviewed by: zlei Differential Revision: https://reviews.freebsd.org/D39527 --- usr.bin/mail/cmd1.c | 6 +++--- usr.bin/mail/cmd2.c | 5 +++-- usr.bin/mail/cmd3.c | 26 ++++++++++++++----------- usr.bin/mail/collect.c | 2 +- usr.bin/mail/def.h | 2 +- usr.bin/mail/edit.c | 4 ++-- usr.bin/mail/extern.h | 44 +++++++++++++++++++++--------------------- usr.bin/mail/lex.c | 2 +- usr.bin/mail/quit.c | 2 +- usr.bin/mail/send.c | 2 +- usr.bin/mail/util.c | 3 ++- 11 files changed, 52 insertions(+), 46 deletions(-) diff --git a/usr.bin/mail/cmd1.c b/usr.bin/mail/cmd1.c index cace03df9aab..0689c1eb0cb5 100644 --- a/usr.bin/mail/cmd1.c +++ b/usr.bin/mail/cmd1.c @@ -211,7 +211,7 @@ printhead(int mesg) * Print out the value of dot. */ int -pdot(void) +pdot(void *arg __unused) { printf("%td\n", dot - &message[0] + 1); return (0); @@ -221,7 +221,7 @@ pdot(void) * Print out all the possible commands. */ int -pcmdlist(void) +pcmdlist(void *arg __unused) { extern const struct cmd cmdtab[]; const struct cmd *cp; @@ -439,7 +439,7 @@ mboxit(void *v) * List the folders the user currently has. */ int -folders(void) +folders(void *arg __unused) { char dirname[PATHSIZE]; char *cmd; diff --git a/usr.bin/mail/cmd2.c b/usr.bin/mail/cmd2.c index 08b7a252b974..2c0f8d55e299 100644 --- a/usr.bin/mail/cmd2.c +++ b/usr.bin/mail/cmd2.c @@ -360,7 +360,7 @@ undeletecmd(void *v) * Interactively dump core on "core" */ int -core(void) +core(void *arg __unused) { int pid; @@ -386,8 +386,9 @@ core(void) * Clobber as many bytes of stack as the user requests. */ int -clobber(char **argv) +clobber(void *arg) { + char **argv = arg; int times; if (argv[0] == 0) diff --git a/usr.bin/mail/cmd3.c b/usr.bin/mail/cmd3.c index 68afbaa56913..2b4a20b96bb5 100644 --- a/usr.bin/mail/cmd3.c +++ b/usr.bin/mail/cmd3.c @@ -51,7 +51,7 @@ __FBSDID("$FreeBSD$"); * and forking a sh -c */ int -shell(char *str) +shell(void *str) { sig_t sigint = signal(SIGINT, SIG_IGN); char *sh; @@ -74,7 +74,7 @@ shell(char *str) */ /*ARGSUSED*/ int -dosh(char *str __unused) +dosh(void *str __unused) { sig_t sigint = signal(SIGINT, SIG_IGN); char *sh; @@ -146,7 +146,7 @@ overf: */ int -help(void) +help(void *arg __unused) { int c; FILE *f; @@ -530,7 +530,7 @@ diction(const void *a, const void *b) /*ARGSUSED*/ int -null(int e __unused) +null(void *arg __unused) { return (0); } @@ -540,8 +540,9 @@ null(int e __unused) * the current file. */ int -file(char **argv) +file(void *arg) { + char **argv = arg; if (argv[0] == NULL) { newfileinfo(0); @@ -557,8 +558,9 @@ file(char **argv) * Expand file names like echo */ int -echo(char **argv) +echo(void *arg) { + char **argv = arg; char **ap, *cp; for (ap = argv; *ap != NULL; ap++) { @@ -574,7 +576,7 @@ echo(char **argv) } int -Respond(int *msgvec) +Respond(void *msgvec) { if (value("Replyall") == NULL && value("flipr") == NULL) return (doRespond(msgvec)); @@ -625,8 +627,9 @@ doRespond(int msgvec[]) * .mailrc and do some things if sending, others if receiving. */ int -ifcmd(char **argv) +ifcmd(void *arg) { + char **argv = arg; char *cp; if (cond != CANY) { @@ -656,7 +659,7 @@ ifcmd(char **argv) * flip over the conditional flag. */ int -elsecmd(void) +elsecmd(void *arg __unused) { switch (cond) { @@ -684,7 +687,7 @@ elsecmd(void) * End of if statement. Just set cond back to anything. */ int -endifcmd(void) +endifcmd(void *arg __unused) { if (cond == CANY) { @@ -699,8 +702,9 @@ endifcmd(void) * Set the list of alternate names. */ int -alternates(char **namelist) +alternates(void *arg) { + char **namelist = arg; int c; char **ap, **ap2, *cp; diff --git a/usr.bin/mail/collect.c b/usr.bin/mail/collect.c index d56f460a8690..e8249a10f867 100644 --- a/usr.bin/mail/collect.c +++ b/usr.bin/mail/collect.c @@ -199,7 +199,7 @@ cont: /* * Dump core. */ - core(); + core(NULL); break; case '!': /* diff --git a/usr.bin/mail/def.h b/usr.bin/mail/def.h index 02b84478456b..fd41081797c6 100644 --- a/usr.bin/mail/def.h +++ b/usr.bin/mail/def.h @@ -106,7 +106,7 @@ struct message { */ struct cmd { const char *c_name; /* Name of command */ - int (*c_func)(); /* Implementor of the command */ + int (*c_func)(void *); /* Implementor of the command */ short c_argtype; /* Type of arglist (see below) */ short c_msgflag; /* Required flags of messages */ short c_msgmask; /* Relevant flags of messages */ diff --git a/usr.bin/mail/edit.c b/usr.bin/mail/edit.c index e8d6fcb12ccc..bc7f4beb29fb 100644 --- a/usr.bin/mail/edit.c +++ b/usr.bin/mail/edit.c @@ -51,7 +51,7 @@ __FBSDID("$FreeBSD$"); * Edit a message list. */ int -editor(int *msgvec) +editor(void *msgvec) { return (edit1(msgvec, 'e')); @@ -61,7 +61,7 @@ editor(int *msgvec) * Invoke the visual editor on a message list. */ int -visual(int *msgvec) +visual(void *msgvec) { return (edit1(msgvec, 'v')); diff --git a/usr.bin/mail/extern.h b/usr.bin/mail/extern.h index aa31733dd26a..4f06f77f18a2 100644 --- a/usr.bin/mail/extern.h +++ b/usr.bin/mail/extern.h @@ -75,12 +75,12 @@ char *yanklogin(char *, char *); int Fclose(FILE *); int More(void *); int Pclose(FILE *); -int Respond(int *); +int Respond(void *); int Type(void *); int doRespond(int *); int dorespond(int *); void alter(char *); -int alternates(char **); +int alternates(void *); void announce(void); int append(struct message *, FILE *); int argcount(char **); @@ -90,7 +90,7 @@ void brokpipe(int); int charcount(char *, int); int check(int, int); void clob1(int); -int clobber(char **); +int clobber(void *); void close_all_files(void); int cmatch(char *, char *); void collhup(int); @@ -98,32 +98,32 @@ void collint(int); void collstop(int); void commands(void); int copycmd(void *v); -int core(void); +int core(void *); int count(struct name *); int deletecmd(void *); int delm(int *); int deltype(void *); void demail(void); int diction(const void *, const void *); -int dosh(char *); -int echo(char **); +int dosh(void *); +int echo(void *); int edit1(int *, int); -int editor(int *); +int editor(void *); void edstop(void); -int elsecmd(void); -int endifcmd(void); +int elsecmd(void *); +int endifcmd(void *); int evalcol(int); int execute(char *, int); int exwrite(char *, FILE *, int); void fail(const char *, const char *); -int file(char **); +int file(void *); struct grouphead * findgroup(char *); void findmail(char *, char *, int); int first(int, int); void fixhead(struct header *, struct name *); void fmt(const char *, struct name *, FILE *, int); -int folders(void); +int folders(void *); int forward(char *, FILE *, char *, int); void free_child(int); int from(void *); @@ -139,9 +139,9 @@ void hangup(int); int hash(const char *); void hdrstop(int); int headers(void *); -int help(void); +int help(void *); void holdsigs(void); -int ifcmd(char **); +int ifcmd(void *); int igcomp(const void *, const void *); int igfield(void *); int ignore1(char **, struct ignoretab *, const char *); @@ -178,10 +178,10 @@ int metamess(int, int); int more(void *); int newfileinfo(int); int next(void *); -int null(int); +int null(void *); void parse(char *, struct headline *, char *); -int pcmdlist(void); -int pdot(void); +int pcmdlist(void *); +int pdot(void *); void prepare_child(sigset_t *, int, int); int preserve(void *); void prettyprint(struct name *); @@ -189,9 +189,9 @@ void printgroup(char *); void printhead(int); int puthead(struct header *, FILE *, int); int putline(FILE *, char *, int); -int pversion(int); +int pversion(void *); void quit(void); -int quitcmd(void); +int quitcmd(void *); int readline(FILE *, char *, int); void register_file(FILE *, int, int); void regret(int); @@ -213,16 +213,16 @@ int schdir(void *); int screensize(void); int scroll(void *); int sendmessage(struct message *, FILE *, struct ignoretab *, char *); -int sendmail(char *); +int sendmail(void *); int set(void *); int setfile(char *); void setmsize(int); void setptr(FILE *, off_t); void setscreensize(void); -int shell(char *); +int shell(void *); void sigchild(int); void sort(char **); -int source(char **); +int source(void *); void spreserve(void); void sreset(void); int start_command(char *, sigset_t *, int, int, ...); @@ -245,7 +245,7 @@ void unregister_file(FILE *); int unset(void *); int unstack(void); void vfree(char *); -int visual(int *); +int visual(void *); int wait_child(int); int wait_command(int); int writeback(FILE *); diff --git a/usr.bin/mail/lex.c b/usr.bin/mail/lex.c index 77004e52f28c..dfca9edeab8e 100644 --- a/usr.bin/mail/lex.c +++ b/usr.bin/mail/lex.c @@ -672,7 +672,7 @@ newfileinfo(int omsgCount) */ int -pversion(int e __unused) +pversion(void *arg __unused) { printf("Version %s\n", version); diff --git a/usr.bin/mail/quit.c b/usr.bin/mail/quit.c index 7b44f386bd53..e9d93285c65e 100644 --- a/usr.bin/mail/quit.c +++ b/usr.bin/mail/quit.c @@ -51,7 +51,7 @@ __FBSDID("$FreeBSD$"); * The "quit" command. */ int -quitcmd(void) +quitcmd(void *arg __unused) { /* * If we are sourcing, then return 1 so execute() can handle it. diff --git a/usr.bin/mail/send.c b/usr.bin/mail/send.c index 70bc5261f805..702dbd031216 100644 --- a/usr.bin/mail/send.c +++ b/usr.bin/mail/send.c @@ -268,7 +268,7 @@ mail(struct name *to, struct name *cc, struct name *bcc, struct name *smopts, * the mail routine below. */ int -sendmail(char *str) +sendmail(void *str) { struct header head; diff --git a/usr.bin/mail/util.c b/usr.bin/mail/util.c index 558b47245c77..7187d1b520f9 100644 --- a/usr.bin/mail/util.c +++ b/usr.bin/mail/util.c @@ -265,8 +265,9 @@ static struct sstack sstack[SSTACK_SIZE]; * that they are no longer reading from a tty (in all probability). */ int -source(char **arglist) +source(void *arg) { + char **arglist = arg; FILE *fi; char *cp;