All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] Fix some exit codes (strutils.h and friends)
@ 2017-06-22 20:43 Ruediger Meier
  2017-06-22 20:43 ` [PATCH 1/5] misc: fix some broken exit codes Ruediger Meier
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Ruediger Meier @ 2017-06-22 20:43 UTC (permalink / raw)
  To: util-linux

From: Ruediger Meier <ruediger.meier@ga-group.nl>

As discussed on the mailing list, most importantly
we remove the -nonworking define STRTOXX_EXIT_CODE.

This is pull request #470 on github
https://github.com/karelzak/util-linux/pull/470

Ruediger Meier (5):
  misc: fix some broken exit codes
  lib: fix strutils.h, remove STRTOXX_EXIT_CODE
  misc: fix more strutils related exit codes
  misc: fix xalloc.h related exit codes
  misc: fix optutils.h related exit codes

 disk-utils/fsck.c        |  3 +--
 disk-utils/fsck.cramfs.c |  4 +++-
 disk-utils/fsck.minix.c  |  2 ++
 disk-utils/mkfs.cramfs.c |  4 +++-
 disk-utils/mkfs.minix.c  |  4 ++++
 include/strutils.h       |  7 ++-----
 lib/strutils.c           |  6 ++++++
 misc-utils/blkid.c       |  5 ++++-
 misc-utils/findfs.c      |  4 ++--
 sys-utils/flock.c        |  2 ++
 sys-utils/hwclock.c      |  3 +++
 sys-utils/mount.c        |  6 +++++-
 sys-utils/tunelp.c       | 10 +++++++---
 sys-utils/umount.c       |  6 +++++-
 14 files changed, 49 insertions(+), 17 deletions(-)

-- 
1.8.5.6


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/5] misc: fix some broken exit codes
  2017-06-22 20:43 [PATCH 0/5] Fix some exit codes (strutils.h and friends) Ruediger Meier
@ 2017-06-22 20:43 ` Ruediger Meier
  2017-06-22 20:43 ` [PATCH 2/5] lib: fix strutils.h, remove STRTOXX_EXIT_CODE Ruediger Meier
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: Ruediger Meier @ 2017-06-22 20:43 UTC (permalink / raw)
  To: util-linux

From: Ruediger Meier <ruediger.meier@ga-group.nl>

These tools have special exit codes. They got changed mistakenly.

See:
  findfs       0e1fa6b6
  fsck         658c0891
  fsck.cramfs  922ec175
  mkfs.cramfs  16154b1f
  tunelp       2ab428f6

FIXME: STRTOXX_EXIT_CODE doesn't work as it should.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
---
 disk-utils/fsck.c        | 2 +-
 disk-utils/fsck.cramfs.c | 2 +-
 disk-utils/mkfs.cramfs.c | 2 +-
 misc-utils/findfs.c      | 4 ++--
 sys-utils/tunelp.c       | 5 ++++-
 5 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/disk-utils/fsck.c b/disk-utils/fsck.c
index cb1b212..5a418fc 100644
--- a/disk-utils/fsck.c
+++ b/disk-utils/fsck.c
@@ -55,7 +55,7 @@
 #include "fileutils.h"
 #include "monotonic.h"
 
-#define STRTOXX_EXIT_CODE	FSCK_EX_ERROR
+#define STRTOXX_EXIT_CODE	FSCK_EX_USAGE
 #include "strutils.h"
 
 #define XALLOC_EXIT_CODE	FSCK_EX_ERROR
diff --git a/disk-utils/fsck.cramfs.c b/disk-utils/fsck.cramfs.c
index 63033d6..952f153 100644
--- a/disk-utils/fsck.cramfs.c
+++ b/disk-utils/fsck.cramfs.c
@@ -671,7 +671,7 @@ int main(int argc, char **argv)
 			break;
 		case 'V':
 			printf(UTIL_LINUX_VERSION);
-			return EXIT_SUCCESS;
+			return FSCK_EX_OK;
 		case 'x':
 			opt_extract = 1;
 			if(optarg)
diff --git a/disk-utils/mkfs.cramfs.c b/disk-utils/mkfs.cramfs.c
index 77b4467..041c6d7 100644
--- a/disk-utils/mkfs.cramfs.c
+++ b/disk-utils/mkfs.cramfs.c
@@ -910,5 +910,5 @@ int main(int argc, char **argv)
 	    (warn_namelen|warn_skip|warn_size|warn_uid|warn_gid|warn_dev))
 		exit(MKFS_EX_ERROR);
 
-	return EXIT_SUCCESS;
+	return MKFS_EX_OK;
 }
diff --git a/misc-utils/findfs.c b/misc-utils/findfs.c
index 7935232..7d2d803 100644
--- a/misc-utils/findfs.c
+++ b/misc-utils/findfs.c
@@ -63,11 +63,11 @@ int main(int argc, char **argv)
 		switch (c) {
 		case 'V':
 			printf(UTIL_LINUX_VERSION);
-			return EXIT_SUCCESS;
+			return FINDFS_SUCCESS;
 		case 'h':
 			usage(FINDFS_SUCCESS);
 		default:
-			errtryhelp(EXIT_FAILURE);
+			errtryhelp(FINDFS_USAGE_ERROR);
 		}
 
 	dev = blkid_evaluate_tag(argv[1], NULL, NULL);
diff --git a/sys-utils/tunelp.c b/sys-utils/tunelp.c
index 8cfbe80..89afff1 100644
--- a/sys-utils/tunelp.c
+++ b/sys-utils/tunelp.c
@@ -71,14 +71,17 @@
 
 #include "lp.h"
 #include "nls.h"
-#include "xalloc.h"
 #include "closestream.h"
 
+#define EXIT_LP_MALLOC		2
 #define STRTOXX_EXIT_CODE	3
 #define EXIT_LP_IO_ERR		4
 
 #include "strutils.h"
 
+#define XALLOC_EXIT_CODE EXIT_LP_MALLOC
+#include "xalloc.h"
+
 struct command {
 	long op;
 	long val;
-- 
1.8.5.6


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/5] lib: fix strutils.h, remove STRTOXX_EXIT_CODE
  2017-06-22 20:43 [PATCH 0/5] Fix some exit codes (strutils.h and friends) Ruediger Meier
  2017-06-22 20:43 ` [PATCH 1/5] misc: fix some broken exit codes Ruediger Meier
