diff options
author | Jiri Popelka <jpopelka@redhat.com> | 2012-06-21 11:30:22 +0200 |
---|---|---|
committer | Jiri Popelka <jpopelka@redhat.com> | 2012-06-26 12:05:28 +0200 |
commit | 699e5db88236deff1ff4cc657a8d978c25790587 (patch) | |
tree | 19854119440fe0f049abc7f51c96e7668313d449 | |
parent | 6d09cad3b7fdd9d22648cd3ee64ce6bc8e2faab0 (diff) | |
download | net-tools-699e5db88236deff1ff4cc657a8d978c25790587.tar.gz net-tools-699e5db88236deff1ff4cc657a8d978c25790587.tar.bz2 net-tools-699e5db88236deff1ff4cc657a8d978c25790587.zip |
Consistently use defined exit codes.
Tools have been inconsistently using exit codes when started with
--help/--version.
With this patch all tools use exit codes E_USAGE/E_VERSION defined
in net-support.h.
There's probably no rule what exit codes should programs use when
started with --help/--version, but when I'm checking programs on
my system most of them use 0 (SUCCESS) exit code.
Therefore I redefined E_USAGE/E_VERSION to EXIT_SUCCESS (0).
-rw-r--r-- | hostname.c | 5 | ||||
-rw-r--r-- | ifconfig.c | 2 | ||||
-rw-r--r-- | ipmaddr.c | 2 | ||||
-rw-r--r-- | iptunnel.c | 2 | ||||
-rw-r--r-- | lib/net-support.h | 4 | ||||
-rw-r--r-- | mii-tool.c | 3 | ||||
-rw-r--r-- | nameif.c | 3 | ||||
-rw-r--r-- | plipconfig.c | 2 | ||||
-rw-r--r-- | slattach.c | 2 |
9 files changed, 14 insertions, 11 deletions
@@ -42,6 +42,7 @@ #include <arpa/inet.h> #include "config.h" #include "version.h" +#include "net-support.h" #include "../intl.h" #if HAVE_AFINET6 @@ -266,7 +267,7 @@ static void setfilename(char *name, int what) static void version(void) { fprintf(stderr, "%s\n%s\n", Release, Version); - exit(5); /* E_VERSION */ + exit(E_VERSION); } static void usage(void) @@ -297,7 +298,7 @@ static void usage(void) " FQDN (Fully Qualified Domain Name) and the DNS domain name (which is\n" " part of the FQDN) in the /etc/hosts file.\n")); - exit(4); /* E_USAGE */ + exit(E_USAGE); } @@ -236,7 +236,7 @@ static void usage(void) static void version(void) { fprintf(stderr, "%s\n%s\n", Release, Version); - exit(E_USAGE); + exit(E_VERSION); } static int set_netmask(int skfd, struct ifreq *ifr, struct sockaddr *sa) @@ -62,7 +62,7 @@ static void usage(void) fprintf(stderr, _("Usage: ipmaddr [ add | del ] MULTIADDR dev STRING\n")); fprintf(stderr, _(" ipmaddr show [ dev STRING ] [ ipv4 | ipv6 | link | all ]\n")); fprintf(stderr, _(" ipmaddr -V | -version\n")); - exit(-1); + exit(E_USAGE); } static void print_lla(FILE *fp, int len, unsigned char *addr) @@ -92,7 +92,7 @@ static void usage(void) fprintf(stderr, _(" TOS := { NUMBER | inherit }\n")); fprintf(stderr, _(" TTL := { 1..255 | inherit }\n")); fprintf(stderr, _(" KEY := { DOTTED_QUAD | NUMBER }\n")); - exit(-1); + exit(E_USAGE); } static int do_ioctl_get_ifindex(char *dev) diff --git a/lib/net-support.h b/lib/net-support.h index 2359e6c..e25c021 100644 --- a/lib/net-support.h +++ b/lib/net-support.h @@ -168,8 +168,8 @@ extern char afname[]; #define E_NOTFOUND 8 #define E_SOCK 7 #define E_LOOKUP 6 -#define E_VERSION 5 -#define E_USAGE 4 +#define E_VERSION EXIT_SUCCESS +#define E_USAGE EXIT_SUCCESS #define E_OPTERR 3 #define E_INTERN 2 #define E_NOSUPP 1 @@ -54,6 +54,7 @@ static char Version[] = "$Id: mii-tool.c,v 1.9 2006/09/27 20:59:18 ecki Exp $\n( #include <linux/mii.h> #include <linux/sockios.h> #include "version.h" +#include "net-support.h" #define MAX_ETH 8 /* Maximum # of interfaces */ #define LPA_ABILITY_MASK 0x07e0 @@ -458,7 +459,7 @@ const char *usage = static void version(void) { fprintf(stderr, "%s\n%s\n", Version, RELEASE); - exit(5); /* E_VERSION */ + exit(E_VERSION); } @@ -22,6 +22,7 @@ #include <linux/sockios.h> #include <errno.h> #include "intl.h" +#include "net-support.h" const char default_conf[] = "/etc/mactab"; const char *fname = default_conf; @@ -200,7 +201,7 @@ struct option lopt[] = { void usage(void) { fprintf(stderr, _("usage: nameif [-c configurationfile] [-s] {ifname macaddress}\n")); - exit(1); + exit(E_USAGE); } int main(int ac, char **av) diff --git a/plipconfig.c b/plipconfig.c index 01597ae..00286ae 100644 --- a/plipconfig.c +++ b/plipconfig.c @@ -63,7 +63,7 @@ void usage(void) fprintf(stderr, _("Usage: plipconfig interface [nibble NN] [trigger NN]\n")); fprintf(stderr, _(" plipconfig -V | --version\n")); fprintf(stderr, _(" plipconfig -h | --help\n")); - exit(-1); + exit(E_USAGE); } void print_plip(void) @@ -595,7 +595,7 @@ usage(void) " slattach -V | --version\n"; fputs(usage_msg, stderr); - exit(1); + exit(E_USAGE); } |