remove superfluous case '?': from /sbin utils

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

remove superfluous case '?': from /sbin utils

Benjamin Baier
Hello tech@

I cleaned up and split up my former diff[0] for removing superfluous
        case '?': /*FALLTHROUGH*/
        default:
                usage();

Also removes one unnecessary break;

This is for /sbin, more to come if there are any takers?
Greetings Ben

[0] https://marc.info/?l=openbsd-tech&m=143387215328391&w=2

Index: disklabel/disklabel.c
===================================================================
RCS file: /cvs/src/sbin/disklabel/disklabel.c,v
retrieving revision 1.211
diff -u -p -r1.211 disklabel.c
--- disklabel/disklabel.c 17 Oct 2015 13:27:08 -0000 1.211
+++ disklabel/disklabel.c 8 Nov 2015 09:38:05 -0000
@@ -169,7 +169,6 @@ main(int argc, char *argv[])
  case 'v':
  verbose = 1;
  break;
- case '?':
  default:
  usage();
  }
Index: dmesg/dmesg.c
===================================================================
RCS file: /cvs/src/sbin/dmesg/dmesg.c,v
retrieving revision 1.27
diff -u -p -r1.27 dmesg.c
--- dmesg/dmesg.c 9 Oct 2015 01:37:06 -0000 1.27
+++ dmesg/dmesg.c 8 Nov 2015 09:38:05 -0000
@@ -81,7 +81,6 @@ main(int argc, char *argv[])
  case 'N':
  nlistf = optarg;
  break;
- case '?':
  default:
  usage();
  }
Index: dumpfs/dumpfs.c
===================================================================
RCS file: /cvs/src/sbin/dumpfs/dumpfs.c,v
retrieving revision 1.32
diff -u -p -r1.32 dumpfs.c
--- dumpfs/dumpfs.c 20 Jan 2015 18:22:21 -0000 1.32
+++ dumpfs/dumpfs.c 8 Nov 2015 09:38:05 -0000
@@ -89,7 +89,6 @@ main(int argc, char *argv[])
  case 'm':
  domarshal = 1;
  break;
- case '?':
  default:
  usage();
  }
Index: fsck/fsck.c
===================================================================
RCS file: /cvs/src/sbin/fsck/fsck.c,v
retrieving revision 1.37
diff -u -p -r1.37 fsck.c
--- fsck/fsck.c 29 May 2015 15:57:36 -0000 1.37
+++ fsck/fsck.c 8 Nov 2015 09:38:05 -0000
@@ -163,7 +163,6 @@ main(int argc, char *argv[])
  filter = NET_FILTER;
  break;

- case '?':
  default:
  usage();
  /* NOTREACHED */
Index: growfs/growfs.c
===================================================================
RCS file: /cvs/src/sbin/growfs/growfs.c,v
retrieving revision 1.40
diff -u -p -r1.40 growfs.c
--- growfs/growfs.c 20 Aug 2015 22:02:21 -0000 1.40
+++ growfs/growfs.c 8 Nov 2015 09:38:05 -0000
@@ -1937,8 +1937,6 @@ main(int argc, char **argv)
  case 'y':
  ExpertFlag = 1;
  break;
- case '?':
- /* FALLTHROUGH */
  default:
  usage();
  }
Index: isakmpd/isakmpd.c
===================================================================
RCS file: /cvs/src/sbin/isakmpd/isakmpd.c,v
retrieving revision 1.103
diff -u -p -r1.103 isakmpd.c
--- isakmpd/isakmpd.c 20 Aug 2015 22:02:21 -0000 1.103
+++ isakmpd/isakmpd.c 8 Nov 2015 09:38:05 -0000
@@ -210,7 +210,6 @@ parse_args(int argc, char *argv[])
  verbose_logging = 1;
  break;

- case '?':
  default:
  usage();
  }
