Skip to content

Commit

Permalink
radvdump.c: less global variables
Browse files Browse the repository at this point in the history
I'm attempting to clean up the usage of global variable to make the
functions in radvd easier to unit test.
  • Loading branch information
reubenhwk committed Jun 4, 2014
1 parent 2e73370 commit cff118b
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions radvdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "includes.h"
#include "radvd.h"

char usage_str[] = "[-vhfe] [-d level]";
static char usage_str[] = "[-vhfe] [-d level]";

#ifdef HAVE_GETOPT_LONG
struct option prog_opt[] = {
Expand All @@ -30,7 +30,6 @@ struct option prog_opt[] = {
};
#endif

char *pname;
int sock = -1;

void version(void);
Expand All @@ -48,8 +47,7 @@ int main(int argc, char *argv[])
#ifdef HAVE_GETOPT_LONG
int opt_idx;
#endif

pname = ((pname = strrchr(argv[0], '/')) != NULL) ? pname + 1 : argv[0];
char const * pname = ((pname = strrchr(argv[0], '/')) != NULL) ? pname + 1 : argv[0];

/* parse args */
#ifdef HAVE_GETOPT_LONG
Expand All @@ -71,7 +69,7 @@ int main(int argc, char *argv[])
version();
break;
case 'h':
usage();
usage(pname);
#ifdef HAVE_GETOPT_LONG
case ':':
fprintf(stderr, "%s: option %s: parameter expected\n", pname, prog_opt[opt_idx].name);
Expand Down Expand Up @@ -468,11 +466,11 @@ void version(void)
{
fprintf(stderr, "Version: %s\n\n", VERSION);
fprintf(stderr, "Please send bug reports and suggestions to %s\n", CONTACT_EMAIL);
exit(1);
exit(-1);
}

void usage(void)
static void usage(char const * pname)
{
fprintf(stderr, "usage: %s %s\n", pname, usage_str);
exit(1);
exit(-1);
}

0 comments on commit cff118b

Please sign in to comment.