From e8cbd4b8c577b1e17a7616ce13db7348084b0a28 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Fri, 30 Jan 2015 15:12:43 +0100 Subject: [PATCH] Remove magic argument numbers to exit(2) Signed-off-by: Giuseppe Scrivano --- cfg.mk | 1 - src/libotutil/ot-unix-utils.c | 2 +- src/ostree/ot-builtin-pull-local.c | 2 +- src/switchroot/ostree-prepare-root.c | 26 +++++++++++++------------- src/switchroot/ostree-remount.c | 10 +++++----- 5 files changed, 20 insertions(+), 21 deletions(-) diff --git a/cfg.mk b/cfg.mk index d3e18ca3..00da65c6 100644 --- a/cfg.mk +++ b/cfg.mk @@ -21,7 +21,6 @@ local-checks-to-skip = \ sc_program_name \ sc_bindtextdomain \ sc_prohibit_empty_lines_at_EOF \ - sc_prohibit_magic_number_exit \ sc_prohibit_path_max_allocation \ sc_prohibit_test_double_equal \ sc_space_tab \ diff --git a/src/libotutil/ot-unix-utils.c b/src/libotutil/ot-unix-utils.c index 2cc375ae..9ba0dc38 100644 --- a/src/libotutil/ot-unix-utils.c +++ b/src/libotutil/ot-unix-utils.c @@ -126,7 +126,7 @@ void ot_util_fatal_literal (const char *msg) { g_printerr ("%s\n", msg); - exit (1); + exit (EXIT_FAILURE); } void diff --git a/src/ostree/ot-builtin-pull-local.c b/src/ostree/ot-builtin-pull-local.c index 808773d5..c49ad0f6 100644 --- a/src/ostree/ot-builtin-pull-local.c +++ b/src/ostree/ot-builtin-pull-local.c @@ -83,7 +83,7 @@ import_one_object_thread (gpointer object, if (local_error != NULL) { g_printerr ("%s\n", local_error->message); - exit (1); + exit (EXIT_FAILURE); } } diff --git a/src/switchroot/ostree-prepare-root.c b/src/switchroot/ostree-prepare-root.c index a7338464..f92d15a0 100644 --- a/src/switchroot/ostree-prepare-root.c +++ b/src/switchroot/ostree-prepare-root.c @@ -123,7 +123,7 @@ main(int argc, char *argv[]) if (argc < 2) { fprintf (stderr, "usage: ostree-prepare-root SYSROOT\n"); - exit (1); + exit (EXIT_FAILURE); } root_mountpoint = argv[1]; @@ -132,7 +132,7 @@ main(int argc, char *argv[]) if (!ostree_target) { 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); @@ -140,18 +140,18 @@ main(int argc, char *argv[]) if (lstat (destpath, &stbuf) < 0) { perrorv ("Couldn't find specified OSTree root '%s': ", destpath); - exit (1); + exit (EXIT_FAILURE); } if (!S_ISLNK (stbuf.st_mode)) { fprintf (stderr, "OSTree target is not a symbolic link: %s\n", destpath); - exit (1); + exit (EXIT_FAILURE); } deploy_path = realpath (destpath, NULL); if (deploy_path == NULL) { perrorv ("realpath(%s) failed: ", destpath); - exit (1); + exit (EXIT_FAILURE); } 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) { perrorv ("Failed to make \"/\" private mount: %m"); - exit (1); + exit (EXIT_FAILURE); } /* Make deploy_path a bind mount, so we can move it later */ if (mount (deploy_path, deploy_path, NULL, MS_BIND, NULL) < 0) { perrorv ("failed to initial bind mount %s", deploy_path); - exit (1); + exit (EXIT_FAILURE); } snprintf (destpath, sizeof(destpath), "%s/sysroot", deploy_path); if (mount (root_mountpoint, destpath, NULL, MS_BIND, NULL) < 0) { perrorv ("Failed to bind mount %s to '%s'", root_mountpoint, destpath); - exit (1); + exit (EXIT_FAILURE); } 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) { perrorv ("failed to bind mount %s to %s", srcpath, destpath); - exit (1); + exit (EXIT_FAILURE); } 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) { 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) { 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) { perrorv ("failed to MS_MOVE %s to %s", deploy_path, root_mountpoint); - exit (1); + exit (EXIT_FAILURE); } - exit (0); + exit (EXIT_SUCCESS); } diff --git a/src/switchroot/ostree-remount.c b/src/switchroot/ostree-remount.c index 4af7eeb2..32062c44 100644 --- a/src/switchroot/ostree-remount.c +++ b/src/switchroot/ostree-remount.c @@ -45,7 +45,7 @@ path_is_on_readonly_fs (char *path) if (statvfs (path, &stvfsbuf) == -1) { perrorv ("statvfs(%s): ", path); - exit (1); + exit (EXIT_FAILURE); } 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) { 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 (); - exit (0); + exit (EXIT_SUCCESS); } for (i = 0; remounts[i] != NULL; i++) @@ -110,13 +110,13 @@ main(int argc, char *argv[]) if (errno != EINVAL) { perrorv ("failed to remount %s", target); - exit (1); + exit (EXIT_FAILURE); } } } maybe_mount_tmpfs_on_var (); - exit (0); + exit (EXIT_SUCCESS); }