Index: mknod/mknod.c
===================================================================
RCS file: /cvs/src/sbin/mknod/mknod.c,v
retrieving revision 1.18
diff -u -p -r1.18 mknod.c
--- mknod/mknod.c 27 Mar 2010 09:10:02 -0000 1.18
+++ mknod/mknod.c 8 Nov 2015 09:38:05 -0000
@@ -76,7 +76,6 @@ main(int argc, char *argv[])
  mode = getmode(set, DEFFILEMODE);
  free(set);
  break;
- case '?':
  default:
  usage(ismkfifo);
  }
Index: mount/mount.c
===================================================================
RCS file: /cvs/src/sbin/mount/mount.c,v
retrieving revision 1.60
diff -u -p -r1.60 mount.c
--- mount/mount.c 16 Jan 2015 06:39:59 -0000 1.60
+++ mount/mount.c 8 Nov 2015 09:38:05 -0000
@@ -157,7 +157,6 @@ main(int argc, char * const argv[])
  if (!hasopt(options, "rw"))
  options = catopt(options, "rw");
  break;
- case '?':
  default:
  usage();
  /* NOTREACHED */
Index: mount_cd9660/mount_cd9660.c
===================================================================
RCS file: /cvs/src/sbin/mount_cd9660/mount_cd9660.c,v
retrieving revision 1.21
diff -u -p -r1.21 mount_cd9660.c
--- mount_cd9660/mount_cd9660.c 16 Jan 2015 06:39:59 -0000 1.21
+++ mount_cd9660/mount_cd9660.c 8 Nov 2015 09:38:05 -0000
@@ -91,7 +91,6 @@ main(int argc, char *argv[])
  errx(1, "session number is %s: %s", errstr,
     optarg);
  break;
- case '?':
  default:
  usage();
  }
Index: mount_ext2fs/mount_ext2fs.c
===================================================================
RCS file: /cvs/src/sbin/mount_ext2fs/mount_ext2fs.c,v
retrieving revision 1.17
diff -u -p -r1.17 mount_ext2fs.c
--- mount_ext2fs/mount_ext2fs.c 16 Jan 2015 06:39:59 -0000 1.17
+++ mount_ext2fs/mount_ext2fs.c 8 Nov 2015 09:38:05 -0000
@@ -65,7 +65,6 @@ main(int argc, char *argv[])
  case 'o':
  getmntopts(optarg, mopts, &mntflags);
  break;
- case '?':
  default:
  ext2fs_usage();
  }
Index: mount_ffs/mount_ffs.c
===================================================================
RCS file: /cvs/src/sbin/mount_ffs/mount_ffs.c,v
retrieving revision 1.21
diff -u -p -r1.21 mount_ffs.c
--- mount_ffs/mount_ffs.c 16 Jan 2015 06:39:59 -0000 1.21
+++ mount_ffs/mount_ffs.c 8 Nov 2015 09:38:05 -0000
@@ -70,7 +70,6 @@ main(int argc, char *argv[])
  case 'o':
  getmntopts(optarg, mopts, &mntflags);
  break;
- case '?':
  default:
  ffs_usage();
  }
Index: mount_msdos/mount_msdos.c
===================================================================
RCS file: /cvs/src/sbin/mount_msdos/mount_msdos.c,v
retrieving revision 1.31
diff -u -p -r1.31 mount_msdos.c
--- mount_msdos/mount_msdos.c 2 Nov 2015 01:22:37 -0000 1.31
+++ mount_msdos/mount_msdos.c 8 Nov 2015 09:55:34 -0000
@@ -100,10 +100,8 @@ main(int argc, char **argv)
  case 'o':
  getmntopts(optarg, mopts, &mntflags);
  break;
- case '?':
  default:
  usage();
- break;
  }
  }

