Subject: bin/2244: Several utilites and daemons misdeclare main.
To: None <gnats-bugs@NetBSD.ORG>
From: Peter Seebach <seebs@taniemarie.solon.com>
List: netbsd-bugs
Date: 03/21/1996 06:45:12
>Number:         2244
>Category:       bin
>Synopsis:       No one reads the FAQ anymore.
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Mar 21 08:05:01 1996
>Last-Modified:
>Originator:     Peter Seebach
>Organization:
Usenet Fact Police (Undercover)
>Release:        Mar 8, 1996
>Environment:
System: NetBSD taniemarie 1.1A NetBSD 1.1A (SEEBS) #0: Sat Mar 9 11:19:31 CST 1996 seebs@taniemarie:/usr/src/sys/arch/amiga/compile/SEEBS amiga


>Description:
	Many of our utilites declare main to return void.  This is
incorrect.

>How-To-Repeat:
	Fix gcc to warn for it, build, watch for warnings.

>Fix:

WARNING:  This patch becomes a much higher priority if the related
standards/2236 (?) bug gets accepted; without this, and with -Werror,
nothing compiles.  Well, not nothing; just nothing patched here.

The enclosed patch gets all but part of bootp.  It's easy enough; replace
void with int.  (ANSI does not require that you return a meaningful value,
merely that main be declared as having a return type of int.)

*** /usr/src/sbin/fsdb/fsdb.old	Thu Mar 21 06:20:44 1996
--- /usr/src/sbin/fsdb/fsdb.c	Thu Mar 21 06:20:59 1996
***************
*** 82,88 ****
   * fsreadfd is set up to read from the file system, fswritefd to write to
   * the file system.
   */
! void
  main(argc, argv)
  	int argc;
  	char *argv[];
--- 82,88 ----
   * fsreadfd is set up to read from the file system, fswritefd to write to
   * the file system.
   */
! int
  main(argc, argv)
  	int argc;
  	char *argv[];
*** /usr/src/usr.bin/gencat/gencat.old	Thu Mar 21 06:22:03 1996
--- /usr/src/usr.bin/gencat/gencat.c	Thu Mar 21 06:22:14 1996
***************
*** 80,86 ****
      fprintf(stderr, "            catfile msgfile [-h <header-file>]...\n");
  }
  
! void main(
  #if ANSI_C || defined(__cplusplus)
  		int argc, char *argv[])
  #else
--- 80,86 ----
      fprintf(stderr, "            catfile msgfile [-h <header-file>]...\n");
  }
  
! int main(
  #if ANSI_C || defined(__cplusplus)
  		int argc, char *argv[])
  #else
*** /usr/src/usr.bin/rusers/rusers.old	Thu Mar 21 06:22:51 1996
--- /usr/src/usr.bin/rusers/rusers.c	Thu Mar 21 06:23:07 1996
***************
*** 230,236 ****
  	exit(1);
  }
  
! void main(int argc, char *argv[])
  {
  	int ch;
  	extern int optind;
--- 230,236 ----
  	exit(1);
  }
  
! int main(int argc, char *argv[])
  {
  	int ch;
  	extern int optind;
*** /usr/src/usr.bin/systat/main.old	Thu Mar 21 06:23:47 1996
--- /usr/src/usr.bin/systat/main.c	Thu Mar 21 06:23:54 1996
***************
*** 82,88 ****
  
  static	WINDOW *wload;			/* one line window for load average */
  
! void
  main(argc, argv)
  	int argc;
  	char **argv;
--- 82,88 ----
  
  static	WINDOW *wload;			/* one line window for load average */
  
! int
  main(argc, argv)
  	int argc;
  	char **argv;
*** /usr/src/usr.bin/units/units.old	Thu Mar 21 06:24:46 1996
--- /usr/src/usr.bin/units/units.c	Thu Mar 21 06:24:57 1996
***************
*** 625,631 ****
  }
  
  
! void 
  main(int argc, char **argv)
  {
  
--- 625,631 ----
  }
  
  
! int
  main(int argc, char **argv)
  {
  
*** /usr/src/usr.bin/vgrind/vfontedpr.old	Thu Mar 21 06:25:46 1996
--- /usr/src/usr.bin/vgrind/vfontedpr.c	Thu Mar 21 06:25:59 1996
***************
*** 130,136 ****
  
  #define	ps(x)	printf("%s", x)
  
! void
  main(argc, argv)
      int argc;
      char *argv[];
--- 130,136 ----
  
  #define	ps(x)	printf("%s", x)
  
! int
  main(argc, argv)
      int argc;
      char *argv[];
*** /usr/src/usr.sbin/bootpd/bootpd.old	Thu Mar 21 06:26:35 1996
--- /usr/src/usr.sbin/bootpd/bootpd.c	Thu Mar 21 06:26:42 1996
***************
*** 185,191 ****
   * main server loop is started.
   */
  
! void
  main(argc, argv)
  	int argc;
  	char **argv;
--- 185,191 ----
   * main server loop is started.
   */
  
! int
  main(argc, argv)
  	int argc;
  	char **argv;
*** /usr/src/usr.sbin/lpr/lpr/lpr.old	Thu Mar 21 06:30:48 1996
--- /usr/src/usr.sbin/lpr/lpr/lpr.c	Thu Mar 21 06:30:53 1996
***************
*** 113,119 ****
  
  uid_t	uid, euid;
  
! void
  main(argc, argv)
  	int argc;
  	char *argv[];
--- 113,119 ----
  
  uid_t	uid, euid;
  
! int
  main(argc, argv)
  	int argc;
  	char *argv[];
*** /usr/src/usr.sbin/lpr/lptest/lptest.old	Thu Mar 21 06:31:23 1996
--- /usr/src/usr.sbin/lpr/lptest/lptest.c	Thu Mar 21 06:31:29 1996
***************
*** 49,55 ****
  /*
   * lptest -- line printer test program (and other devices).
   */
! void
  main(argc, argv)
  	int argc;
  	char **argv;
--- 49,55 ----
  /*
   * lptest -- line printer test program (and other devices).
   */
! int
  main(argc, argv)
  	int argc;
  	char **argv;
*** /usr/src/usr.sbin/lpr/pac/pac.old	Thu Mar 21 06:31:52 1996
--- /usr/src/usr.sbin/lpr/pac/pac.c	Thu Mar 21 06:31:56 1996
***************
*** 101,107 ****
  static int	qucmp __P((const void *, const void *));
  static void	rewrite __P((void));
  
! void
  main(argc, argv)
  	int argc;
  	char **argv;
--- 101,107 ----
  static int	qucmp __P((const void *, const void *));
  static void	rewrite __P((void));
  
! int
  main(argc, argv)
  	int argc;
  	char **argv;
*** /usr/src/usr.sbin/named/named/ns_main.old	Thu Mar 21 06:33:26 1996
--- /usr/src/usr.sbin/named/named/ns_main.c	Thu Mar 21 06:33:28 1996
***************
*** 159,165 ****
  }
  
  /*ARGSUSED*/
