Skip to contentSkip to conversation

overriding STRTOXX_EXIT_CODE does not work

DISCUSSION Ruediger Meier 2 participants 3 messages Jun 21, 2017 – Jun 22, 2017 Util-Linux package

lore
Share & tools
lore
#0 lore raw

Hi,

I found a little annoying issue. The trick to re-define STRTOXX_EXIT_CODE (see a99c913091c, 2012-03-30) can't work. When compiling strutils.c it will always use the default from strutils.h

STRTOXX_EXIT_CODE is used only at 3 places:

disk-utils/fsck.c:#define STRTOXX_EXIT_CODE     FSCK_EX_USAGE
misc-utils/blkid.c:#define STRTOXX_EXIT_CODE    BLKID_EXIT_OTHER
sys-utils/tunelp.c:#define STRTOXX_EXIT_CODE    3

But there are more candidates where the return codes are broken since strutils.h was introduced, for example here f150ac37.

$ grep -l "strutils.h" `git grep -l   "FINDFS_\|MNT_EX\|MKFS_EX\|FSCK_EX" --  "*.c"`
disk-utils/fsck.c
disk-utils/fsck.cramfs.c
disk-utils/fsck.minix.c
disk-utils/mkfs.cramfs.c
disk-utils/mkfs.minix.c
libmount/src/context_mount.c
libmount/src/context_umount.c
sys-utils/fstrim.c
sys-utils/mount.c

Should we make STRTOXX_EXIT_CODE usable by moving strutils.c to strutils.h, like optutils.h? Or any other ideas?

cu,
Rudi

maintainer
#1 lore raw
Quoted 30 lines · Ruediger Meier

Hi,

I found a little annoying issue. The trick to re-define STRTOXX_EXIT_CODE (see a99c913091c, 2012-03-30) can't work. When compiling strutils.c it will always use the default from strutils.h

STRTOXX_EXIT_CODE is used only at 3 places:

disk-utils/fsck.c:#define STRTOXX_EXIT_CODE     FSCK_EX_USAGE
misc-utils/blkid.c:#define STRTOXX_EXIT_CODE    BLKID_EXIT_OTHER
sys-utils/tunelp.c:#define STRTOXX_EXIT_CODE    3

But there are more candidates where the return codes are broken since strutils.h was introduced, for example here f150ac37.

$ grep -l "strutils.h" `git grep -l   "FINDFS_\|MNT_EX\|MKFS_EX\|FSCK_EX" --  "*.c"`
disk-utils/fsck.c
disk-utils/fsck.cramfs.c
disk-utils/fsck.minix.c
disk-utils/mkfs.cramfs.c
disk-utils/mkfs.minix.c
libmount/src/context_mount.c
libmount/src/context_umount.c
sys-utils/fstrim.c
sys-utils/mount.c
Quoted 2 lines

Should we make STRTOXX_EXIT_CODE usable by moving strutils.c to strutils.h, like optutils.h? Or any other ideas?

I don't think use static inline for everything is the right way, maybe we can introduce

static int _strutils_exitcode;

  void strutils_set_exitcode(int ex) {
    _strutils_exitcode  = ex;
  }

function and call the function from main() for utils where it matter.

Karel

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com
#2 lore raw
Quoted 37 lines · Karel Zak
Quoted 30 lines · Ruediger Meier

Hi,

I found a little annoying issue. The trick to re-define STRTOXX_EXIT_CODE (see a99c913091c, 2012-03-30) can't work. When compiling strutils.c it will always use the default from strutils.h

STRTOXX_EXIT_CODE is used only at 3 places:

disk-utils/fsck.c:#define STRTOXX_EXIT_CODE     FSCK_EX_USAGE
misc-utils/blkid.c:#define STRTOXX_EXIT_CODE    BLKID_EXIT_OTHER
sys-utils/tunelp.c:#define STRTOXX_EXIT_CODE    3

But there are more candidates where the return codes are broken since strutils.h was introduced, for example here f150ac37.

$ grep -l "strutils.h" `git grep -l  
"FINDFS_\|MNT_EX\|MKFS_EX\|FSCK_EX" --  "*.c"` disk-utils/fsck.c
disk-utils/fsck.cramfs.c
disk-utils/fsck.minix.c
disk-utils/mkfs.cramfs.c
disk-utils/mkfs.minix.c
libmount/src/context_mount.c
libmount/src/context_umount.c
sys-utils/fstrim.c
sys-utils/mount.c
Quoted 2 lines

Should we make STRTOXX_EXIT_CODE usable by moving strutils.c to strutils.h, like optutils.h? Or any other ideas?

I don't think use static inline for everything is the right way, maybe we can introduce

Quoted 7 lines

static int _strutils_exitcode;

  void strutils_set_exitcode(int ex) {
    _strutils_exitcode  = ex;
  }

function and call the function from main() for utils where it matter.

Should be good enough for our use cases.

cu,
Rudi