Hi,
I've pushed this patch already because it seems pretty
uncontroversial.
Basically converting some K&R functions to ISO C and not using empty
argument lists:
/* Bad. */
void do_something ();
extern char *getenv ();
vs.
/* Good. */
void do_something (void);
extern char *getenv (const char *);
Since the first example will cause problems in C23. There are still a
few function pointers that need to be fixed. For example this idiom in
telnet:
struct encryptlist
{
const char *name;
const char *help;
int (*handler) ();
int needconnect;
int minarg;
int maxarg;
};
Where handler can have multiple different prototypes. FreeBSD just
casts the function which is undefined behavior in ISO C, but *should*
be allowed by POSIX (see documentation for dlsym). I'll fix those
eventually and add a NEWS entry saying Inetutils can be compiled in
C23 mode for whenever there is a release.
Collin
From dd4c077b3407b7fc0bd88313ee54c7c9200e2498 Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.fu...@gmail.com>
Date: Thu, 9 May 2024 18:51:54 -0700
Subject: [PATCH] maint: Fix most instances of '-Wstrict-prototypes'.
* libinetutils/des_rw.c (des_clear_key, des_read, des_write): Don't
use K&R-style function declarations.
* ifconfig/system/linux.c (pnd_read): Use void instead of an empty
argument list.
* libtelnet/auth.c (auth_status, auth_request, auth_send_retry):
Likewise.
* libtelnet/kerberos5.c (kerberos5_cleanup): Likewise.
* ping/ping.c (ping_run): Likewise.
* ping/ping6.c (ping_run): Likewise.
* ping/ping6.h (ping_run): Likewise.
* ping/ping_impl.h (ping_run): Likewise.
* telnet/authenc.c (net_encrypt, telnet_spin): Likewise.
* telnet/commands.c (_setlist_init, auth_help, EncryptHelp)
(ayt_status): Likewise.
* telnet/sys_bsd.c (TerminalNewMode): Likewise.
* telnet/tn3270.c (outputPurge, Push3270, Finish3270, SetIn3270)
(tn3270_ttype): Likewise.
* telnetd/state.c (willoption): Likewise.
* telnetd/telnetd.h (pty_buffer_level): Likewise.
* telnetd/term.c (term_send_eof, term_change_eof, tty_linemode)
(tty_isecho, tty_flowmode, tty_restartany, tty_israw)
(tty_isbinaryin, tty_isbinaryout, tty_isediting, tty_istrapsig)
(tty_issofttab, tty_islitecho, tty_iscrnl, copy_termbuf): Likewise.
* telnetd/termstat.c (termstat, _termstat): Likewise.
* telnetd/utility.c (net_encrypt, telnet_spin): Likewise.
* src/rcp.c (krb_realmofhost): Add the parameter type.
* telnet/ring.c (ring_encrypt): Likewise.
* telnet/ring.h (ring_encrypt): Likewise.
---
ifconfig/system/linux.c | 2 +-
libinetutils/des_rw.c | 12 +++---------
libtelnet/auth.c | 6 +++---
libtelnet/kerberos5.c | 2 +-
ping/ping.c | 2 +-
ping/ping6.c | 2 +-
ping/ping6.h | 2 +-
ping/ping_impl.h | 2 +-
src/rcp.c | 2 +-
telnet/authenc.c | 4 ++--
telnet/commands.c | 8 ++++----
telnet/ring.c | 2 +-
telnet/ring.h | 3 ++-
telnet/sys_bsd.c | 6 +++---
telnet/tn3270.c | 10 +++++-----
telnetd/state.c | 6 +++---
telnetd/telnetd.h | 4 ++--
telnetd/term.c | 30 +++++++++++++++---------------
telnetd/termstat.c | 4 ++--
telnetd/utility.c | 4 ++--
20 files changed, 54 insertions(+), 59 deletions(-)
diff --git a/ifconfig/system/linux.c b/ifconfig/system/linux.c
index 9e0fe47b..f06290d8 100644
--- a/ifconfig/system/linux.c
+++ b/ifconfig/system/linux.c
@@ -399,7 +399,7 @@ pnd_version (char *buf)
}
static void
-pnd_read ()
+pnd_read (void)
{
FILE *fp;
char *buf = NULL;
diff --git a/libinetutils/des_rw.c b/libinetutils/des_rw.c
index c0cf812b..6f1ee07e 100644
--- a/libinetutils/des_rw.c
+++ b/libinetutils/des_rw.c
@@ -83,7 +83,7 @@ int krb_net_read (int, char *, int);
*/
void
-des_clear_key ()
+des_clear_key (void)
{
memset (key, 0, sizeof (C_Block));
memset (key_schedule, 0, sizeof (Key_schedule));
@@ -91,10 +91,7 @@ des_clear_key ()
int
-des_read (fd, buf, len)
- int fd;
- char *buf;
- int len;
+des_read (int fd, char *buf, int len)
{
int nreturned = 0;
long net_len, rd_len;
@@ -171,10 +168,7 @@ des_read (fd, buf, len)
static unsigned char des_outbuf[10240]; /* > longest write */
int
-des_write (fd, buf, len)
- int fd;
- char *buf;
- int len;
+des_write (int fd, char *buf, int len)
{
static int seeded = 0;
static char garbage_buf[8];
diff --git a/libtelnet/auth.c b/libtelnet/auth.c
index 392510ac..935edfe4 100644
--- a/libtelnet/auth.c
+++ b/libtelnet/auth.c
@@ -366,7 +366,7 @@ auth_togdebug (int on)
}
int
-auth_status ()
+auth_status (void)
{
TN_Authenticator *ap;
int i, mask;
@@ -395,7 +395,7 @@ auth_status ()
* negotiation.
*/
void
-auth_request ()
+auth_request (void)
{
static unsigned char str_request[64] = { IAC, SB,
TELOPT_AUTHENTICATION,
@@ -549,7 +549,7 @@ auth_send (unsigned char *data, int cnt)
}
void
-auth_send_retry ()
+auth_send_retry (void)
{
/*
* if auth_send_cnt <= 0 then auth_send will end up rejecting
diff --git a/libtelnet/kerberos5.c b/libtelnet/kerberos5.c
index 4affbe61..40540872 100644
--- a/libtelnet/kerberos5.c
+++ b/libtelnet/kerberos5.c
@@ -127,7 +127,7 @@ kerberos5_init (TN_Authenticator *ap MAYBE_UNUSED, int server)
}
void
-kerberos5_cleanup ()
+kerberos5_cleanup (void)
{
krb5_ccache ccache;
char *ccname;
diff --git a/ping/ping.c b/ping/ping.c
index f9014c7e..6c7dbd9a 100644
--- a/ping/ping.c
+++ b/ping/ping.c
@@ -382,7 +382,7 @@ sig_int (int signal MAYBE_UNUSED)
}
int
-ping_run (PING *ping, int (*finish) ())
+ping_run (PING *ping, int (*finish) (void))
{
fd_set fdset;
int fdmax;
diff --git a/ping/ping6.c b/ping/ping6.c
index b15c513e..9cf03eb1 100644
--- a/ping/ping6.c
+++ b/ping/ping6.c
@@ -325,7 +325,7 @@ sig_int (int signal MAYBE_UNUSED)
}
static int
-ping_run (PING *ping, int (*finish) ())
+ping_run (PING *ping, int (*finish) (void))
{
fd_set fdset;
int fdmax;
diff --git a/ping/ping6.h b/ping/ping6.h
index 3bb8186a..27fc3ac9 100644
--- a/ping/ping6.h
+++ b/ping/ping6.h
@@ -27,5 +27,5 @@ static int ping_set_dest (PING * ping, const char *host);
static int ping_recv (PING * p);
static int ping_xmit (PING * p);
-static int ping_run (PING * ping, int (*finish) ());
+static int ping_run (PING * ping, int (*finish) (void));
static int ping_finish (void);
diff --git a/ping/ping_impl.h b/ping/ping_impl.h
index d44f0b01..8694a887 100644
--- a/ping/ping_impl.h
+++ b/ping/ping_impl.h
@@ -26,7 +26,7 @@ extern PING *ping;
extern unsigned char *data_buffer;
extern size_t data_length;
-extern int ping_run (PING * ping, int (*finish) ());
+extern int ping_run (PING * ping, int (*finish) (void));
extern int ping_finish (void);
extern void print_icmp_header (struct sockaddr_in *from,
struct ip *ip, icmphdr_t * icmp, int len);
diff --git a/src/rcp.c b/src/rcp.c
index 53b87fa4..11b14c44 100644
--- a/src/rcp.c
+++ b/src/rcp.c
@@ -124,7 +124,7 @@ int doencrypt = 0;
# ifdef KERBEROS
CREDENTIALS cred;
Key_schedule schedule;
-extern char *krb_realmofhost ();
+extern char *krb_realmofhost (const char *);
# elif defined SHISHI /* !KERBEROS */
Shishi *h;
diff --git a/telnet/authenc.c b/telnet/authenc.c
index ef7844f9..ec75aeb4 100644
--- a/telnet/authenc.c
+++ b/telnet/authenc.c
@@ -74,7 +74,7 @@ net_write (unsigned char *str, int len)
}
void
-net_encrypt ()
+net_encrypt (void)
{
# ifdef ENCRYPTION
if (encrypt_output)
@@ -85,7 +85,7 @@ net_encrypt ()
}
int
-telnet_spin ()
+telnet_spin (void)
{
return (-1);
}
diff --git a/telnet/commands.c b/telnet/commands.c
index fb1e08c8..01f5b27b 100644
--- a/telnet/commands.c
+++ b/telnet/commands.c
@@ -1023,7 +1023,7 @@ static struct setlist Setlist[] = {
#if defined CRAY && !defined __STDC__
/* Work around compiler bug in pcc 4.1.5 */
void
-_setlist_init ()
+_setlist_init (void)
{
# ifndef KLUDGELINEMODE
# define N 5
@@ -2136,7 +2136,7 @@ struct authlist AuthList[] = {
};
static int
-auth_help ()
+auth_help (void)
{
struct authlist *c;
@@ -2245,7 +2245,7 @@ struct encryptlist EncryptList[] = {
};
static int
-EncryptHelp ()
+EncryptHelp (void)
{
struct encryptlist *c;
@@ -2441,7 +2441,7 @@ status (int argc, char *argv[])
* Function that gets called when SIGINFO is received.
*/
int
-ayt_status ()
+ayt_status (void)
{
call (status, "status", "notmuch", 0);
return 1; /* not used */
diff --git a/telnet/ring.c b/telnet/ring.c
index b2c49ab1..87003e1f 100644
--- a/telnet/ring.c
+++ b/telnet/ring.c
@@ -327,7 +327,7 @@ ring_supply_data (Ring *ring, unsigned char *buffer, int count)
#ifdef ENCRYPTION
void
-ring_encrypt (Ring *ring, void (*encryptor) ())
+ring_encrypt (Ring *ring, void (*encryptor) (unsigned char *, int))
{
unsigned char *s, *c;
diff --git a/telnet/ring.h b/telnet/ring.h
index d1267396..d61a810a 100644
--- a/telnet/ring.h
+++ b/telnet/ring.h
@@ -92,7 +92,8 @@ ring_full_count (Ring * ring), ring_full_consecutive (Ring * ring);
#ifdef ENCRYPTION
extern void
-ring_encrypt (Ring * ring, void (*func) ()), ring_clearto (Ring * ring);
+ring_encrypt (Ring * ring, void (*encryptor) (unsigned char *, int)),
+ring_clearto (Ring * ring);
#endif /* ENCRYPTION */
extern void ring_clear_mark (Ring *);
diff --git a/telnet/sys_bsd.c b/telnet/sys_bsd.c
index a7f69dd8..03d22372 100644
--- a/telnet/sys_bsd.c
+++ b/telnet/sys_bsd.c
@@ -70,8 +70,8 @@
#include "types.h"
#ifdef SIGINFO
-extern void ayt_status ();
-extern void sendayt ();
+extern void ayt_status (void);
+extern void sendayt (void);
#endif
int tout, /* Output file descriptor */
@@ -729,7 +729,7 @@ TerminalNewMode (int f)
else
{
#ifdef SIGINFO
- void ayt_status ();
+ void ayt_status (void);
signal (SIGINFO, ayt_status);
#endif
diff --git a/telnet/tn3270.c b/telnet/tn3270.c
index f745ea02..6e35e90a 100644
--- a/telnet/tn3270.c
+++ b/telnet/tn3270.c
@@ -192,7 +192,7 @@ inputAvailable (int signo)
# endif/* unix || __unix || __unix__ */
void
-outputPurge ()
+outputPurge (void)
{
ttyflush (1);
}
@@ -258,7 +258,7 @@ DataToTerminal (char *buffer, int count)
*/
int
-Push3270 ()
+Push3270 (void)
{
int save = ring_full_count (&netiring);
@@ -288,7 +288,7 @@ Push3270 ()
*/
void
-Finish3270 ()
+Finish3270 (void)
{
while (Push3270 () || !DoTerminalOutput ())
{
@@ -343,7 +343,7 @@ _putchar (char c)
# endif/* ((!defined(NOT43)) || defined(PUTCHAR)) */
void
-SetIn3270 ()
+SetIn3270 (void)
{
if (Sent3270TerminalType && my_want_state_is_will (TELOPT_BINARY)
&& my_want_state_is_do (TELOPT_BINARY) && !donebinarytoggle)
@@ -378,7 +378,7 @@ SetIn3270 ()
*/
int
-tn3270_ttype ()
+tn3270_ttype (void)
{
/*
* Try to send a 3270 type terminal name. Decide which one based
diff --git a/telnetd/state.c b/telnetd/state.c
index ebb745b8..db33bf22 100644
--- a/telnetd/state.c
+++ b/telnetd/state.c
@@ -549,18 +549,18 @@ send_do (int option, int init)
}
#ifdef AUTHENTICATION
-extern void auth_request ();
+extern void auth_request (void);
#endif
extern void doclientstat (void);
#ifdef ENCRYPTION
-extern void encrypt_send_support ();
+extern void encrypt_send_support (void);
#endif /* ENCRYPTION */
void
willoption (int option)
{
int changeok = 0;
- void (*func) () = 0;
+ void (*func) (void) = NULL;
/*
* process input from peer.
diff --git a/telnetd/telnetd.h b/telnetd/telnetd.h
index a8df5f9b..39696cb5 100644
--- a/telnetd/telnetd.h
+++ b/telnetd/telnetd.h
@@ -275,7 +275,7 @@ void netflush (void);
int pty_buffer_is_full (void);
void pty_output_byte (int c);
void pty_output_datalen (const void *data, size_t len);
-int pty_buffer_level ();
+int pty_buffer_level (void);
/* Debugging functions */
extern void printoption (char *, int);
@@ -325,7 +325,7 @@ extern void change_slc (char func, char flag, cc_t val);
extern void cleanup (int);
extern void clientstat (int, int, int);
-extern void copy_termbuf ();
+extern void copy_termbuf (void);
extern void deferslc (void);
extern void defer_terminit (void);
extern void do_opt_slc (unsigned char *, int);
diff --git a/telnetd/term.c b/telnetd/term.c
index 84c9aba7..f53b2810 100644
--- a/telnetd/term.c
+++ b/telnetd/term.c
@@ -40,19 +40,19 @@ _term_setattr (int fd, TERMDESC *tp)
}
void
-term_send_eof ()
+term_send_eof (void)
{
/*nothing */
}
int
-term_change_eof ()
+term_change_eof (void)
{
return 0;
}
int
-tty_linemode ()
+tty_linemode (void)
{
return termbuf.state & TS_EXTPROC;
}
@@ -75,19 +75,19 @@ tty_setlinemode (int on)
}
int
-tty_isecho ()
+tty_isecho (void)
{
return termbuf.sg.sg_flags & ECHO;
}
int
-tty_flowmode ()
+tty_flowmode (void)
{
return ((termbuf.tc.t_startc) > 0 && (termbuf.tc.t_stopc) > 0) ? 1 : 0;
}
int
-tty_restartany ()
+tty_restartany (void)
{
# ifdef DECCTQ
return (termbuf.lflags & DECCTQ) ? 0 : 1;
@@ -106,7 +106,7 @@ tty_setecho (int on)
}
int
-tty_israw ()
+tty_israw (void)
{
return termbuf.sg.sg_flags & RAW;
}
@@ -141,25 +141,25 @@ tty_binaryout (int on)
}
int
-tty_isbinaryin ()
+tty_isbinaryin (void)
{
return termbuf.lflags & LPASS8;
}
int
-tty_isbinaryout ()
+tty_isbinaryout (void)
{
return termbuf.lflags & LLITOUT;
}
int
-tty_isediting ()
+tty_isediting (void)
{
return !(termbuf.sg.sg_flags & (CBREAK | RAW));
}
int
-tty_istrapsig ()
+tty_istrapsig (void)
{
return !(termbuf.sg.sg_flags & RAW);
}
@@ -179,7 +179,7 @@ tty_setsig (int on)
}
int
-tty_issofttab ()
+tty_issofttab (void)
{
return termbuf.sg.sg_flags & XTABS;
}
@@ -194,7 +194,7 @@ tty_setsofttab (int on)
}
int
-tty_islitecho ()
+tty_islitecho (void)
{
return !(termbuf.lflags & LCTLECH);
}
@@ -209,7 +209,7 @@ tty_setlitecho (int on)
}
int
-tty_iscrnl ()
+tty_iscrnl (void)
{
return termbuf.sg.sg_flags & CRMOD;
}
@@ -534,7 +534,7 @@ init_termbuf (void)
/*FIXME: Hardly needed?
* Built by OpenSolaris and BSD, though. */
void
-copy_termbuf ()
+copy_termbuf (void)
{
size_t len = 0;
char *cp = (char *) &termbuf;
diff --git a/telnetd/termstat.c b/telnetd/termstat.c
index b0509d81..e9657905 100644
--- a/telnetd/termstat.c
+++ b/telnetd/termstat.c
@@ -647,13 +647,13 @@ clientstat (int code, int parm1, int parm2)
#if defined CRAY2 && defined UNICOS5
void
-termstat ()
+termstat (void)
{
needtermstat = 1;
}
void
-_termstat ()
+_termstat (void)
{
needtermstat = 0;
init_termbuf ();
diff --git a/telnetd/utility.c b/telnetd/utility.c
index d8ec6f0f..88dc834f 100644
--- a/telnetd/utility.c
+++ b/telnetd/utility.c
@@ -1640,7 +1640,7 @@ net_write (unsigned char *str, int len)
}
void
-net_encrypt ()
+net_encrypt (void)
{
# ifdef ENCRYPTION
char *s = (nclearto > nbackp) ? nclearto : nbackp;
@@ -1651,7 +1651,7 @@ net_encrypt ()
}
int
-telnet_spin ()
+telnet_spin (void)
{
io_drain ();
return 0;
--
2.45.0