! void
  main(argc, argv, envp)
  	int argc;
  	char *argv[], *envp[];
--- 159,165 ----
  }
  
  /*ARGSUSED*/
! int
  main(argc, argv, envp)
  	int argc;
  	char *argv[], *envp[];
*** /usr/src/usr.sbin/named/named-xfer/named-xfer.old	Thu Mar 21 06:34:06 1996
--- /usr/src/usr.sbin/named/named-xfer/named-xfer.c	Thu Mar 21 06:34:17 1996
***************
*** 139,145 ****
  extern char *optarg;
  extern int optind, getopt();
  
! void
  main(argc, argv)
  	int argc;
  	char *argv[];
--- 139,145 ----
  extern char *optarg;
  extern int optind, getopt();
  
! int
  main(argc, argv)
  	int argc;
  	char *argv[];
*** /usr/src/usr.sbin/pppd/main.old	Thu Mar 21 06:35:19 1996
--- /usr/src/usr.sbin/pppd/main.c	Thu Mar 21 06:35:26 1996
***************
*** 137,143 ****
      NULL
  };
  
! void
  main(argc, argv)
      int argc;
      char *argv[];
--- 137,143 ----
      NULL
  };
  
! int
  main(argc, argv)
      int argc;
      char *argv[];
*** /usr/src/usr.sbin/rarpd/rarpd.old	Thu Mar 21 06:36:06 1996
--- /usr/src/usr.sbin/rarpd/rarpd.c	Thu Mar 21 06:36:14 1996
***************
*** 101,107 ****
  int     dflag = 0;		/* print debugging messages */
  int     fflag = 0;		/* don't fork */
  
! void
  main(argc, argv)
  	int     argc;
  	char  **argv;
--- 101,107 ----
  int     dflag = 0;		/* print debugging messages */
  int     fflag = 0;		/* don't fork */
  
! int
  main(argc, argv)
  	int     argc;
  	char  **argv;
*** /usr/src/games/arithmetic/arithmetic.old	Thu Mar 21 06:36:54 1996
--- /usr/src/games/arithmetic/arithmetic.c	Thu Mar 21 06:37:13 1996
***************
*** 101,107 ****
   * bound is 10.  After every NQUESTS questions, statistics on the performance
   * so far are printed.
   */
! void
  main(argc, argv)
  	int argc;
  	char **argv;
--- 101,107 ----
   * bound is 10.  After every NQUESTS questions, statistics on the performance
   * so far are printed.
   */
! int
  main(argc, argv)
  	int argc;
  	char **argv;
*** /usr/src/gnu/usr.bin/cpio/main.old	Thu Mar 21 06:37:48 1996
--- /usr/src/gnu/usr.bin/cpio/main.c	Thu Mar 21 06:38:55 1996
***************
*** 450,456 ****
    bzero (zeros_512, 512);
  }
  
! void
  main (argc, argv)
       int argc;
       char *argv[];
--- 450,456 ----
    bzero (zeros_512, 512);
  }
  
! int
  main (argc, argv)
       int argc;
       char *argv[];
*** /usr/src/gnu/usr.bin/sort/sort.old	Thu Mar 21 06:40:04 1996
--- /usr/src/gnu/usr.bin/sort/sort.c	Thu Mar 21 06:40:09 1996
***************
*** 1451,1457 ****
    return s;
  }
  
! void
  main (argc, argv)
       int argc;
       char *argv[];
--- 1451,1457 ----
    return s;
  }
  
! int
  main (argc, argv)
       int argc;
       char *argv[];
*** /usr/src/gnu/usr.bin/tar/tar.old	Thu Mar 21 06:40:51 1996
--- /usr/src/gnu/usr.bin/tar/tar.c	Thu Mar 21 06:40:56 1996
***************
*** 194,200 ****
  /*
   * Main routine for tar.
   */
! void
  main (argc, argv)
       int argc;
       char **argv;
--- 194,200 ----
  /*
   * Main routine for tar.
   */
! int
  main (argc, argv)
       int argc;
       char **argv;
>Audit-Trail:
>Unformatted: