Commit 699e5db8 authored by Jiri Popelka's avatar Jiri Popelka

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).
parent 6d09cad3
......@@ -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)
......
......@@ -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)
......
......@@ -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);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment