commit 5b25ea20567d33171e54c9d3540fbd043cf9c1af
parent 78a77163d5673d93d86b4f2792a4c85506d37442
Author: Morel BĂ©renger <berengermorel76@gmail.com>
Date: Fri, 25 Oct 2024 17:26:43 +0200
fix -Wimplicit-fallthrough
Diffstat:
7 files changed, 52 insertions(+), 11 deletions(-)
diff --git a/build.ninja b/build.ninja
@@ -27,6 +27,7 @@ CCFLAGS = $$CCFLAGS $
-Werror=float-conversion $
-Werror=pedantic $
-Werror=unreachable-code $
+ -Werror=implicit-fallthrough$
subninja src/librunit.ninja
subninja src/runsv.ninja
diff --git a/src/chpst.c b/src/chpst.c
@@ -324,7 +324,9 @@ int main(int argc, const char **argv) {
if (optarg[scan_ulong(optarg, &ul)]) usage(); nicelvl =ul;
nicelvl *=-1;
break;
- case '+': ++optarg;
+ case '+':
+ ++optarg;
+ __attribute__((fallthrough));
default:
if (optarg[scan_ulong(optarg, &ul)]) usage(); nicelvl =ul;
break;
@@ -337,7 +339,9 @@ int main(int argc, const char **argv) {
case '0': nostdin =1; break;
case '1': nostdout =1; break;
case '2': nostderr =1; break;
- case 'V': strerr_warn1(VERSION, 0);
+ case 'V':
+ strerr_warn1(VERSION, 0);
+ __attribute__((fallthrough));
case '?': usage();
}
argv +=optind;
@@ -483,7 +487,9 @@ static void softlimit(int argc, const char *const *argv)
while ((opt =getopt(argc,argv,"a:c:d:f:l:m:o:p:r:s:t:")) != opteof)
switch(opt) {
- case '?': softlimit_usage();
+ case '?':
+ softlimit_usage();
+ __attribute__((fallthrough));
case 'a': getlarg(&limita); break;
case 'c': getlarg(&limitc); break;
case 'd': getlarg(&limitd); break;
diff --git a/src/runit-init.c b/src/runit-init.c
@@ -69,6 +69,7 @@ int main (int argc, const char * const *argv, char * const *envp) {
case '-':
if ((*argv)[1] == 'V')
strerr_warn1(VERSION "\n", 0);
+ __attribute__((fallthrough));
default:
usage();
}
diff --git a/src/runsvdir.c b/src/runsvdir.c
@@ -183,7 +183,9 @@ int main(int argc, char **argv)
if (! argv || ! *argv) usage();
if (**argv == '-') {
switch (*(*argv +1)) {
- case 'P': pgrp =1;
+ case 'P':
+ pgrp =1;
+ __attribute__((fallthrough));
case '-': ++argv;
}
if (! argv || ! *argv) usage();
diff --git a/src/sv.c b/src/sv.c
@@ -159,7 +159,13 @@ static int status(char *unused)
int rc;
rc =svstatus_get();
- switch(rc) { case -1: if (lsb) done(4); case 0: return(0); }
+ switch(rc) {
+ case -1:
+ if (lsb) done(4);
+ __attribute__((fallthrough));
+ case 0:
+ return(0);
+ }
rc =svstatus_print(*service);
islog =1;
if (chdir("log") == -1) {
@@ -175,7 +181,16 @@ static int status(char *unused)
}
islog =0;
flush("");
- if (lsb) switch(rc) { case 1: done(0); case 2: done(3); case 0: done(4); }
+ if (lsb) switch(rc) {
+ case 1:
+ done(0);
+ __attribute__((fallthrough));
+ case 2:
+ done(3);
+ __attribute__((fallthrough));
+ case 0: done(4);
+ }
+
return(rc);
}
@@ -291,9 +306,13 @@ int main(int argc, char **argv)
if ((x =env_get("SVWAIT"))) scan_ulong(x, &wait);
while ((i =getopt(argc, (const char* const*)argv, "w:vV")) != opteof) {
switch(i) {
- case 'w': scan_ulong(optarg, &wait);
+ case 'w':
+ scan_ulong(optarg, &wait);
+ __attribute__((fallthrough));
case 'v': verbose =1; break;
- case 'V': strerr_warn1(VERSION, 0);
+ case 'V':
+ strerr_warn1(VERSION, 0);
+ __attribute__((fallthrough));
case '?': usage();
}
}
@@ -319,8 +338,10 @@ int main(int argc, char **argv)
acts ="tc"; kll =1; cbk =✓ break;
case 't':
if (!str_diff(action, "try-restart")) { acts ="tc"; cbk =✓ break; }
+ __attribute__((fallthrough));
case 'c':
if (!str_diff(action, "check")) { act =0; acts ="C"; cbk =✓ break; }
+ __attribute__((fallthrough));
case 'u': case 'd': case 'o': case 'p': case 'h':
case 'a': case 'i': case 'k': case 'q': case '1': case '2':
action[1] =0; acts =action; break;
@@ -334,6 +355,7 @@ int main(int argc, char **argv)
if (!str_diff(action, "restart")) { acts ="tcu"; cbk =✓ break; }
if (!str_diff(action, "reload")) { acts ="h"; cbk =✓ break; }
usage();
+ __attribute__((fallthrough));
case 'f':
if (!str_diff(action, "force-reload"))
{ acts ="tc"; kll =1; cbk =✓ break; }
@@ -343,6 +365,7 @@ int main(int argc, char **argv)
{ acts ="x"; kll =1; cbk =✓ break; }
if (!str_diff(action, "force-stop"))
{ acts ="d"; kll =1; cbk =✓ break; }
+ __attribute__((fallthrough));
default:
usage();
}
diff --git a/src/svlogd.c b/src/svlogd.c
@@ -473,7 +473,9 @@ static unsigned int logdir_open(struct logdir *ld, const char *fn)
break;
case 's':
switch (sa.s[scan_ulong(&sa.s[i +1], &ld->sizemax) +i +1]) {
- case 'm': ld->sizemax *=1024;
+ case 'm':
+ ld->sizemax *=1024;
+ __attribute__((fallthrough));
case 'k': ld->sizemax *=1024;
}
break;
@@ -486,7 +488,9 @@ static unsigned int logdir_open(struct logdir *ld, const char *fn)
case 't':
switch (sa.s[scan_ulong(&sa.s[i +1], &ld->tmax) +i +1]) {
/* case 'd': ld->tmax *=24; */
- case 'h': ld->tmax *=60;
+ case 'h':
+ ld->tmax *=60;
+ __attribute__((fallthrough));
case 'm': ld->tmax *=60;
}
if (ld->tmax) {
@@ -505,6 +509,7 @@ static unsigned int logdir_open(struct logdir *ld, const char *fn)
break;
case 'U':
ld->udponly =1;
+ __attribute__((fallthrough));
case 'u':
if (! (c =ip4_scan(sa.s +i +1, (char *)&ld->udpaddr.sin_addr))) {
warnx("unable to scan ip address", sa.s +i +1);
@@ -727,7 +732,9 @@ int main(int argc, const char **argv)
case 'v':
++verbose;
break;
- case 'V': strerr_warn1(VERSION, 0);
+ case 'V':
+ strerr_warn1(VERSION, 0);
+ __attribute__((fallthrough));
case '?': usage();
}
}
diff --git a/src/utmpset.c b/src/utmpset.c
@@ -101,6 +101,7 @@ int main (int argc, const char * const *argv, const char * const *envp)
break;
case 'V':
strerr_warn1(VERSION, 0);
+ __attribute__((fallthrough));
case '?':
usage();
}