@ 2017-06-22 20:43 ` Ruediger Meier
  2017-06-22 20:43 ` [PATCH 3/5] misc: fix more strutils related exit codes Ruediger Meier
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: Ruediger Meier @ 2017-06-22 20:43 UTC (permalink / raw)
  To: util-linux

From: Ruediger Meier <ruediger.meier@ga-group.nl>

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  | 3 +--
 include/strutils.h | 7 ++-----
 lib/strutils.c     | 6 ++++++
 misc-utils/blkid.c | 3 ++-
 sys-utils/tunelp.c | 7 ++++---
 5 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/disk-utils/fsck.c b/disk-utils/fsck.c
index 5a418fc..e310fc3 100644
--- a/disk-utils/fsck.c
+++ b/disk-utils/fsck.c
@@ -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 */
 
diff --git a/include/strutils.h b/include/strutils.h
index 28c1b5e..be1ba67 100644
--- a/include/strutils.h
+++ b/include/strutils.h
@@ -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);
diff --git a/lib/strutils.c b/lib/strutils.c
index 45127b5..74d2e5a 100644
--- a/lib/strutils.c
+++ b/lib/strutils.c
@@ -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--) {
diff --git a/misc-utils/blkid.c b/misc-utils/blkid.c
index 1dc8f40..73731f0 100644
--- a/misc-utils/blkid.c
+++ b/misc-utils/blkid.c
@@ -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) {
 
diff --git a/sys-utils/tunelp.c b/sys-utils/tunelp.c
index 89afff1..2749dd1 100644
--- a/sys-utils/tunelp.c
+++ b/sys-utils/tunelp.c
@@ -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);
 
-- 
1.8.5.6


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 3/5] misc: fix more strutils related exit codes
  2017-06-22 20:43 [PATCH 0/5] Fix some exit codes (strutils.h and friends) Ruediger Meier
  2017-06-22 20:43 ` [PATCH 1/5] misc: fix some broken exit codes Ruediger Meier
  2017-06-22 20:43 ` [PATCH 2/5] lib: fix strutils.h, remove STRTOXX_EXIT_CODE Ruediger Meier
