[PATCH 1/2] maint: use EXIT_SUCCESS and EXIT_FAILURE, not 0 and 1 to exit

Jim Meyering meyering at redhat.com
Sat Nov 7 15:47:37 UTC 2009


Convert all uses automatically, via these two commands:
git grep -l '\<exit *(1)'|xargs --no-run-if-empty \
  perl -pi -e 's/\b(exit ?)\(1\)/$1(EXIT_FAILURE)/'
git grep -l '\<exit *(0)'|xargs --no-run-if-empty \
  perl -pi -e 's/\b(exit ?)\(0\)/$1(EXIT_SUCCESS)/'
* libparted/fs/fat/table.c (fat_table_get): Use symbolic exit codes.
* libparted/labels/vtoc.c (vtoc_update_format5_label_add): Likewise.
(vtoc_update_format5_label_del): Likewise.
(vtoc_update_format7_label_add): Likewise.
(vtoc_update_format7_label_del): Likewise.
* m4/parted.m4 (PARTED_CHECK_LIBPARTED): Likewise.
* parted/parted.c (do_quit): Likewise.
* parted/strlist.c (gettext_to_wchar, wchar_to_str): Likewise.
* parted/ui.c (reset_env, help_msg, non_interactive_mode): Likewise.
---
 libparted/fs/fat/table.c |    2 +-
 libparted/labels/vtoc.c  |   18 +++++++++---------
 m4/parted.m4             |    4 ++--
 parted/parted.c          |    2 +-
 parted/strlist.c         |    4 ++--
 parted/ui.c              |    6 +++---
 6 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/libparted/fs/fat/table.c b/libparted/fs/fat/table.c
index 6ef208d..284250e 100644
--- a/libparted/fs/fat/table.c
+++ b/libparted/fs/fat/table.c
@@ -300,7 +300,7 @@ fat_table_get (const FatTable* ft, FatCluster cluster)
 				     _("fat_table_get: cluster %ld outside "
 				       "file system"),
 				     (long) cluster);
