Remove magic argument numbers to exit(2)

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
Giuseppe Scrivano 2015-01-30 15:12:43 +01:00
parent ea4683ba06
commit e8cbd4b8c5
5 changed files with 20 additions and 21 deletions

1
cfg.mk
View File

@ -21,7 +21,6 @@ local-checks-to-skip = \
sc_program_name \ sc_program_name \
sc_bindtextdomain \ sc_bindtextdomain \
sc_prohibit_empty_lines_at_EOF \ sc_prohibit_empty_lines_at_EOF \
sc_prohibit_magic_number_exit \
sc_prohibit_path_max_allocation \ sc_prohibit_path_max_allocation \
sc_prohibit_test_double_equal \ sc_prohibit_test_double_equal \
sc_space_tab \ sc_space_tab \

View File

@ -126,7 +126,7 @@ void
ot_util_fatal_literal (const char *msg) ot_util_fatal_literal (const char *msg)
{ {
g_printerr ("%s\n", msg); g_printerr ("%s\n", msg);
exit (1); exit (EXIT_FAILURE);
} }
void void

View File

@ -83,7 +83,7 @@ import_one_object_thread (gpointer object,
if (local_error != NULL) if (local_error != NULL)
{ {
g_printerr ("%s\n", local_error->message); g_printerr ("%s\n", local_error->message);
exit (1); exit (EXIT_FAILURE);
} }
} }

View File

@ -123,7 +123,7 @@ main(int argc, char *argv[])
if (argc < 2) if (argc < 2)
{ {
fprintf (stderr, "usage: ostree-prepare-root SYSROOT\n"); fprintf (stderr, "usage: ostree-prepare-root SYSROOT\n");
exit (1); exit (EXIT_FAILURE);
} }
root_mountpoint = argv[1]; root_mountpoint = argv[1];
@ -132,7 +132,7 @@ main(int argc, char *argv[])
if (!ostree_target) if (!ostree_target)
{ {
fprintf (stderr, "No OSTree target; expected ostree=/ostree/boot.N/...\n"); fprintf (stderr, "No OSTree target; expected ostree=/ostree/boot.N/...\n");
exit (1); exit (EXIT_FAILURE);
} }
snprintf (destpath, sizeof(destpath), "%s/%s", root_mountpoint, ostree_target); snprintf (destpath, sizeof(destpath), "%s/%s", root_mountpoint, ostree_target);
@ -140,18 +140,18 @@ main(int argc, char *argv[])
if (lstat (destpath, &stbuf) < 0) if (lstat (destpath, &stbuf) < 0)
{ {
perrorv ("Couldn't find specified OSTree root '%s': ", destpath); perrorv ("Couldn't find specified OSTree root '%s': ", destpath);
exit (1); exit (EXIT_FAILURE);
} }
if (!S_ISLNK (stbuf.st_mode)) if (!S_ISLNK (stbuf.st_mode))
{ {
fprintf (stderr, "OSTree target is not a symbolic link: %s\n", destpath); fprintf (stderr, "OSTree target is not a symbolic link: %s\n", destpath);
exit (1); exit (EXIT_FAILURE);
} }
deploy_path = realpath (destpath, NULL); deploy_path = realpath (destpath, NULL);
if (deploy_path == NULL) if (deploy_path == NULL)
{ {
perrorv ("realpath(%s) failed: ", destpath); perrorv ("realpath(%s) failed: ", destpath);
exit (1); exit (EXIT_FAILURE);
} }
fprintf (stderr, "Resolved OSTree target to: %s\n", deploy_path); fprintf (stderr, "Resolved OSTree target to: %s\n", deploy_path);
@ -164,21 +164,21 @@ main(int argc, char *argv[])
if (mount (NULL, "/", NULL, MS_REC|MS_PRIVATE, NULL) < 0) if (mount (NULL, "/", NULL, MS_REC|MS_PRIVATE, NULL) < 0)
{ {
perrorv ("Failed to make \"/\" private mount: %m"); perrorv ("Failed to make \"/\" private mount: %m");
exit (1); exit (EXIT_FAILURE);
} }
/* Make deploy_path a bind mount, so we can move it later */ /* Make deploy_path a bind mount, so we can move it later */
if (mount (deploy_path, deploy_path, NULL, MS_BIND, NULL) < 0) if (mount (deploy_path, deploy_path, NULL, MS_BIND, NULL) < 0)
{ {
perrorv ("failed to initial bind mount %s", deploy_path); perrorv ("failed to initial bind mount %s", deploy_path);
exit (1); exit (EXIT_FAILURE);
} }
snprintf (destpath, sizeof(destpath), "%s/sysroot", deploy_path); snprintf (destpath, sizeof(destpath), "%s/sysroot", deploy_path);
if (mount (root_mountpoint, destpath, NULL, MS_BIND, NULL) < 0) if (mount (root_mountpoint, destpath, NULL, MS_BIND, NULL) < 0)
{ {
perrorv ("Failed to bind mount %s to '%s'", root_mountpoint, destpath); perrorv ("Failed to bind mount %s to '%s'", root_mountpoint, destpath);
exit (1); exit (EXIT_FAILURE);
} }
snprintf (srcpath, sizeof(srcpath), "%s/../../var", deploy_path); snprintf (srcpath, sizeof(srcpath), "%s/../../var", deploy_path);
@ -186,7 +186,7 @@ main(int argc, char *argv[])
if (mount (srcpath, destpath, NULL, MS_MGC_VAL|MS_BIND, NULL) < 0) if (mount (srcpath, destpath, NULL, MS_MGC_VAL|MS_BIND, NULL) < 0)
{ {
perrorv ("failed to bind mount %s to %s", srcpath, destpath); perrorv ("failed to bind mount %s to %s", srcpath, destpath);
exit (1); exit (EXIT_FAILURE);
} }
for (i = 0; readonly_bind_mounts[i] != NULL; i++) for (i = 0; readonly_bind_mounts[i] != NULL; i++)
@ -195,12 +195,12 @@ main(int argc, char *argv[])
if (mount (destpath, destpath, NULL, MS_BIND, NULL) < 0) if (mount (destpath, destpath, NULL, MS_BIND, NULL) < 0)
{ {
perrorv ("failed to bind mount (class:readonly) %s", destpath); perrorv ("failed to bind mount (class:readonly) %s", destpath);
exit (1); exit (EXIT_FAILURE);
} }
if (mount (destpath, destpath, NULL, MS_BIND | MS_REMOUNT | MS_RDONLY, NULL) < 0) if (mount (destpath, destpath, NULL, MS_BIND | MS_REMOUNT | MS_RDONLY, NULL) < 0)
{ {
perrorv ("failed to bind mount (class:readonly) %s", destpath); perrorv ("failed to bind mount (class:readonly) %s", destpath);
exit (1); exit (EXIT_FAILURE);
} }
} }
@ -213,9 +213,9 @@ main(int argc, char *argv[])
if (mount (deploy_path, root_mountpoint, NULL, MS_MOVE, NULL) < 0) if (mount (deploy_path, root_mountpoint, NULL, MS_MOVE, NULL) < 0)
{ {
perrorv ("failed to MS_MOVE %s to %s", deploy_path, root_mountpoint); perrorv ("failed to MS_MOVE %s to %s", deploy_path, root_mountpoint);
exit (1); exit (EXIT_FAILURE);
} }
exit (0); exit (EXIT_SUCCESS);
} }