@ 2017-06-22 20:43 ` Ruediger Meier
  2017-06-23 17:28   ` J William Piggott
  2017-06-22 20:43 ` [PATCH 4/5] misc: fix xalloc.h " Ruediger Meier
  2017-06-22 20:43 ` [PATCH 5/5] misc: fix optutils.h " Ruediger Meier
  4 siblings, 1 reply; 10+ messages in thread
From: Ruediger Meier @ 2017-06-22 20:43 UTC (permalink / raw)
  To: util-linux

From: Ruediger Meier <ruediger.meier@ga-group.nl>

Found by grep:

grep -l "\bEXIT_\|exit *( *[0-9][0-9] *)\|strutils\.h" $(grep -L \
    strutils_set_exitcode  $(git grep -l "_EX_\|FINDFS_\|BLKID_EXIT\|EX_USAGE" -- "*.c"))

The Command shows also some false positives (fstrim.c,
context_mount.c, ...)

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
---
 disk-utils/fsck.cramfs.c | 2 ++
 disk-utils/fsck.minix.c  | 2 ++
 disk-utils/mkfs.cramfs.c | 2 ++
 disk-utils/mkfs.minix.c  | 2 ++
 sys-utils/flock.c        | 2 ++
 sys-utils/hwclock.c      | 2 ++
 sys-utils/mount.c        | 2 ++
 7 files changed, 14 insertions(+)

diff --git a/disk-utils/fsck.cramfs.c b/disk-utils/fsck.cramfs.c
index 952f153..1dba95e 100644
--- a/disk-utils/fsck.cramfs.c
+++ b/disk-utils/fsck.cramfs.c
@@ -660,6 +660,8 @@ int main(int argc, char **argv)
 	textdomain(PACKAGE);
 	atexit(close_stdout);
 
