Fix -Wimplicit-fallthrough=5 warnings

Modern Linux (since 5.4) builds with -Wimplicit-fallthrough=5.  On some
environments (notably Debian buster) this is even an error, so building
dahdi-linux will fail.

Let's add the proper 'fallthrough' annotation of
linux/compiler_attributes.h and add a backwards-compatibility definition
for older kernels.

Change-Id: I3507876d90dd882b95c22ece51e8620ad6f0bd08
This commit is contained in:
Harald Welte 2022-04-24 19:21:58 +02:00
parent c61d75d80e
commit 69b223e58d
5 changed files with 19 additions and 8 deletions

View File

@ -7961,7 +7961,7 @@ static inline void __dahdi_process_getaudio_chunk(struct dahdi_chan *ss, unsigne
memset(getlin, 0, DAHDI_CHUNKSIZE * sizeof(short));
txb[0] = DAHDI_LIN2X(0, ms);
memset(txb + 1, txb[0], DAHDI_CHUNKSIZE - 1);
/* fall through to normal conf mode */
fallthrough;
case DAHDI_CONF_CONF: /* Normal conference mode */
if (is_pseudo_chan(ms)) /* if pseudo-channel */
{
@ -7985,7 +7985,7 @@ static inline void __dahdi_process_getaudio_chunk(struct dahdi_chan *ss, unsigne
memset(txb + 1, txb[0], DAHDI_CHUNKSIZE - 1);
break;
}
/* fall through */
fallthrough;
case DAHDI_CONF_CONFMON: /* Conference monitor mode */
if (ms->confmode & DAHDI_CONF_LISTENER) {
/* Subtract out last sample written to conf */
@ -8524,7 +8524,7 @@ static void __dahdi_hooksig_pvt(struct dahdi_chan *chan, enum dahdi_rxsig rxsig)
break;
}
#endif
/* fall through intentionally */
fallthrough;
case DAHDI_SIG_FXSGS: /* FXS Groundstart */
if (rxsig == DAHDI_RXSIG_ONHOOK) {
chan->ringdebtimer = RING_DEBOUNCE_TIME;
@ -8543,7 +8543,7 @@ static void __dahdi_hooksig_pvt(struct dahdi_chan *chan, enum dahdi_rxsig rxsig)
chan->gotgs = 1;
}
}
/* fall through intentionally */
fallthrough;
case DAHDI_SIG_FXOLS: /* FXO Loopstart */
case DAHDI_SIG_FXOKS: /* FXO Kewlstart */
switch(rxsig) {
@ -8643,7 +8643,7 @@ void dahdi_rbsbits(struct dahdi_chan *chan, int cursig)
__dahdi_hooksig_pvt(chan, DAHDI_RXSIG_START);
break;
}
/* Fall through */
fallthrough;
case DAHDI_SIG_EM_E1:
case DAHDI_SIG_FXOLS: /* FXO Loopstart */
case DAHDI_SIG_FXOKS: /* FXO Kewlstart */
@ -8661,7 +8661,7 @@ void dahdi_rbsbits(struct dahdi_chan *chan, int cursig)
break;
case DAHDI_SIG_FXSKS: /* FXS Kewlstart */
case DAHDI_SIG_FXSGS: /* FXS Groundstart */
/* Fall through */
fallthrough;
case DAHDI_SIG_FXSLS:
if (!(cursig & DAHDI_BBIT)) {
/* Check for ringing first */
@ -9090,7 +9090,7 @@ static inline void __dahdi_process_putaudio_chunk(struct dahdi_chan *ss, unsigne
memcpy(ss->putlin, putlin, DAHDI_CHUNKSIZE * sizeof(short));
break;
}
/* fall through */
fallthrough;
case DAHDI_CONF_CONFANN: /* Conference with announce */
if (ms->confmode & DAHDI_CONF_TALKER) {
/* Store temp value */

View File

@ -1445,6 +1445,7 @@ wcaxx_check_battery_lost(struct wcaxx *wc, struct wcaxx_module *const mod)
break;
case BATTERY_UNKNOWN:
mod_hooksig(wc, mod, DAHDI_RXSIG_ONHOOK);
fallthrough;
case BATTERY_PRESENT:
fxo->battery_state = BATTERY_DEBOUNCING_LOST;
fxo->battdebounce_timer = wc->framecount + battdebounce;
@ -1553,6 +1554,7 @@ wcaxx_check_battery_present(struct wcaxx *wc, struct wcaxx_module *const mod)
break;
case BATTERY_UNKNOWN:
mod_hooksig(wc, mod, DAHDI_RXSIG_OFFHOOK);
fallthrough;
case BATTERY_LOST: /* intentional drop through */
fxo->battery_state = BATTERY_DEBOUNCING_PRESENT;
fxo->battdebounce_timer = wc->framecount + battdebounce;

View File

@ -1954,6 +1954,7 @@ wctdm_check_battery_lost(struct wctdm *wc, struct wctdm_module *const mod)
break;
case BATTERY_UNKNOWN:
mod_hooksig(wc, mod, DAHDI_RXSIG_ONHOOK);
fallthrough;
case BATTERY_PRESENT:
fxo->battery_state = BATTERY_DEBOUNCING_LOST;
fxo->battdebounce_timer = wc->framecount + battdebounce;
@ -2062,6 +2063,7 @@ wctdm_check_battery_present(struct wctdm *wc, struct wctdm_module *const mod)
break;
case BATTERY_UNKNOWN:
mod_hooksig(wc, mod, DAHDI_RXSIG_OFFHOOK);
fallthrough;
case BATTERY_LOST: /* intentional drop through */
fxo->battery_state = BATTERY_DEBOUNCING_PRESENT;
fxo->battdebounce_timer = wc->framecount + battdebounce;

View File

@ -148,7 +148,7 @@ static int execute_chip_command(xpd_t *xpd, const int argc, char *argv[])
XPD_NOTICE(xpd,
"'I' is deprecated in register commands. "
"Use 'S' instead.\n");
/* fall through */
fallthrough;
case 'S':
do_subreg = 1;
num_args += 2; /* register + subreg */

View File

@ -58,6 +58,13 @@
#include <linux/poll.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 20, 0)
#include <linux/compiler_attributes.h>
#endif
#ifndef fallthrough
#define fallthrough do {} while (0) /* fallthrough */
#endif
#ifdef CONFIG_PCI
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0)
#include <linux/pci.h>