On Tue, 9 Jun 2015 14:01:01 -0700
patrick keshishian <[email protected]> wrote:

> Hi,
> 
> On Tue, Jun 09, 2015 at 07:46:20PM +0200, Benjamin Baier wrote:
> > Hello tech@
> > 
> > delete "case '?': /* FALLTHROUGH */" where it is already handled 
> > by "default: usage();".
> 
> Not quite sure it is correct to remove the '?' case from
> npppd.c, since there is no 'default' case.
Best to leave it out. Yes you are right this alters behaviour (usage not 
printed) when invalid option arguments are passed. Had it on the list to
revisit later and add a default case.

> Also, if the idea is to remove cases which simply fall through
> 'default', these few (10) have 'h' cases that do same (judging
> from your diff):
> 
> > RCS file: /cvs/src/games/arithmetic/arithmetic.c,v
> > RCS file: /cvs/src/games/banner/banner.c,v
> > RCS file: /cvs/src/games/fish/fish.c,v
> > RCS file: /cvs/src/games/grdc/grdc.c,v
> > RCS file: /cvs/src/games/hangman/main.c,v
> > RCS file: /cvs/src/games/morse/morse.c,v
> > RCS file: /cvs/src/games/number/number.c,v
> > RCS file: /cvs/src/games/ppt/ppt.c,v
> > RCS file: /cvs/src/games/snake/snake.c,v
> > RCS file: /cvs/src/games/worms/worms.c,v
I was focusing on case '?', and because 'h' is a valid option argument i
decided not to delete the case 'h', for now.
But i'm happy to add them to the patch, if requested.
 