+	strutils_set_exitcode(FSCK_EX_USAGE);
+
 	/* command line options */
 	while ((c = getopt_long(argc, argv, "ayvVhb:", longopts, NULL)) != EOF)
 		switch (c) {
diff --git a/disk-utils/fsck.minix.c b/disk-utils/fsck.minix.c
index dea3436..bff810e 100644
--- a/disk-utils/fsck.minix.c
+++ b/disk-utils/fsck.minix.c
@@ -1293,6 +1293,8 @@ main(int argc, char **argv) {
 	textdomain(PACKAGE);
 	atexit(close_stdout);
 
+	strutils_set_exitcode(FSCK_EX_USAGE);
+
 	if (INODE_SIZE * MINIX_INODES_PER_BLOCK != MINIX_BLOCK_SIZE)
 		die(_("bad inode size"));
 	if (INODE2_SIZE * MINIX2_INODES_PER_BLOCK != MINIX_BLOCK_SIZE)
diff --git a/disk-utils/mkfs.cramfs.c b/disk-utils/mkfs.cramfs.c
index 041c6d7..6a6d9a1 100644
--- a/disk-utils/mkfs.cramfs.c
+++ b/disk-utils/mkfs.cramfs.c
@@ -717,6 +717,8 @@ int main(int argc, char **argv)
 	textdomain(PACKAGE);
 	atexit(close_stdout);
 
+	strutils_set_exitcode(MKFS_EX_USAGE);
+
 	/* command line options */
 	while ((c = getopt(argc, argv, "hb:Ee:i:n:N:psVvz")) != EOF) {
 		switch (c) {
diff --git a/disk-utils/mkfs.minix.c b/disk-utils/mkfs.minix.c
index 47a155c..96d36b0 100644
--- a/disk-utils/mkfs.minix.c
+++ b/disk-utils/mkfs.minix.c
@@ -758,6 +758,8 @@ int main(int argc, char ** argv)
 	textdomain(PACKAGE);
 	atexit(close_stdout);
 
+	strutils_set_exitcode(MKFS_EX_USAGE);
+
 	while ((i = getopt_long(argc, argv, "1v23n:i:cl:Vh", longopts, NULL)) != -1)
 		switch (i) {
 		case '1':
diff --git a/sys-utils/flock.c b/sys-utils/flock.c
index 50194bd..003a126 100644
--- a/sys-utils/flock.c
+++ b/sys-utils/flock.c
@@ -170,6 +170,8 @@ int main(int argc, char *argv[])
 	textdomain(PACKAGE);
 	atexit(close_stdout);
 
+	strutils_set_exitcode(EX_USAGE);
+
 	if (argc < 2)
 		usage(EX_USAGE);
 
diff --git a/sys-utils/hwclock.c b/sys-utils/hwclock.c
index 5433cd0..325106a 100644
--- a/sys-utils/hwclock.c
+++ b/sys-utils/hwclock.c
@@ -1326,6 +1326,8 @@ int main(int argc, char **argv)
 	};
 	int excl_st[ARRAY_SIZE(excl)] = UL_EXCL_STATUS_INIT;
 
+	strutils_set_exitcode(EX_USAGE);
+
 	/* Remember what time we were invoked */
 	gettimeofday(&startup_time, NULL);
 
diff --git a/sys-utils/mount.c b/sys-utils/mount.c
index 4d7a5fc..0f7fa90 100644
--- a/sys-utils/mount.c
+++ b/sys-utils/mount.c
@@ -534,6 +534,8 @@ int main(int argc, char **argv)
 	textdomain(PACKAGE);
 	atexit(close_stdout);
 
+	strutils_set_exitcode(MNT_EX_USAGE);
+
 	mnt_init_debug(0);
 	cxt = mnt_new_context();
 	if (!cxt)
-- 
1.8.5.6


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 4/5] misc: fix xalloc.h related exit codes
  2017-06-22 20:43 [PATCH 0/5] Fix some exit codes (strutils.h and friends) Ruediger Meier
                   ` (2 preceding siblings ...)
  2017-06-22 20:43 ` [PATCH 3/5] misc: fix more strutils related exit codes Ruediger Meier
@ 2017-06-22 20:43 ` Ruediger Meier
  2017-06-23 17:28   ` J William Piggott
  2017-06-22 20:43 ` [PATCH 5/5] misc: fix optutils.h " Ruediger Meier
  4 siblings, 1 reply; 10+ messages in thread
From: Ruediger Meier @ 2017-06-22 20:43 UTC (permalink / raw)
  To: util-linux

From: Ruediger Meier <ruediger.meier@ga-group.nl>

Found by:

grep -L "XALLOC_EXIT_CODE" $(grep -l "xalloc\.h" \
    $(git grep -l "_EX_\|FINDFS_\|BLKID_EXIT\|EX_USAGE" -- "*.c"))

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
---
 disk-utils/mkfs.minix.c | 2 ++
 misc-utils/blkid.c      | 2 ++
 sys-utils/hwclock.c     | 1 +
 sys-utils/mount.c       | 4 +++-
 sys-utils/umount.c      | 2 ++
 5 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/disk-utils/mkfs.minix.c b/disk-utils/mkfs.minix.c
index 96d36b0..98a6266 100644
--- a/disk-utils/mkfs.minix.c
+++ b/disk-utils/mkfs.minix.c
@@ -77,6 +77,8 @@
 #include "all-io.h"
 #include "closestream.h"
 #include "ismounted.h"
+
+#define XALLOC_EXIT_CODE MKFS_EX_ERROR
 #include "xalloc.h"
 
 #define MINIX_ROOT_INO 1
diff --git a/misc-utils/blkid.c b/misc-utils/blkid.c
index 73731f0..3e6f1ce 100644
--- a/misc-utils/blkid.c
+++ b/misc-utils/blkid.c
@@ -42,6 +42,8 @@
 
 #include "nls.h"
 #include "ttyutils.h"
+
+#define XALLOC_EXIT_CODE    BLKID_EXIT_OTHER    /* x.*alloc(), xstrndup() */
 #include "xalloc.h"
 
 struct blkid_control {
diff --git a/sys-utils/hwclock.c b/sys-utils/hwclock.c
index 325106a..5c34144 100644
--- a/sys-utils/hwclock.c
+++ b/sys-utils/hwclock.c
@@ -71,6 +71,7 @@
 #include <unistd.h>
 
 #define OPTUTILS_EXIT_CODE EX_USAGE
+#define XALLOC_EXIT_CODE EX_OSERR
 
 #include "c.h"
 #include "closestream.h"
diff --git a/sys-utils/mount.c b/sys-utils/mount.c
index 0f7fa90..ffe294e 100644
--- a/sys-utils/mount.c
+++ b/sys-utils/mount.c
@@ -36,10 +36,12 @@
 #include "c.h"
 #include "env.h"
 #include "strutils.h"
-#include "xalloc.h"
 #include "closestream.h"
 #include "canonicalize.h"
 
+#define XALLOC_EXIT_CODE MNT_EX_SYSERR
+#include "xalloc.h"
+
 #define OPTUTILS_EXIT_CODE MNT_EX_USAGE
 #include "optutils.h"
 
diff --git a/sys-utils/umount.c b/sys-utils/umount.c
index ed8fd4f..2dfb139 100644
--- a/sys-utils/umount.c
+++ b/sys-utils/umount.c
@@ -36,6 +36,8 @@
 #include "closestream.h"
 #include "pathnames.h"
 #include "canonicalize.h"
+
+#define XALLOC_EXIT_CODE MNT_EX_SYSERR
 #include "xalloc.h"
 
 static int table_parser_errcb(struct libmnt_table *tb __attribute__((__unused__)),
-- 
1.8.5.6


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 5/5] misc: fix optutils.h related exit codes
  2017-06-22 20:43 [PATCH 0/5] Fix some exit codes (strutils.h and friends) Ruediger Meier
                   ` (3 preceding siblings ...)
  2017-06-22 20:43 ` [PATCH 4/5] misc: fix xalloc.h " Ruediger Meier
@ 2017-06-22 20:43 ` Ruediger Meier
  4 siblings, 0 replies; 10+ messages in thread
From: Ruediger Meier @ 2017-06-22 20:43 UTC (permalink / raw)
  To: util-linux

From: Ruediger Meier <ruediger.meier@ga-group.nl>

Found by:

  grep -L "OPTUTILS_EXIT_CODE" $(grep -l "err_exclusive_options" \
      $(git grep -l "_EX_\|FINDFS_\|BLKID_EXIT\|EX_USAGE" -- "*.c"))

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
---
 sys-utils/umount.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sys-utils/umount.c b/sys-utils/umount.c
index 2dfb139..57140a6 100644
--- a/sys-utils/umount.c
+++ b/sys-utils/umount.c
@@ -32,7 +32,6 @@
 #include "nls.h"
 #include "c.h"
 #include "env.h"
-#include "optutils.h"
 #include "closestream.h"
 #include "pathnames.h"
 #include "canonicalize.h"
@@ -40,6 +39,9 @@
 #define XALLOC_EXIT_CODE MNT_EX_SYSERR
 #include "xalloc.h"
 
+#define OPTUTILS_EXIT_CODE MNT_EX_USAGE
+#include "optutils.h"
+
 static int table_parser_errcb(struct libmnt_table *tb __attribute__((__unused__)),
 			const char *filename, int line)
 {
-- 
1.8.5.6


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 3/5] misc: fix more strutils related exit codes
  2017-06-22 20:43 ` [PATCH 3/5] misc: fix more strutils related exit codes Ruediger Meier
@ 2017-06-23 17:28   ` J William Piggott
  2017-06-24 11:42     ` Rüdiger Meier
  0 siblings, 1 reply; 10+ messages in thread
From: J William Piggott @ 2017-06-23 17:28 UTC (permalink / raw)
  To: Ruediger Meier, util-linux



On 06/22/2017 04:43 PM, Ruediger Meier wrote:
> From: Ruediger Meier <ruediger.meier@ga-group.nl>
> 
> Found by grep:
> 
> grep -l "\bEXIT_\|exit *( *[0-9][0-9] *)\|strutils\.h" $(grep -L \
>     strutils_set_exitcode  $(git grep -l "_EX_\|FINDFS_\|BLKID_EXIT\|EX_USAGE" -- "*.c"))
> 
> The Command shows also some false positives (fstrim.c,
> context_mount.c, ...)
> 
> Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
> ---
>  disk-utils/fsck.cramfs.c | 2 ++
>  disk-utils/fsck.minix.c  | 2 ++
>  disk-utils/mkfs.cramfs.c | 2 ++
>  disk-utils/mkfs.minix.c  | 2 ++
>  sys-utils/flock.c        | 2 ++
>  sys-utils/hwclock.c      | 2 ++
>  sys-utils/mount.c        | 2 ++
>  7 files changed, 14 insertions(+)
>

 --- >8

>  
> diff --git a/sys-utils/hwclock.c b/sys-utils/hwclock.c
> index 5433cd0..325106a 100644
> --- a/sys-utils/hwclock.c
> +++ b/sys-utils/hwclock.c
> @@ -1326,6 +1326,8 @@ int main(int argc, char **argv)
>  	};
>  	int excl_st[ARRAY_SIZE(excl)] = UL_EXCL_STATUS_INIT;
>  
> +	strutils_set_exitcode(EX_USAGE);
> +
>  	/* Remember what time we were invoked */
>  	gettimeofday(&startup_time, NULL);
>

If we keep this it needs to be: #if defined(__linux__) && defined(__alpha__)

I think the default EXIT_FAILURE is fine for this case.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 4/5] misc: fix xalloc.h related exit codes
  2017-06-22 20:43 ` [PATCH 4/5] misc: fix xalloc.h " Ruediger Meier
@ 2017-06-23 17:28   ` J William Piggott
  0 siblings, 0 replies; 10+ messages in thread
From: J William Piggott @ 2017-06-23 17:28 UTC (permalink / raw)
  To: Ruediger Meier, util-linux



On 06/22/2017 04:43 PM, Ruediger Meier wrote:
> From: Ruediger Meier <ruediger.meier@ga-group.nl>
> 
> Found by:
> 
> grep -L "XALLOC_EXIT_CODE" $(grep -l "xalloc\.h" \
>     $(git grep -l "_EX_\|FINDFS_\|BLKID_EXIT\|EX_USAGE" -- "*.c"))
> 
> Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
> ---
>  disk-utils/mkfs.minix.c | 2 ++
>  misc-utils/blkid.c      | 2 ++
>  sys-utils/hwclock.c     | 1 +
>  sys-utils/mount.c       | 4 +++-
>  sys-utils/umount.c      | 2 ++
>  5 files changed, 10 insertions(+), 1 deletion(-)
> 

 --- >8

> diff --git a/sys-utils/hwclock.c b/sys-utils/hwclock.c
> index 325106a..5c34144 100644
> --- a/sys-utils/hwclock.c
> +++ b/sys-utils/hwclock.c
> @@ -71,6 +71,7 @@
>  #include <unistd.h>
>  
>  #define OPTUTILS_EXIT_CODE EX_USAGE
> +#define XALLOC_EXIT_CODE EX_OSERR

I think the default EXIT_FAILURE is fine for this case.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 3/5] misc: fix more strutils related exit codes
  2017-06-23 17:28   ` J William Piggott
@ 2017-06-24 11:42     ` Rüdiger Meier
  2017-06-25 21:39       ` J William Piggott
  0 siblings, 1 reply; 10+ messages in thread
From: Rüdiger Meier @ 2017-06-24 11:42 UTC (permalink / raw)
  To: J William Piggott, util-linux



On 06/23/2017 07:28 PM, J William Piggott wrote:
> 
> 
> On 06/22/2017 04:43 PM, Ruediger Meier wrote:
>> From: Ruediger Meier <ruediger.meier@ga-group.nl>
>>
>> Found by grep:
>>
>> grep -l "\bEXIT_\|exit *( *[0-9][0-9] *)\|strutils\.h" $(grep -L \
>>      strutils_set_exitcode  $(git grep -l "_EX_\|FINDFS_\|BLKID_EXIT\|EX_USAGE" -- "*.c"))
>>
>> The Command shows also some false positives (fstrim.c,
>> context_mount.c, ...)
>>
>> Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
>> ---
>>   disk-utils/fsck.cramfs.c | 2 ++
>>   disk-utils/fsck.minix.c  | 2 ++
>>   disk-utils/mkfs.cramfs.c | 2 ++
>>   disk-utils/mkfs.minix.c  | 2 ++
>>   sys-utils/flock.c        | 2 ++
>>   sys-utils/hwclock.c      | 2 ++
>>   sys-utils/mount.c        | 2 ++
>>   7 files changed, 14 insertions(+)
>>
> 
>   --- >8
> 
>>   
>> diff --git a/sys-utils/hwclock.c b/sys-utils/hwclock.c
>> index 5433cd0..325106a 100644
>> --- a/sys-utils/hwclock.c
>> +++ b/sys-utils/hwclock.c
>> @@ -1326,6 +1326,8 @@ int main(int argc, char **argv)
>>   	};
>>   	int excl_st[ARRAY_SIZE(excl)] = UL_EXCL_STATUS_INIT;
>>   
>> +	strutils_set_exitcode(EX_USAGE);
>> +
>>   	/* Remember what time we were invoked */
>>   	gettimeofday(&startup_time, NULL);
>>
> 
> If we keep this it needs to be: #if defined(__linux__) && defined(__alpha__)

I think the non-needed strutils_set_exitcode() call on non-alpha doesn't hurt
but would ensure that it stays correct if someone would use more *_or_err
functions in future. Otherwise we should also have

#if defined(__linux__) && defined(__alpha__)
# include "strutils.h"
#endif

In general I don't really like that we have soo many exiting functions at all.
They all should take an exit_code argument at least. Like errx() or
errtryhelp(). On average this would look less ugly than all these hacky
exit code re-defines.


> I think the default EXIT_FAILURE is fine for this case.
> 



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 3/5] misc: fix more strutils related exit codes
  2017-06-24 11:42     ` Rüdiger Meier
@ 2017-06-25 21:39       ` J William Piggott
  0 siblings, 0 replies; 10+ messages in thread
From: J William Piggott @ 2017-06-25 21:39 UTC (permalink / raw)
  To: Rüdiger Meier, util-linux



On 06/24/2017 07:42 AM, Rüdiger Meier wrote:
> 
> On 06/23/2017 07:28 PM, J William Piggott wrote:
>>
>> On 06/22/2017 04:43 PM, Ruediger Meier wrote:
>>> From: Ruediger Meier <ruediger.meier@ga-group.nl>
>>>

>>   --- >8
>>
>>
>>>   diff --git a/sys-utils/hwclock.c b/sys-utils/hwclock.c
>>> index 5433cd0..325106a 100644 --- a/sys-utils/hwclock.c
>>> +++ b/sys-utils/hwclock.c
>>> @@ -1326,6 +1326,8 @@ int main(int argc, char **argv)
>>>      
>>> };
>>>      
>>> int excl_st[ARRAY_SIZE(excl)] = UL_EXCL_STATUS_INIT;
>>>   +   strutils_set_exitcode(EX_USAGE);
>>> +
>>> /* Remember what time we were invoked */
>>> gettimeofday(&startup_time, NULL);
>>>
>>
>> If we keep this it needs to be: #if defined(__linux__) &&
>> defined(__alpha__)
>>
> 
> I think the non-needed strutils_set_exitcode() call on non-alpha
> doesn't hurt but would ensure that it stays correct if someone would
> use more *_or_err functions in future.  Otherwise we should also have
> 
> #if defined(__linux__) && defined(__alpha__)
> # include "strutils.h"
> #endif
> 
> In general I don't really like that we have soo many exiting functions
> at all.