-		exit (1);	/* FIXME */
+		exit (EXIT_FAILURE);	/* FIXME */
 	}

 	switch (ft->fat_type) {
diff --git a/libparted/labels/vtoc.c b/libparted/labels/vtoc.c
index bdcb9f4..35b26e1 100644
--- a/libparted/labels/vtoc.c
+++ b/libparted/labels/vtoc.c
@@ -732,7 +732,7 @@ vtoc_update_format5_label_add (format5_label_t *f5, int verbose, int cyl,
 		{
 			puts ("BUG: overlapping free space extents "
 			      "in FMT5 DSCB!\nexiting...");
-			exit(1);
+			exit(EXIT_FAILURE);
 		}

 		if ((ext->t + ext->fc + ext->ft) == 0x0000) {
@@ -749,7 +749,7 @@ vtoc_update_format5_label_add (format5_label_t *f5, int verbose, int cyl,
 	if (tmp == NULL) {
 		/* BUG: no free extent found */
 		puts ("BUG: no free FMT5 DSCB extent found!\nexiting...");
-		exit(1);
+		exit(EXIT_FAILURE);
 	}

 	for (i=0; i<26; i++) {
@@ -895,7 +895,7 @@ vtoc_update_format5_label_del (format5_label_t *f5, int verbose, int cyl,
 			puts ("BUG: corresponding free space extent "
 			      "doesn't match free space currently shown "
 			      "in FMT5 DSCB!\nexiting...");
-			exit(1);
+			exit(EXIT_FAILURE);
 		}

 		if ((a > ext->t) && (a < ext->t + ext->fc*trk + ext->ft)
@@ -905,7 +905,7 @@ vtoc_update_format5_label_del (format5_label_t *f5, int verbose, int cyl,
 			      "deleting doesn't match free space "
 			      "currently shown in FMT5 DSCB!\n"
 			      "exiting...");
-			exit(1);
+			exit(EXIT_FAILURE);
 		}
 	}

@@ -915,7 +915,7 @@ vtoc_update_format5_label_del (format5_label_t *f5, int verbose, int cyl,
 	puts ("BUG: specified free space extent for "
 	      "deleting not found in FMT5 DSCB!\n"
 	      "exiting...");
-	exit(1);
+	exit(EXIT_FAILURE);
 }

 /*
@@ -976,7 +976,7 @@ vtoc_update_format7_label_add (format7_label_t *f7, int verbose,
 		{
 			puts ("BUG: overlapping free space extents "
 			      "in FMT7 DSCB!\nexiting...");
-			exit(1);
+			exit(EXIT_FAILURE);
 		}

 		if ((ext->a + ext->b) == 0x00000000) {
@@ -994,7 +994,7 @@ vtoc_update_format7_label_add (format7_label_t *f7, int verbose,
 	if (tmp == NULL) {
 		/* BUG: no free extent found */
 		puts ("BUG: no free FMT7 DSCB extent found!\nexiting...");
-		exit(1);
+		exit(EXIT_FAILURE);
 	}

 	for (i=0; i<16; i++) {
@@ -1102,7 +1102,7 @@ vtoc_update_format7_label_del (format7_label_t *f7, int verbose,
                               "doesn't match free space currently shown in "
                               "FMT7 DSCB!\nexiting...");
 			printf ("%d %d %d %d\n", a, b, ext->a, ext->b);
-			exit(1);
+			exit(EXIT_FAILURE);
 		}
 	}

@@ -1112,7 +1112,7 @@ vtoc_update_format7_label_del (format7_label_t *f7, int verbose,
 	puts ("BUG: specified free space extent for "
 	      "deleting not found in FMT7 DSCB!\n"
 	      "exiting...");
-	exit(1);
+	exit(EXIT_FAILURE);
 }

 void
diff --git a/m4/parted.m4 b/m4/parted.m4
index 3f6e2e3..0dc7a7e 100644
--- a/m4/parted.m4
+++ b/m4/parted.m4
@@ -73,10 +73,10 @@ int main ()
 	const char	*version;

 	if ( !(version = ped_get_version ()) )
-		exit(1);
+		exit(EXIT_FAILURE);
 	if (sscanf(version, "%d.%d.%d", &major, &minor, &micro) != 3) {
 		printf("%s, bad version string\n", version);
-		exit(1);
+		exit(EXIT_FAILURE);
 	}

 	if ((major > $parted_config_major_version) ||
diff --git a/parted/parted.c b/parted/parted.c
index bc55bc9..d9c4333 100644
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -1616,7 +1616,7 @@ static int
 do_quit (PedDevice** dev)
 {
         _done (*dev);
-        exit (0);
+        exit (EXIT_SUCCESS);
 }

 static PedPartitionType
diff --git a/parted/strlist.c b/parted/strlist.c
index 4d173a9..5a9053a 100644
--- a/parted/strlist.c
+++ b/parted/strlist.c
@@ -128,7 +128,7 @@ gettext_to_wchar (const char* str)

 error:
 	printf ("Error during translation: %s\n", strerror (errno));
-	exit (1);
+	exit (EXIT_FAILURE);
 }

 #else /* ENABLE_NLS */
@@ -177,7 +177,7 @@ wchar_to_str (const wchar_t* str, size_t count)

 error:
 	printf ("Error during translation: %s\n", strerror (errno));
-	exit (1);
+	exit (EXIT_FAILURE);
 }

 #else /* ENABLE_NLS */
diff --git a/parted/ui.c b/parted/ui.c
index c63df8a..58fb80c 100644
--- a/parted/ui.c
+++ b/parted/ui.c
@@ -314,7 +314,7 @@ reset_env (int quit)
         if (in_readline) {
                 putchar ('\n');
                 if (quit)
-                        exit (0);
+                        exit (EXIT_SUCCESS);

                 siglongjmp (readline_state.jmp_state, 1);
         }
@@ -1471,7 +1471,7 @@ help_msg ()
         fputs (_("COMMANDs:"), stdout);
         putchar ('\n');
         print_commands_help ();
-        exit (0);
+        exit (EXIT_SUCCESS);
 }

 void
@@ -1553,7 +1553,7 @@ non_interactive_mode (PedDevice** dev, Command* cmd_list[],
                 if (!(cmd->non_interactive)) {
                         fputs(_("This command does not make sense in "
                                 "non-interactive mode.\n"), stdout);
-                        exit(1);
+                        exit(EXIT_FAILURE);
                         goto error;
                 }

--
1.6.5.2.303.g13162




More information about the parted-devel mailing list