bug-findutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Use 'return' from main() instead of calling exit()


From: Petter Reinholdtsen
Subject: [PATCH] Use 'return' from main() instead of calling exit()
Date: Fri, 22 Oct 2004 13:30:33 +0200

Hi.

Here is a patch for findutils 4.1.20 to avoid warnings from the
compiler about unreachable code.  It changes all calls to exit() in
main() to use the 'return' statement instead.  Please include in a
future version of findutils.

This version (with the patch) compiled out of the box on RedHat EL 2.1
and 3 for i386, RHEL 3 for ia64, Mac OS X, AIX 5.1, Irix 6.5 and
finally Solaris 7 and 8.

It failed to compile on HP-UX 11.23 for ia64.  I'll get back to you
with patches for this one.

Good work. :)

diff -ur src-4.1.20/find/find.c src-4.1.20-local/find/find.c
--- src-4.1.20/find/find.c      2003-05-24 20:36:25.000000000 +0200
+++ src-4.1.20-local/find/find.c        2004-10-22 13:04:36.000000000 +0200
@@ -287,7 +287,7 @@
   if (i == 1)
     process_top_path (".");
 
-  exit (exit_status);
+  return (exit_status);
 }
 
 /* Safely go back to the starting directory. */
diff -ur src-4.1.20/locate/bigram.c src-4.1.20-local/locate/bigram.c
--- src-4.1.20/locate/bigram.c  2003-05-26 15:38:38.000000000 +0200
+++ src-4.1.20-local/locate/bigram.c    2004-10-22 13:06:33.000000000 +0200
@@ -118,5 +118,5 @@
   free (path);
   free (oldpath);
 
-  exit (0);
+  return (0);
 }
diff -ur src-4.1.20/locate/code.c src-4.1.20-local/locate/code.c
--- src-4.1.20/locate/code.c    2003-05-26 15:39:32.000000000 +0200
+++ src-4.1.20-local/locate/code.c      2004-10-22 13:07:06.000000000 +0200
@@ -144,7 +144,7 @@
     {
       fprintf (stderr, _("Usage: %s most_common_bigrams < list > 
coded_list\n"),
               argv[0]);
-      exit (2);
+      return (2);
     }
 
   fp = fopen (argv[1], "r");
@@ -152,7 +152,7 @@
     {
       fprintf (stderr, "%s: ", argv[0]);
       perror (argv[1]);
-      exit (1);
+      return (1);
     }
 
   pathsize = oldpathsize = 1026; /* Increased as necessary by getline.  */
@@ -229,5 +229,5 @@
   free (path);
   free (oldpath);
 
-  exit (0);
+  return (0);
 }
diff -ur src-4.1.20/locate/frcode.c src-4.1.20-local/locate/frcode.c
--- src-4.1.20/locate/frcode.c  2003-05-26 15:38:30.000000000 +0200
+++ src-4.1.20-local/locate/frcode.c    2004-10-22 13:07:32.000000000 +0200
@@ -171,5 +171,5 @@
   free (path);
   free (oldpath);
 
-  exit (0);
+  return (0);
 }
diff -ur src-4.1.20/locate/locate.c src-4.1.20-local/locate/locate.c
--- src-4.1.20/locate/locate.c  2003-05-26 15:39:54.000000000 +0200
+++ src-4.1.20-local/locate/locate.c    2004-10-22 13:08:12.000000000 +0200
@@ -541,7 +541,7 @@
 
       case 'v':
        printf (_("GNU locate version %s\n"), version_string);
-       exit (0);
+       return (0);
 
       default:
        usage (stderr, 1);
@@ -558,5 +558,5 @@
        found |= locate (argv[optind], e, ignore_case);
     }
 
-  exit (!found);
+  return (!found);
 }
diff -ur src-4.1.20/xargs/xargs.c src-4.1.20-local/xargs/xargs.c
--- src-4.1.20/xargs/xargs.c    2003-05-26 15:39:14.000000000 +0200
+++ src-4.1.20-local/xargs/xargs.c      2004-10-22 13:09:31.000000000 +0200
@@ -381,7 +381,7 @@
 
        case 'v':
          printf (_("GNU xargs version %s\n"), version_string);
-         exit (0);
+         return (0);
 
        default:
          usage (stderr, 1);
@@ -446,7 +446,7 @@
     }
 
   wait_for_proc (true);
-  exit (child_error);
+  return (child_error);
 }
 
 /* Read a line of arguments from stdin and add them to the list of




reply via email to

[Prev in Thread] Current Thread [Next in Thread]