It seems over engineered to me.

I don't want to block your work, so I withdraw my comments. After this
set is committed I'll submit a patch to remove strutils from hwclock.

> They all should take an exit_code argument at least.  Like
> errx() or errtryhelp().  On average this would look less ugly than all
> these hacky exit code re-defines.
> 
> 
>> I think the default EXIT_FAILURE is fine for this case.
>>
> 
> 
> -- To unsubscribe from this list: send the line "unsubscribe
> util-linux" in
> 
> the body of a message to majordomo@vger.kernel.org
> 
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> 
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2017-06-25 21:39 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-22 20:43 [PATCH 0/5] Fix some exit codes (strutils.h and friends) Ruediger Meier
2017-06-22 20:43 ` [PATCH 1/5] misc: fix some broken exit codes Ruediger Meier
2017-06-22 20:43 ` [PATCH 2/5] lib: fix strutils.h, remove STRTOXX_EXIT_CODE Ruediger Meier
2017-06-22 20:43 ` [PATCH 3/5] misc: fix more strutils related exit codes Ruediger Meier
2017-06-23 17:28   ` J William Piggott
2017-06-24 11:42     ` Rüdiger Meier
2017-06-25 21:39       ` J William Piggott
2017-06-22 20:43 ` [PATCH 4/5] misc: fix xalloc.h " Ruediger Meier
2017-06-23 17:28   ` J William Piggott
2017-06-22 20:43 ` [PATCH 5/5] misc: fix optutils.h " Ruediger Meier

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.