]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib: fix strutils.h, remove STRTOXX_EXIT_CODE
authorRuediger Meier <ruediger.meier@ga-group.nl>
Thu, 22 Jun 2017 20:15:14 +0000 (22:15 +0200)
committerRuediger Meier <ruediger.meier@ga-group.nl>
Thu, 22 Jun 2017 20:40:12 +0000 (22:40 +0200)
As discussed on the mailing list. We fix all places
where the non-working define STRTOXX_EXIT_CODE was used.

Regarding tunelp, also see 7e3c80a7.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
disk-utils/fsck.c
include/strutils.h
lib/strutils.c
misc-utils/blkid.c
sys-utils/tunelp.c

index 5a418fc1f5d13257b261cc1ad24e082608f1b57b..e310fc394cefef7d96f614e244a1c18f63002d1d 100644 (file)
@@ -54,8 +54,6 @@
 #include "c.h"
 #include "fileutils.h"
 #include "monotonic.h"
-
-#define STRTOXX_EXIT_CODE      FSCK_EX_USAGE
 #include "strutils.h"
 
 #define XALLOC_EXIT_CODE       FSCK_EX_ERROR
@@ -1599,6 +1597,7 @@ int main(int argc, char *argv[])
        textdomain(PACKAGE);
        atexit(close_stdout);
 
+       strutils_set_exitcode(FSCK_EX_USAGE);
        mnt_init_debug(0);              /* init libmount debug mask */
        mntcache = mnt_new_cache();     /* no fatal error if failed */
 
index 28c1b5e5d6f1d0da1ba50abbf57c6f6c5d1d2f1f..be1ba67371d87a1e039e032851dbc8735f275b1d 100644 (file)
@@ -9,11 +9,8 @@
 #include <stdio.h>
 #include <errno.h>
 
-/* default strtoxx_or_err() exit code */
-#ifndef STRTOXX_EXIT_CODE
-# define STRTOXX_EXIT_CODE EXIT_FAILURE
-#endif
-
+/* initialize a custom exit code for all *_or_err functions */
+extern void strutils_set_exitcode(int exit_code);
 
 extern int parse_size(const char *str, uintmax_t *res, int *power);
 extern int strtosize(const char *str, uintmax_t *res);
index 45127b5a207b582efe47e05a253ba12ab7b19c53..74d2e5aa9cb8f735b0b5b8ca021b289313c9d64a 100644 (file)
 #include "strutils.h"
 #include "bitops.h"
 
+static int STRTOXX_EXIT_CODE = EXIT_FAILURE;
+
+void strutils_set_exitcode(int ex) {
+       STRTOXX_EXIT_CODE = ex;
+}
+
 static int do_scale_by_power (uintmax_t *x, int base, int power)
 {
        while (power--) {
index 1dc8f40854c79a00bfb29211b625a56ac10ca6c7..73731f0b8a9a7b4ee160ce816e612f89250258fe 100644 (file)
@@ -34,7 +34,6 @@
 
 #include "ismounted.h"
 
-#define STRTOXX_EXIT_CODE      BLKID_EXIT_OTHER        /* strtoxx_or_err() */
 #include "strutils.h"
 #define OPTUTILS_EXIT_CODE     BLKID_EXIT_OTHER        /* exclusive_option() */
 #include "optutils.h"
@@ -691,6 +690,8 @@ int main(int argc, char **argv)
        textdomain(PACKAGE);
        atexit(close_stdout);
 
+       strutils_set_exitcode(BLKID_EXIT_OTHER);
+
        while ((c = getopt_long (argc, argv,
                            "c:dghilL:n:ko:O:ps:S:t:u:U:w:Vv", longopts, NULL)) != -1) {
 
index 89afff1baf29725ff7b24c1684cfdc23bc92f6a8..2749dd1c8e9f5d28f8dfe606d95bef350ec60c2c 100644 (file)
 #include "lp.h"
 #include "nls.h"
 #include "closestream.h"
+#include "strutils.h"
 
 #define EXIT_LP_MALLOC         2
-#define STRTOXX_EXIT_CODE      3
+#define EXIT_LP_BADVAL         3
 #define EXIT_LP_IO_ERR         4
 
-#include "strutils.h"
-
 #define XALLOC_EXIT_CODE EXIT_LP_MALLOC
 #include "xalloc.h"
 
@@ -147,6 +146,8 @@ int main(int argc, char **argv)
        textdomain(PACKAGE);
        atexit(close_stdout);
 
+       strutils_set_exitcode(EXIT_LP_BADVAL);
+
        if (argc < 2)
                print_usage(stderr);