mirror of
git://git.sv.gnu.org/findutils.git
synced 2026-01-28 04:23:21 +01:00
Avoid use of exit() within main, to silence warnings about unreachable code
This commit is contained in:
@@ -30,9 +30,9 @@
|
||||
#else
|
||||
#include <sys/file.h>
|
||||
#endif
|
||||
#include <human.h>
|
||||
#include "../gnulib/lib/human.h"
|
||||
#include <modetype.h>
|
||||
#include <savedir.h>
|
||||
#include "../gnulib/lib/savedir.h"
|
||||
|
||||
#ifdef HAVE_LOCALE_H
|
||||
#include <locale.h>
|
||||
@@ -316,7 +316,7 @@ main (int argc, char **argv)
|
||||
if (i == 1)
|
||||
process_top_path (".");
|
||||
|
||||
exit (exit_status);
|
||||
return exit_status;
|
||||
}
|
||||
|
||||
/* Safely go back to the starting directory. */
|
||||
|
||||
@@ -118,5 +118,5 @@ main (int argc, char **argv)
|
||||
free (path);
|
||||
free (oldpath);
|
||||
|
||||
exit (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ main (int argc, char **argv)
|
||||
{
|
||||
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 @@ main (int argc, char **argv)
|
||||
{
|
||||
fprintf (stderr, "%s: ", argv[0]);
|
||||
perror (argv[1]);
|
||||
exit (1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
pathsize = oldpathsize = 1026; /* Increased as necessary by getline. */
|
||||
@@ -229,5 +229,5 @@ main (int argc, char **argv)
|
||||
free (path);
|
||||
free (oldpath);
|
||||
|
||||
exit (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -171,5 +171,5 @@ main (int argc, char **argv)
|
||||
free (path);
|
||||
free (oldpath);
|
||||
|
||||
exit (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -465,16 +465,14 @@ extern char *version_string;
|
||||
char *program_name;
|
||||
|
||||
static void
|
||||
usage (stream, status)
|
||||
usage (stream)
|
||||
FILE *stream;
|
||||
int status;
|
||||
{
|
||||
fprintf (stream, _("\
|
||||
Usage: %s [-d path | --database=path] [-e | --existing]\n\
|
||||
[-i | --ignore-case] [--version] [--help] pattern...\n"),
|
||||
program_name);
|
||||
fputs (_("\nReport bugs to <bug-findutils@gnu.org>.\n"), stream);
|
||||
exit (status);
|
||||
}
|
||||
|
||||
static struct option const longopts[] =
|
||||
@@ -528,18 +526,24 @@ main (argc, argv)
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
usage (stdout, 0);
|
||||
usage (stdout);
|
||||
return 0;
|
||||
|
||||
case 'v':
|
||||
printf (_("GNU locate version %s\n"), version_string);
|
||||
exit (0);
|
||||
return 0;
|
||||
|
||||
default:
|
||||
usage (stderr, 1);
|
||||
usage (stderr);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (optind == argc)
|
||||
usage (stderr, 1);
|
||||
{
|
||||
usage (stderr);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
for (; optind < argc; optind++)
|
||||
{
|
||||
@@ -549,5 +553,8 @@ main (argc, argv)
|
||||
found |= locate (argv[optind], e, ignore_case);
|
||||
}
|
||||
|
||||
exit (!found);
|
||||
if (found)
|
||||
return 0;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -295,7 +295,7 @@ static void add_proc PARAMS ((pid_t pid));
|
||||
static void wait_for_proc PARAMS ((boolean all));
|
||||
static long parse_num PARAMS ((char *str, int option, long min, long max));
|
||||
static long env_size PARAMS ((char **envp));
|
||||
static void usage PARAMS ((FILE * stream, int status));
|
||||
static void usage PARAMS ((FILE * stream));
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
@@ -347,7 +347,8 @@ main (int argc, char **argv)
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
usage (stdout, 0);
|
||||
usage (stdout);
|
||||
return 0;
|
||||
|
||||
case 'i':
|
||||
if (optarg)
|
||||
@@ -407,10 +408,11 @@ main (int argc, char **argv)
|
||||
|
||||
case 'v':
|
||||
printf (_("GNU xargs version %s\n"), version_string);
|
||||
exit (0);
|
||||
return 0;
|
||||
|
||||
default:
|
||||
usage (stderr, 1);
|
||||
usage (stderr);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -483,7 +485,7 @@ main (int argc, char **argv)
|
||||
}
|
||||
|
||||
wait_for_proc (true);
|
||||
exit (child_error);
|
||||
return child_error;
|
||||
}
|
||||
|
||||
#if 0
|
||||
@@ -943,6 +945,7 @@ do_exec (void)
|
||||
execvp (cmd_argv[0], cmd_argv);
|
||||
error (0, errno, "%s", cmd_argv[0]);
|
||||
_exit (errno == ENOENT ? 127 : 126);
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
add_proc (child);
|
||||
}
|
||||
@@ -1044,19 +1047,22 @@ parse_num (char *str, int option, long int min, long int max)
|
||||
{
|
||||
fprintf (stderr, _("%s: invalid number for -%c option\n"),
|
||||
program_name, option);
|
||||
usage (stderr, 1);
|
||||
usage (stderr);
|
||||
exit(1);
|
||||
}
|
||||
else if (val < min)
|
||||
{
|
||||
fprintf (stderr, _("%s: value for -%c option must be >= %ld\n"),
|
||||
program_name, option, min);
|
||||
usage (stderr, 1);
|
||||
usage (stderr);
|
||||
exit(1);
|
||||
}
|
||||
else if (max >= 0 && val > max)
|
||||
{
|
||||
fprintf (stderr, _("%s: value for -%c option must be < %ld\n"),
|
||||
program_name, option, max);
|
||||
usage (stderr, 1);
|
||||
usage (stderr);
|
||||
exit(1);
|
||||
}
|
||||
return val;
|
||||
}
|
||||
@@ -1075,7 +1081,7 @@ env_size (char **envp)
|
||||
}
|
||||
|
||||
static void
|
||||
usage (FILE *stream, int status)
|
||||
usage (FILE *stream)
|
||||
{
|
||||
fprintf (stream, _("\
|
||||
Usage: %s [-0prtx] [-e[eof-str]] [-i[replace-str]] [-l[max-lines]]\n\
|
||||
@@ -1086,5 +1092,4 @@ Usage: %s [-0prtx] [-e[eof-str]] [-i[replace-str]] [-l[max-lines]]\n\
|
||||
[command [initial-arguments]]\n"),
|
||||
program_name);
|
||||
fputs (_("\nReport bugs to <bug-findutils@gnu.org>.\n"), stream);
|
||||
exit (status);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user