Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tty: n_gsm: Mark expected switch fall-throughs

In preparation to enabling -Wimplicit-fallthrough, mark switch
cases where we are expecting to fall through.

This patch fixes the following warnings:

drivers/tty/n_gsm.c: In function ‘gsm_dlci_data’:
drivers/tty/n_gsm.c:1582:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
if (tty) {
^
drivers/tty/n_gsm.c:1587:2: note: here
case 1:
^~~~
drivers/tty/n_gsm.c: In function ‘gsm1_receive’:
CC [M] drivers/scsi/snic/snic_disc.o
CC [M] drivers/net/wireless/realtek/rtlwifi/pci.o
CC drivers/usb/early/xhci-dbc.o
drivers/tty/n_gsm.c:1981:12: warning: this statement may fall through [-Wimplicit-fallthrough=]
gsm->fcs = INIT_FCS;
^
drivers/tty/n_gsm.c:1983:2: note: here
case GSM_ADDRESS: /* Address continuation */
^~~~

Warning level 3 was used: -Wimplicit-fallthrough=3

Notice that, in this particular case, the code comment is modified
in accordance with what GCC is expecting to find.

This patch is part of the ongoing efforts to enable
-Wimplicit-fallthrough.

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Gustavo A. R. Silva and committed by
Greg Kroah-Hartman
3e913eeb be24c270

+6 -9
+6 -9
drivers/tty/n_gsm.c
··· 1565 1565 pr_debug("%d bytes for tty\n", len); 1566 1566 switch (dlci->adaption) { 1567 1567 /* Unsupported types */ 1568 - /* Packetised interruptible data */ 1569 - case 4: 1568 + case 4: /* Packetised interruptible data */ 1570 1569 break; 1571 - /* Packetised uininterruptible voice/data */ 1572 - case 3: 1570 + case 3: /* Packetised uininterruptible voice/data */ 1573 1571 break; 1574 - /* Asynchronous serial with line state in each frame */ 1575 - case 2: 1572 + case 2: /* Asynchronous serial with line state in each frame */ 1576 1573 while (gsm_read_ea(&modem, *data++) == 0) { 1577 1574 len--; 1578 1575 if (len == 0) ··· 1580 1583 gsm_process_modem(tty, dlci, modem, clen); 1581 1584 tty_kref_put(tty); 1582 1585 } 1583 - /* Line state will go via DLCI 0 controls only */ 1584 - case 1: 1586 + /* Fall through */ 1587 + case 1: /* Line state will go via DLCI 0 controls only */ 1585 1588 default: 1586 1589 tty_insert_flip_string(port, data, len); 1587 1590 tty_flip_buffer_push(port); ··· 1976 1979 gsm->address = 0; 1977 1980 gsm->state = GSM_ADDRESS; 1978 1981 gsm->fcs = INIT_FCS; 1979 - /* Drop through */ 1982 + /* Fall through */ 1980 1983 case GSM_ADDRESS: /* Address continuation */ 1981 1984 gsm->fcs = gsm_fcs_add(gsm->fcs, c); 1982 1985 if (gsm_read_ea(&gsm->address, c))