Index: mount_tmpfs/mount_tmpfs.c
===================================================================
RCS file: /cvs/src/sbin/mount_tmpfs/mount_tmpfs.c,v
retrieving revision 1.5
diff -u -p -r1.5 mount_tmpfs.c
--- mount_tmpfs/mount_tmpfs.c 16 Jan 2015 06:39:59 -0000 1.5
+++ mount_tmpfs/mount_tmpfs.c 8 Nov 2015 09:38:05 -0000
@@ -131,7 +131,6 @@ mount_tmpfs_parseargs(int argc, char *ar
  uidset = 1;
  break;

- case '?':
  default:
  usage();
  }
Index: newfs/newfs.c
===================================================================
RCS file: /cvs/src/sbin/newfs/newfs.c,v
retrieving revision 1.100
diff -u -p -r1.100 newfs.c
--- newfs/newfs.c 29 Sep 2015 03:19:24 -0000 1.100
+++ newfs/newfs.c 8 Nov 2015 09:38:05 -0000
@@ -294,7 +294,6 @@ main(int argc, char *argv[])
  pop = optarg;
  break;
 #endif
- case '?':
  default:
  usage();
  }
Index: newfs_ext2fs/newfs_ext2fs.c
===================================================================
RCS file: /cvs/src/sbin/newfs_ext2fs/newfs_ext2fs.c,v
retrieving revision 1.17
diff -u -p -r1.17 newfs_ext2fs.c
--- newfs_ext2fs/newfs_ext2fs.c 14 Oct 2015 15:54:49 -0000 1.17
+++ newfs_ext2fs/newfs_ext2fs.c 8 Nov 2015 09:38:05 -0000
@@ -204,7 +204,6 @@ main(int argc, char *argv[])
  errx(EXIT_FAILURE,
     "Volume name cannot be zero length");
  break;
- case '?':
  default:
  usage();
  }
Index: savecore/savecore.c
===================================================================
RCS file: /cvs/src/sbin/savecore/savecore.c,v
retrieving revision 1.55
diff -u -p -r1.55 savecore.c
--- savecore/savecore.c 18 Oct 2015 03:17:48 -0000 1.55
+++ savecore/savecore.c 8 Nov 2015 09:38:05 -0000
@@ -153,7 +153,6 @@ main(int argc, char *argv[])
  case 'z':
  zcompress = 1;
  break;
- case '?':
  default:
  usage();
  }
Index: scsi/scsi.c
===================================================================
RCS file: /cvs/src/sbin/scsi/scsi.c,v
retrieving revision 1.29
diff -u -p -r1.29 scsi.c
--- scsi/scsi.c 20 Nov 2014 15:22:39 -0000 1.29
+++ scsi/scsi.c 8 Nov 2015 09:38:05 -0000
@@ -142,7 +142,6 @@ procargs(int *argc_p, char ***argv_p)
  case 'v':
  verbose = 1;
  break;
- case '?':
  default:
  usage();
  }
Index: ttyflags/ttyflags.c
===================================================================
RCS file: /cvs/src/sbin/ttyflags/ttyflags.c,v
retrieving revision 1.13
diff -u -p -r1.13 ttyflags.c
--- ttyflags/ttyflags.c 4 Dec 2012 02:27:00 -0000 1.13
+++ ttyflags/ttyflags.c 8 Nov 2015 09:38:05 -0000
@@ -78,7 +78,6 @@ main(int argc, char *argv[])
  case 'v':
  vflag = 1;
  break;
- case '?':
  default:
  usage();
  }

Reply | Threaded
Open this post in threaded view
|

Re: remove superfluous case '?': from /sbin utils

Michael McConville-3
Benjamin Baier wrote:

> Hello tech@
>
> I cleaned up and split up my former diff[0] for removing superfluous
> case '?': /*FALLTHROUGH*/
> default:
> usage();
>
> Also removes one unnecessary break;
>
> This is for /sbin, more to come if there are any takers?
> Greetings Ben
>
> [0] https://marc.info/?l=openbsd-tech&m=143387215328391&w=2

