From e5a9384c928f853eefba28435d63cb8337d30b13 Mon Sep 17 00:00:00 2001 From: Collin Funk Date: Wed, 8 May 2024 20:20:18 -0700 Subject: [PATCH 1/2] maint: Remove unnecessary standard library extern function decls. * ftp/cmds.c (account, user): Don't declare getpass since it is defined in unistd.h. * ftp/ftp.c (login): Likewise. Don't declare fclose and pclose since they are defined in stdio.h. * ftpd/extern.h: Don't declare getusershell since it is defined in unistd.h. * ftpd/ftpd.c: Don't declare fclose since it is defined in stdio.h. * libinetutils/logwtmp.c: Don't declare errno since it is defined in errno.h. * libtelnet/misc.c (auth_encrypt_user): Include string.h and don't declare strdup. * telnet/authenc.c (telnet_gets): Don't declare getpass since it is defined in unistd.h. * telnet/commands.c (hostname): Use NULL instead of 0. (env_init, shell): Include string.h and don't redeclare functions. --- ftp/cmds.c | 6 ------ ftp/ftp.c | 13 ------------- ftpd/extern.h | 4 +--- ftpd/ftpd.c | 5 ----- libinetutils/logwtmp.c | 4 ---- libtelnet/misc.c | 3 +-- telnet/authenc.c | 3 --- telnet/commands.c | 11 ++--------- 8 files changed, 4 insertions(+), 45 deletions(-) diff --git a/ftp/cmds.c b/ftp/cmds.c index bc315f2a..7d794716 100644 --- a/ftp/cmds.c +++ b/ftp/cmds.c @@ -1719,9 +1719,6 @@ shell (int argc, char **argv MAYBE_UNUSED) void user (int argc, char **argv) { -#if !HAVE_DECL_GETPASS - extern char *getpass (); -#endif char acct[80]; int n, aflag = 0; @@ -2071,9 +2068,6 @@ globulize (char *cp) void account (int argc, char **argv) { -#if !HAVE_DECL_GETPASS - extern char *getpass (); -#endif char acct[50], *ap; if (argc > 1) diff --git a/ftp/ftp.c b/ftp/ftp.c index 74232afc..3f6e9c7b 100644 --- a/ftp/ftp.c +++ b/ftp/ftp.c @@ -90,16 +90,6 @@ #include "ftp_var.h" #include "attribute.h" -#if !HAVE_DECL_FCLOSE -/* Some systems don't declare fclose in , so do it ourselves. */ -extern int fclose (FILE *); -#endif - -#if !HAVE_DECL_PCLOSE -/* Some systems don't declare pclose in , so do it ourselves. */ -extern int pclose (FILE *); -#endif - int data = -1; int abrtflag = 0; jmp_buf ptabort; @@ -295,9 +285,6 @@ bad: int login (char *host) { -#if !HAVE_DECL_GETPASS - extern char *getpass (); -#endif char tmp[80]; char *user, *pass, *acct, *p; int n, aflag = 0; diff --git a/ftpd/extern.h b/ftpd/extern.h index f0701583..41d7be28 100644 --- a/ftpd/extern.h +++ b/ftpd/extern.h @@ -46,6 +46,7 @@ */ #include +#include #include #include #include @@ -60,9 +61,6 @@ extern void dologout (int); extern void fatal (const char *); extern int ftpd_pclose (FILE *); extern FILE *ftpd_popen (char *, const char *); -#if !HAVE_DECL_GETUSERSHELL -extern char *getusershell (void); -#endif extern void lreply (int, const char *, ...); extern void lreply_multiline (int n, const char *text); extern void makedir (const char *); diff --git a/ftpd/ftpd.c b/ftpd/ftpd.c index d225f191..9fc9a241 100644 --- a/ftpd/ftpd.c +++ b/ftpd/ftpd.c @@ -115,11 +115,6 @@ # define MAP_FAILED (void*)-1 #endif -#if !HAVE_DECL_FCLOSE -/* Some systems don't declare fclose in , so do it ourselves. */ -extern int fclose (FILE *); -#endif - /* Exported to ftpcmd.h. */ struct sockaddr_storage data_dest; /* Data port. */ socklen_t data_dest_len; diff --git a/libinetutils/logwtmp.c b/libinetutils/logwtmp.c index 9929cd38..5d875f25 100644 --- a/libinetutils/logwtmp.c +++ b/libinetutils/logwtmp.c @@ -44,10 +44,6 @@ #endif #include -#if !HAVE_DECL_ERRNO -extern int errno; -#endif - #ifdef HAVE_UTMPX_H static void _logwtmp (struct utmpx *ut) diff --git a/libtelnet/misc.c b/libtelnet/misc.c index be27e6d4..e1a4d8e3 100644 --- a/libtelnet/misc.c +++ b/libtelnet/misc.c @@ -47,6 +47,7 @@ #include #include +#include #include #include @@ -81,8 +82,6 @@ auth_encrypt_init (char *local, char *remote, char *principal, void auth_encrypt_user (char *name) { - extern char *strdup (const char *); - free (UserNameRequested); UserNameRequested = name ? strdup (name) : NULL; } diff --git a/telnet/authenc.c b/telnet/authenc.c index 26773531..ef7844f9 100644 --- a/telnet/authenc.c +++ b/telnet/authenc.c @@ -99,9 +99,6 @@ telnet_getenv (char *val) char * telnet_gets (char *prompt, char *result, int length, int echo) { -# if !HAVE_DECL_GETPASS - extern char *getpass (); -# endif extern int globalmode; int om = globalmode; char *res; diff --git a/telnet/commands.c b/telnet/commands.c index 2212c7f3..8652ecb1 100644 --- a/telnet/commands.c +++ b/telnet/commands.c @@ -68,6 +68,7 @@ #include #include +#include #include /* LLONG_MAX for Solaris. */ #include @@ -114,9 +115,7 @@ # include #endif -char *hostname = 0; - -extern char *getenv (const char *); +char *hostname = NULL; extern int isprefix (register const char *s1, register const char *s2); extern char **genget (const char *, char **, int); @@ -1605,9 +1604,6 @@ shell (int argc, MAYBE_UNUSED char *argv[]) * Fire up the shell in the child. */ register char *shellp, *shellname; -# ifndef strrchr - extern char *strrchr (const char *, int); -# endif shellp = getenv ("SHELL"); if (shellp == NULL) @@ -1889,9 +1885,6 @@ env_init (void) { register char **epp, *cp; register struct env_lst *ep; -#ifndef strchr - extern char *strchr (const char *, int); -#endif for (epp = environ; *epp; epp++) { -- 2.45.0