> --patrick
> 
> 
> ...
> > Index: games/arithmetic/arithmetic.c
> > ===================================================================
> > RCS file: /cvs/src/games/arithmetic/arithmetic.c,v
> > retrieving revision 1.18
> > diff -u -p -r1.18 arithmetic.c
> > --- games/arithmetic/arithmetic.c   29 Aug 2013 20:22:09 -0000      1.18
> > +++ games/arithmetic/arithmetic.c   9 Jun 2015 17:28:09 -0000
> > @@ -116,7 +116,6 @@ main(int argc, char *argv[])
> >                     if ((rangemax = atoi(optarg)) <= 0)
> >                             errx(1, "invalid range.");
> >                     break;
> > -           case '?':
> >             case 'h':
> >             default:
> >                     usage();
> > Index: games/banner/banner.c
> > ===================================================================
> > RCS file: /cvs/src/games/banner/banner.c,v
> > retrieving revision 1.17
> > diff -u -p -r1.17 banner.c
> > --- games/banner/banner.c   10 Feb 2015 13:50:58 -0000      1.17
> > +++ games/banner/banner.c   9 Jun 2015 17:28:09 -0000
> > @@ -1030,7 +1030,7 @@ main(int argc, char *argv[])
> >                     if (width <= 0 || width > DWIDTH)
> >                             errx(1, "illegal argument for -w option");
> >                     break;
> > -           case '?': case 'h':
> > +           case 'h':
> >             default:
> >                     (void)fprintf(stderr,
> >                         "usage: banner [-w width] message ...\n");
> ...
> > ===================================================================
> > RCS file: /cvs/src/games/fish/fish.c,v
> > retrieving revision 1.17
> > diff -u -p -r1.17 fish.c
> > --- games/fish/fish.c       18 Feb 2015 23:20:45 -0000      1.17
> > +++ games/fish/fish.c       9 Jun 2015 17:28:09 -0000
> > @@ -92,7 +92,6 @@ main(int argc, char *argv[])
> >             case 'p':
> >                     promode = 1;
> >                     break;
> > -           case '?':
> >             case 'h':
> >             default:
> >                     usage();
> >             }
> ...
> > Index: games/grdc/grdc.c
> > ===================================================================
> > RCS file: /cvs/src/games/grdc/grdc.c,v
> > retrieving revision 1.19
> > diff -u -p -r1.19 grdc.c
> > --- games/grdc/grdc.c       19 Nov 2014 03:27:45 -0000      1.19
> > +++ games/grdc/grdc.c       9 Jun 2015 17:28:09 -0000
> > @@ -77,7 +77,6 @@ main(int argc, char *argv[])
> >                     scrol = 1;
> >                     break;
> >             case 'h':
> > -           case '?':
> >             default:
> >                     usage();
> >             }
> > Index: games/hangman/main.c
> > ===================================================================
> > RCS file: /cvs/src/games/hangman/main.c,v
> > retrieving revision 1.12
> > diff -u -p -r1.12 main.c
> > --- games/hangman/main.c    7 Feb 2015 01:37:30 -0000       1.12
> > +++ games/hangman/main.c    9 Jun 2015 17:28:09 -0000
> > @@ -56,7 +56,6 @@ main(int argc, char *argv[])
> >                     Dict_name = _PATH_KSYMS;
> >                     break;
> >             case 'h':
> > -           case '?':
> >             default:
> >                     usage();
> >             }
> > Index: games/morse/morse.c
> > ===================================================================
> > RCS file: /cvs/src/games/morse/morse.c,v
> > retrieving revision 1.15
> > diff -u -p -r1.15 morse.c
> > --- games/morse/morse.c     27 Nov 2013 13:32:02 -0000      1.15
> > +++ games/morse/morse.c     9 Jun 2015 17:28:09 -0000
> > @@ -120,7 +120,7 @@ main(int argc, char *argv[])
> >             case 's':
> >                     sflag = 1;
> >                     break;
> > -           case '?': case 'h':
> > +           case 'h':
> >             default:
> >                     fprintf(stderr, "usage: morse [-d | -s] [string 
> > ...]\n");
> >                     exit(1);
> > Index: games/number/number.c
> > ===================================================================
> > RCS file: /cvs/src/games/number/number.c,v
> > retrieving revision 1.14
> > diff -u -p -r1.14 number.c
> > --- games/number/number.c   27 Oct 2009 23:59:26 -0000      1.14
> > +++ games/number/number.c   9 Jun 2015 17:28:09 -0000
> > @@ -85,7 +85,6 @@ main(int argc, char *argv[])
> >             case 'l':
> >                     lflag = 1;
> >                     break;
> > -           case '?':
> >             case 'h':
> >             default:
> >                     usage();
> ...
> > Index: games/ppt/ppt.c
> > ===================================================================
> > RCS file: /cvs/src/games/ppt/ppt.c,v
> > retrieving revision 1.12
> > diff -u -p -r1.12 ppt.c
> > --- games/ppt/ppt.c 7 Nov 2014 22:17:49 -0000       1.12
> > +++ games/ppt/ppt.c 9 Jun 2015 17:28:09 -0000
> > @@ -69,7 +69,7 @@ main(int argc, char **argv)
> >             case 'b':
> >                     bflag = 1;
> >                     break;
> > -           case '?': case 'h':
> > +           case 'h':
> >             default:
> >                     usage();
> >             }
> ...
> > Index: games/snake/snake.c
> > ===================================================================
> > RCS file: /cvs/src/games/snake/snake.c,v
> > retrieving revision 1.16
> > diff -u -p -r1.16 snake.c
> > --- games/snake/snake.c     16 Nov 2014 04:49:49 -0000      1.16
> > +++ games/snake/snake.c     9 Jun 2015 17:28:09 -0000
> > @@ -161,7 +161,6 @@ main(int argc, char *argv[])
> >             case 't': /* slow terminal */
> >                     fast = 0;
> >                     break;
> > -           case '?':
> >             case 'h':
> >             default:
> >                     fputs("usage: snake [-st] [-l length] [-w width]\n",
> > Index: games/worms/worms.c
> > ===================================================================
> > RCS file: /cvs/src/games/worms/worms.c,v
> > retrieving revision 1.22
> > diff -u -p -r1.22 worms.c
> > --- games/worms/worms.c     18 Feb 2015 23:16:08 -0000      1.22
> > +++ games/worms/worms.c     9 Jun 2015 17:28:09 -0000
> > @@ -214,7 +214,7 @@ main(int argc, char *argv[])
> >             case 't':
> >                     trail = '.';
> >                     break;
> > -           case '?': case 'h':
> > +           case 'h':
> >             default:
> >                     (void)fprintf(stderr,
> >                         "usage: worms [-ft] [-d delay] [-l length] [-n 
> > number]\n");
> ...
> > Index: usr.sbin/npppd/npppd/npppd.c
> > ===================================================================
> > RCS file: /cvs/src/usr.sbin/npppd/npppd/npppd.c,v
> > retrieving revision 1.40
> > diff -u -p -r1.40 npppd.c
> > --- usr.sbin/npppd/npppd/npppd.c    19 Jan 2015 01:48:59 -0000      1.40
> > +++ usr.sbin/npppd/npppd/npppd.c    9 Jun 2015 17:27:57 -0000
> > @@ -157,7 +157,6 @@ main(int argc, char *argv[])
> >                     debuglevel++;
> >                     runasdaemon = 0;
> >                     break;
> > -           case '?':
> >             case 'h':
> >                     usage();
> >                     exit(1);
> ...

Reply via email to