finger: Add a dedicated usage()

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

finger: Add a dedicated usage()

Tristan Le Guern-3
Hi,

This patch adds a dedicated usage() function to finger(1), like most
other utilities do.

It also removes the unnecessary declaration of optind.

Index: finger.c
===================================================================
RCS file: /home/tleguern/proj/perso/cvs/src/usr.bin/finger/finger.c,v
retrieving revision 1.18
diff -u -p -r1.18 finger.c
--- finger.c 12 Nov 2009 15:33:21 -0000 1.18
+++ finger.c 21 Jul 2014 10:40:00 -0000
@@ -68,6 +68,8 @@
 #include "finger.h"
 #include "extern.h"

+__dead void usage(void);
+
 time_t now;
 int entries, lflag, sflag, mflag, oflag, pplan, Mflag;
 char tbuf[1024];
@@ -77,8 +79,6 @@ PERSON *phead, *ptail;
 int
 main(int argc, char *argv[])
 {
- extern int optind;
- extern char *__progname;
  int ch;
  char domain[MAXHOSTNAMELEN];
  struct stat sb;
@@ -109,10 +109,10 @@ main(int argc, char *argv[])
  oflag = 1; /* office info */
  break;
  case '?':
+ /* FALLTHROUGH */
  default:
- (void)fprintf(stderr,
-    "usage: %s [-hlMmops] [login ...]\n", __progname);
- exit(1);
+ usage();
+ /* NOTREACHED */
  }
  argc -= optind;
  argv += optind;
@@ -265,3 +265,12 @@ net: for (pn = nethead; pn; pn = pn->nex
  for (pn = phead; pn != NULL; pn = pn->next)
  enter_lastlog(pn);
 }
+
+void
+usage(void)
+{
+ (void)fprintf(stderr,
+    "usage: %s [-hlMmops] [login ...]\n", getprogname());
+ exit(1);
+}
+