View File

@ -45,7 +45,7 @@ path_is_on_readonly_fs (char *path)
if (statvfs (path, &stvfsbuf) == -1) if (statvfs (path, &stvfsbuf) == -1)
{ {
perrorv ("statvfs(%s): ", path); perrorv ("statvfs(%s): ", path);
exit (1); exit (EXIT_FAILURE);
} }
return (stvfsbuf.f_flag & ST_RDONLY) != 0; return (stvfsbuf.f_flag & ST_RDONLY) != 0;
@ -70,7 +70,7 @@ maybe_mount_tmpfs_on_var (void)
if (mount ("tmpfs", "/var", "tmpfs", 0, NULL) < 0) if (mount ("tmpfs", "/var", "tmpfs", 0, NULL) < 0)
{ {
perror ("failed to mount tmpfs on /var"); perror ("failed to mount tmpfs on /var");
exit (1); exit (EXIT_FAILURE);
} }
} }
@ -89,7 +89,7 @@ main(int argc, char *argv[])
maybe_mount_tmpfs_on_var (); maybe_mount_tmpfs_on_var ();
exit (0); exit (EXIT_SUCCESS);
} }
for (i = 0; remounts[i] != NULL; i++) for (i = 0; remounts[i] != NULL; i++)
@ -110,13 +110,13 @@ main(int argc, char *argv[])
if (errno != EINVAL) if (errno != EINVAL)
{ {
perrorv ("failed to remount %s", target); perrorv ("failed to remount %s", target);
exit (1); exit (EXIT_FAILURE);
} }
} }
} }
maybe_mount_tmpfs_on_var (); maybe_mount_tmpfs_on_var ();
exit (0); exit (EXIT_SUCCESS);
} }