lib: fix strutils.h, remove STRTOXX_EXIT_CODE

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>
This commit is contained in:
Ruediger Meier 2017-06-22 22:15:14 +02:00
parent 05691d9e88
commit 9c8b9fbacc
5 changed files with 15 additions and 11 deletions

View 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 */

View 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);

View File

@ -17,6 +17,12 @@
#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--) {

View 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) {

View File

@ -72,13 +72,12 @@
#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);