Probably worth mentioning that this is inspired by Theo's comment here:

        https://marc.info/?l=openbsd-tech&m=143215393708980&w=2

ok mmcc@

> Index: disklabel/disklabel.c
> ===================================================================
> RCS file: /cvs/src/sbin/disklabel/disklabel.c,v
> retrieving revision 1.211
> diff -u -p -r1.211 disklabel.c
> --- disklabel/disklabel.c 17 Oct 2015 13:27:08 -0000 1.211
> +++ disklabel/disklabel.c 8 Nov 2015 09:38:05 -0000
> @@ -169,7 +169,6 @@ main(int argc, char *argv[])
>   case 'v':
>   verbose = 1;
>   break;
> - case '?':
>   default:
>   usage();
>   }
> Index: dmesg/dmesg.c
> ===================================================================
> RCS file: /cvs/src/sbin/dmesg/dmesg.c,v
> retrieving revision 1.27
> diff -u -p -r1.27 dmesg.c
> --- dmesg/dmesg.c 9 Oct 2015 01:37:06 -0000 1.27
> +++ dmesg/dmesg.c 8 Nov 2015 09:38:05 -0000
> @@ -81,7 +81,6 @@ main(int argc, char *argv[])
>   case 'N':
>   nlistf = optarg;
>   break;
> - case '?':
>   default:
>   usage();
>   }
> Index: dumpfs/dumpfs.c
> ===================================================================
> RCS file: /cvs/src/sbin/dumpfs/dumpfs.c,v
> retrieving revision 1.32
> diff -u -p -r1.32 dumpfs.c
> --- dumpfs/dumpfs.c 20 Jan 2015 18:22:21 -0000 1.32
> +++ dumpfs/dumpfs.c 8 Nov 2015 09:38:05 -0000
> @@ -89,7 +89,6 @@ main(int argc, char *argv[])
>   case 'm':
>   domarshal = 1;
>   break;
> - case '?':
>   default:
>   usage();
>   }
> Index: fsck/fsck.c
> ===================================================================
> RCS file: /cvs/src/sbin/fsck/fsck.c,v
> retrieving revision 1.37
> diff -u -p -r1.37 fsck.c
> --- fsck/fsck.c 29 May 2015 15:57:36 -0000 1.37
> +++ fsck/fsck.c 8 Nov 2015 09:38:05 -0000
> @@ -163,7 +163,6 @@ main(int argc, char *argv[])
>   filter = NET_FILTER;
>   break;
>
> - case '?':
>   default:
>   usage();
>   /* NOTREACHED */
> Index: growfs/growfs.c
> ===================================================================
> RCS file: /cvs/src/sbin/growfs/growfs.c,v
> retrieving revision 1.40
> diff -u -p -r1.40 growfs.c
> --- growfs/growfs.c 20 Aug 2015 22:02:21 -0000 1.40
> +++ growfs/growfs.c 8 Nov 2015 09:38:05 -0000
> @@ -1937,8 +1937,6 @@ main(int argc, char **argv)
>   case 'y':
>   ExpertFlag = 1;
>   break;
> - case '?':
> - /* FALLTHROUGH */
>   default:
>   usage();
>   }
> Index: isakmpd/isakmpd.c
> ===================================================================
> RCS file: /cvs/src/sbin/isakmpd/isakmpd.c,v
> retrieving revision 1.103
> diff -u -p -r1.103 isakmpd.c
> --- isakmpd/isakmpd.c 20 Aug 2015 22:02:21 -0000 1.103
> +++ isakmpd/isakmpd.c 8 Nov 2015 09:38:05 -0000
> @@ -210,7 +210,6 @@ parse_args(int argc, char *argv[])
>   verbose_logging = 1;
>   break;
>
> - case '?':
>   default:
>   usage();
>   }
> Index: mknod/mknod.c
> ===================================================================
> RCS file: /cvs/src/sbin/mknod/mknod.c,v
> retrieving revision 1.18
> diff -u -p -r1.18 mknod.c
> --- mknod/mknod.c 27 Mar 2010 09:10:02 -0000 1.18
> +++ mknod/mknod.c 8 Nov 2015 09:38:05 -0000
> @@ -76,7 +76,6 @@ main(int argc, char *argv[])
>   mode = getmode(set, DEFFILEMODE);
>   free(set);
>   break;
> - case '?':
>   default:
>   usage(ismkfifo);
>   }
> Index: mount/mount.c
> ===================================================================
> RCS file: /cvs/src/sbin/mount/mount.c,v
> retrieving revision 1.60
> diff -u -p -r1.60 mount.c
> --- mount/mount.c 16 Jan 2015 06:39:59 -0000 1.60
> +++ mount/mount.c 8 Nov 2015 09:38:05 -0000
> @@ -157,7 +157,6 @@ main(int argc, char * const argv[])
>   if (!hasopt(options, "rw"))
>   options = catopt(options, "rw");
>   break;
> - case '?':
>   default:
>   usage();
>   /* NOTREACHED */
> Index: mount_cd9660/mount_cd9660.c
> ===================================================================
> RCS file: /cvs/src/sbin/mount_cd9660/mount_cd9660.c,v
> retrieving revision 1.21
> diff -u -p -r1.21 mount_cd9660.c
> --- mount_cd9660/mount_cd9660.c 16 Jan 2015 06:39:59 -0000 1.21
> +++ mount_cd9660/mount_cd9660.c 8 Nov 2015 09:38:05 -0000
> @@ -91,7 +91,6 @@ main(int argc, char *argv[])
>   errx(1, "session number is %s: %s", errstr,
>      optarg);
>   break;
> - case '?':
>   default:
>   usage();
>   }
> Index: mount_ext2fs/mount_ext2fs.c
> ===================================================================
> RCS file: /cvs/src/sbin/mount_ext2fs/mount_ext2fs.c,v
> retrieving revision 1.17
> diff -u -p -r1.17 mount_ext2fs.c
> --- mount_ext2fs/mount_ext2fs.c 16 Jan 2015 06:39:59 -0000 1.17
> +++ mount_ext2fs/mount_ext2fs.c 8 Nov 2015 09:38:05 -0000
> @@ -65,7 +65,6 @@ main(int argc, char *argv[])
>   case 'o':
>   getmntopts(optarg, mopts, &mntflags);
>   break;
> - case '?':
>   default:
>   ext2fs_usage();
>   }
> Index: mount_ffs/mount_ffs.c
> ===================================================================
> RCS file: /cvs/src/sbin/mount_ffs/mount_ffs.c,v
> retrieving revision 1.21
> diff -u -p -r1.21 mount_ffs.c
> --- mount_ffs/mount_ffs.c 16 Jan 2015 06:39:59 -0000 1.21
> +++ mount_ffs/mount_ffs.c 8 Nov 2015 09:38:05 -0000
> @@ -70,7 +70,6 @@ main(int argc, char *argv[])
>   case 'o':
>   getmntopts(optarg, mopts, &mntflags);
>   break;
> - case '?':
>   default:
>   ffs_usage();
>   }
> Index: mount_msdos/mount_msdos.c
> ===================================================================
> RCS file: /cvs/src/sbin/mount_msdos/mount_msdos.c,v
> retrieving revision 1.31
> diff -u -p -r1.31 mount_msdos.c
> --- mount_msdos/mount_msdos.c 2 Nov 2015 01:22:37 -0000 1.31
> +++ mount_msdos/mount_msdos.c 8 Nov 2015 09:55:34 -0000
> @@ -100,10 +100,8 @@ main(int argc, char **argv)
>   case 'o':
>   getmntopts(optarg, mopts, &mntflags);
>   break;
> - case '?':
>   default:
>   usage();
> - break;
>   }
>   }
>
> Index: mount_tmpfs/mount_tmpfs.c
> ===================================================================
> RCS file: /cvs/src/sbin/mount_tmpfs/mount_tmpfs.c,v
> retrieving revision 1.5
> diff -u -p -r1.5 mount_tmpfs.c
> --- mount_tmpfs/mount_tmpfs.c 16 Jan 2015 06:39:59 -0000 1.5
> +++ mount_tmpfs/mount_tmpfs.c 8 Nov 2015 09:38:05 -0000
> @@ -131,7 +131,6 @@ mount_tmpfs_parseargs(int argc, char *ar
>   uidset = 1;
>   break;
>
> - case '?':
>   default:
>   usage();
>   }
> Index: newfs/newfs.c
> ===================================================================
> RCS file: /cvs/src/sbin/newfs/newfs.c,v
> retrieving revision 1.100
> diff -u -p -r1.100 newfs.c
> --- newfs/newfs.c 29 Sep 2015 03:19:24 -0000 1.100
> +++ newfs/newfs.c 8 Nov 2015 09:38:05 -0000
> @@ -294,7 +294,6 @@ main(int argc, char *argv[])
>   pop = optarg;
>   break;
>  #endif
> - case '?':
>   default:
>   usage();
>   }
> Index: newfs_ext2fs/newfs_ext2fs.c
> ===================================================================
> RCS file: /cvs/src/sbin/newfs_ext2fs/newfs_ext2fs.c,v
> retrieving revision 1.17
> diff -u -p -r1.17 newfs_ext2fs.c
> --- newfs_ext2fs/newfs_ext2fs.c 14 Oct 2015 15:54:49 -0000 1.17
> +++ newfs_ext2fs/newfs_ext2fs.c 8 Nov 2015 09:38:05 -0000
> @@ -204,7 +204,6 @@ main(int argc, char *argv[])
>   errx(EXIT_FAILURE,
>      "Volume name cannot be zero length");
>   break;
> - case '?':
>   default:
>   usage();
>   }
> Index: savecore/savecore.c
> ===================================================================
> RCS file: /cvs/src/sbin/savecore/savecore.c,v
> retrieving revision 1.55
> diff -u -p -r1.55 savecore.c
> --- savecore/savecore.c 18 Oct 2015 03:17:48 -0000 1.55
> +++ savecore/savecore.c 8 Nov 2015 09:38:05 -0000
> @@ -153,7 +153,6 @@ main(int argc, char *argv[])
>   case 'z':
>   zcompress = 1;
>   break;
> - case '?':
>   default:
>   usage();
>   }
> Index: scsi/scsi.c
> ===================================================================
> RCS file: /cvs/src/sbin/scsi/scsi.c,v
> retrieving revision 1.29
> diff -u -p -r1.29 scsi.c
> --- scsi/scsi.c 20 Nov 2014 15:22:39 -0000 1.29
> +++ scsi/scsi.c 8 Nov 2015 09:38:05 -0000
> @@ -142,7 +142,6 @@ procargs(int *argc_p, char ***argv_p)
>   case 'v':
>   verbose = 1;
>   break;
> - case '?':
>   default:
>   usage();
>   }
> Index: ttyflags/ttyflags.c
> ===================================================================
> RCS file: /cvs/src/sbin/ttyflags/ttyflags.c,v
> retrieving revision 1.13
> diff -u -p -r1.13 ttyflags.c
> --- ttyflags/ttyflags.c 4 Dec 2012 02:27:00 -0000 1.13
> +++ ttyflags/ttyflags.c 8 Nov 2015 09:38:05 -0000
> @@ -78,7 +78,6 @@ main(int argc, char *argv[])
>   case 'v':
>   vflag = 1;
>   break;
> - case '?':
>   default:
>   usage();
>   }
>