]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
scsi: imm: mark expected switch fall-throughs
authorGustavo A. R. Silva <gustavo@embeddedor.com>
Mon, 26 Nov 2018 18:31:53 +0000 (12:31 -0600)
committerGustavo A. R. Silva <gustavo@embeddedor.com>
Mon, 8 Apr 2019 23:37:37 +0000 (18:37 -0500)
In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.

Notice that, in this particular case, I placed all the "Phase N - ..."
comments on the same line as its corresponding switch case. The same
way in which similar comments appear in drivers/scsi/ppa.c. This makes
it possible to place the "fall through" annotations at the bottom of
each switch case, which is what GCC is expecting to find.

Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
drivers/scsi/imm.c

index cea7f502e8ca362539fcf49c008be1fdd0a4f206..64ae418d29f35dfbaa408c4dcdbfae6149c1e0a4 100644 (file)
@@ -796,21 +796,21 @@ static int imm_engine(imm_struct *dev, struct scsi_cmnd *cmd)
                        return 0;
                }
                return 1;       /* wait until imm_wakeup claims parport */
-               /* Phase 1 - Connected */
-       case 1:
+
+       case 1:         /* Phase 1 - Connected */
                imm_connect(dev, CONNECT_EPP_MAYBE);
                cmd->SCp.phase++;
+               /* fall through */
 
-               /* Phase 2 - We are now talking to the scsi bus */
-       case 2:
+       case 2:         /* Phase 2 - We are now talking to the scsi bus */
                if (!imm_select(dev, scmd_id(cmd))) {
                        imm_fail(dev, DID_NO_CONNECT);
                        return 0;
                }
                cmd->SCp.phase++;
+               /* fall through */
 
-               /* Phase 3 - Ready to accept a command */
-       case 3:
+       case 3:         /* Phase 3 - Ready to accept a command */
                w_ctr(ppb, 0x0c);
                if (!(r_str(ppb) & 0x80))
                        return 1;
@@ -818,9 +818,9 @@ static int imm_engine(imm_struct *dev, struct scsi_cmnd *cmd)
                if (!imm_send_command(cmd))
                        return 0;
                cmd->SCp.phase++;
+               /* fall through */
 
-               /* Phase 4 - Setup scatter/gather buffers */
-       case 4:
+       case 4:         /* Phase 4 - Setup scatter/gather buffers */
                if (scsi_bufflen(cmd)) {
                        cmd->SCp.buffer = scsi_sglist(cmd);
                        cmd->SCp.this_residual = cmd->SCp.buffer->length;
@@ -834,8 +834,9 @@ static int imm_engine(imm_struct *dev, struct scsi_cmnd *cmd)
                cmd->SCp.phase++;
                if (cmd->SCp.this_residual & 0x01)
                        cmd->SCp.this_residual++;
-               /* Phase 5 - Pre-Data transfer stage */
-       case 5:
+               /* fall through */
+
+       case 5:         /* Phase 5 - Pre-Data transfer stage */
                /* Spin lock for BUSY */
                w_ctr(ppb, 0x0c);
                if (!(r_str(ppb) & 0x80))
@@ -850,9 +851,9 @@ static int imm_engine(imm_struct *dev, struct scsi_cmnd *cmd)
                        if (imm_negotiate(dev))
                                return 0;
                cmd->SCp.phase++;
+               /* fall through */
 
-               /* Phase 6 - Data transfer stage */
-       case 6:
+       case 6:         /* Phase 6 - Data transfer stage */
                /* Spin lock for BUSY */
                w_ctr(ppb, 0x0c);
                if (!(r_str(ppb) & 0x80))
@@ -866,9 +867,9 @@ static int imm_engine(imm_struct *dev, struct scsi_cmnd *cmd)
                                return 1;
                }
                cmd->SCp.phase++;
+               /* fall through */
 
-               /* Phase 7 - Post data transfer stage */
-       case 7:
+       case 7:         /* Phase 7 - Post data transfer stage */
                if ((dev->dp) && (dev->rd)) {
                        if ((dev->mode == IMM_NIBBLE) || (dev->mode == IMM_PS2)) {
                                w_ctr(ppb, 0x4);
@@ -878,9 +879,9 @@ static int imm_engine(imm_struct *dev, struct scsi_cmnd *cmd)
                        }
                }
                cmd->SCp.phase++;
+               /* fall through */
 
-               /* Phase 8 - Read status/message */
-       case 8:
+       case 8:         /* Phase 8 - Read status/message */
                /* Check for data overrun */
                if (imm_wait(dev) != (unsigned char) 0xb8) {
                        imm_fail(dev, DID_ERROR);