summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiri Popelka <jpopelka@redhat.com>2012-06-21 11:30:22 +0200
committerJiri Popelka <jpopelka@redhat.com>2012-06-26 12:05:28 +0200
commit699e5db88236deff1ff4cc657a8d978c25790587 (patch)
tree19854119440fe0f049abc7f51c96e7668313d449
parent6d09cad3b7fdd9d22648cd3ee64ce6bc8e2faab0 (diff)
downloadnet-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.c5
-rw-r--r--ifconfig.c2
-rw-r--r--ipmaddr.c2
-rw-r--r--iptunnel.c2
-rw-r--r--lib/net-support.h4
-rw-r--r--mii-tool.c3
-rw-r--r--nameif.c3
-rw-r--r--plipconfig.c2
-rw-r--r--slattach.c2
9 files changed, 14 insertions, 11 deletions
diff --git a/hostname.c b/hostname.c
index 0a2084c..33e2b9b 100644
--- a/hostname.c
+++ b/hostname.c
@@ -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);
}
diff --git a/ifconfig.c b/ifconfig.c
index be69995..5321bde 100644
--- a/ifconfig.c
+++ b/ifconfig.c
@@ -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)
diff --git a/ipmaddr.c b/ipmaddr.c
index 3e3f821..a4299aa 100644
--- a/ipmaddr.c
+++ b/ipmaddr.c
@@ -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)
diff --git a/iptunnel.c b/iptunnel.c
index 1b19fbe..28522fc 100644
--- a/iptunnel.c
+++ b/iptunnel.c
@@ -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
diff --git a/mii-tool.c b/mii-tool.c
index 9f63896..c559f43 100644
--- a/mii-tool.c
+++ b/mii-tool.c
@@ -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);
}
diff --git a/nameif.c b/nameif.c
index c77c4fe..61bf85f 100644
--- a/nameif.c
+++ b/nameif.c
@@ -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)
diff --git a/slattach.c b/slattach.c
index 2b7dde2..6d21465 100644
--- a/slattach.c
+++ b/slattach.c
@@ -595,7 +595,7 @@ usage(void)
" slattach -V | --version\n";
fputs(usage_msg, stderr);
- exit(1);
+ exit(E_USAGE);
}