Skip to contentSkip to conversation

HSI: ssi_protocol: Mark expected switch fall-throughs

PATCH In review Gustavo A. R. Silva 3 participants 3 messages Jul 29, 2019 – Jul 30, 2019 HSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 HSI: ssi_protocol: Mark expected switch fall-throughs

Mark switch cases where we are expecting to fall through.

This patch fixes the following warning (Building: arm):

drivers/hsi/clients/ssi_protocol.c: In function ‘ssip_set_rxstate’:
drivers/hsi/clients/ssi_protocol.c:291:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
if (atomic_read(&ssi->tx_usecnt))

      ^

drivers/hsi/clients/ssi_protocol.c:294:2: note: here
case RECEIVING:
^~~~

drivers/hsi/clients/ssi_protocol.c: In function ‘ssip_keep_alive’:
drivers/hsi/clients/ssi_protocol.c:466:7: warning: this statement may fall through [-Wimplicit-fallthrough=]

    if (atomic_read(&ssi->tx_usecnt) == 0)
       ^

drivers/hsi/clients/ssi_protocol.c:472:3: note: here
case SEND_IDLE:
^~~~

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

---
 drivers/hsi/clients/ssi_protocol.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/hsi/clients/ssi_protocol.c +4 -3
index 9aeed98b87a1..504d00ec1ea7 100644
@@ -290,7 +290,7 @@ static void ssip_set_rxstate(struct ssi_protocol *ssi, unsigned int state)
 		/* CMT speech workaround */
 		if (atomic_read(&ssi->tx_usecnt))
 			break;
-		/* Otherwise fall through */
+		/* Else, fall through */
 	case RECEIVING:
 		mod_timer(&ssi->keep_alive, jiffies +
 						msecs_to_jiffies(SSIP_KATOUT));
@@ -465,9 +465,10 @@ static void ssip_keep_alive(struct timer_list *t)
 		case SEND_READY:
 			if (atomic_read(&ssi->tx_usecnt) == 0)
 				break;
+			/* Fall through */
 			/*
-			 * Fall through. Workaround for cmt-speech
-			 * in that case we relay on audio timers.
+			 * Workaround for cmt-speech in that case
+			 * we relay on audio timers.
 			 */
 		case SEND_IDLE:
 			spin_unlock(&ssi->lock);
Signature · 1 line
2.22.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 20 lines · Gustavo A. R. Silva

Mark switch cases where we are expecting to fall through.

This patch fixes the following warning (Building: arm):

drivers/hsi/clients/ssi_protocol.c: In function ‘ssip_set_rxstate’:
drivers/hsi/clients/ssi_protocol.c:291:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
if (atomic_read(&ssi->tx_usecnt))

      ^

drivers/hsi/clients/ssi_protocol.c:294:2: note: here
case RECEIVING:
^~~~

drivers/hsi/clients/ssi_protocol.c: In function ‘ssip_keep_alive’:
drivers/hsi/clients/ssi_protocol.c:466:7: warning: this statement may fall through [-Wimplicit-fallthrough=]

    if (atomic_read(&ssi->tx_usecnt) == 0)
       ^
drivers/hsi/clients/ssi_protocol.c:472:3: note: here
   case SEND_IDLE:
   ^~~~
Quoted 4 lines

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

-Kees

Quoted 33 lines
---
 drivers/hsi/clients/ssi_protocol.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/hsi/clients/ssi_protocol.c +4 -3
index 9aeed98b87a1..504d00ec1ea7 100644
@@ -290,7 +290,7 @@ static void ssip_set_rxstate(struct ssi_protocol *ssi, unsigned int state)
 		/* CMT speech workaround */
 		if (atomic_read(&ssi->tx_usecnt))
 			break;
-		/* Otherwise fall through */
+		/* Else, fall through */
 	case RECEIVING:
 		mod_timer(&ssi->keep_alive, jiffies +
 						msecs_to_jiffies(SSIP_KATOUT));
@@ -465,9 +465,10 @@ static void ssip_keep_alive(struct timer_list *t)
 		case SEND_READY:
 			if (atomic_read(&ssi->tx_usecnt) == 0)
 				break;
+			/* Fall through */
 			/*
-			 * Fall through. Workaround for cmt-speech
-			 * in that case we relay on audio timers.
+			 * Workaround for cmt-speech in that case
+			 * we relay on audio timers.
 			 */
 		case SEND_IDLE:
 			spin_unlock(&ssi->lock);
Signature · 1 line
2.22.0
Signature · 1 line
Kees Cook
#2 lore raw
In reply to Gustavo A. R. Silva

Hi,

Quoted 20 lines · Gustavo A. R. Silva

Mark switch cases where we are expecting to fall through.

This patch fixes the following warning (Building: arm):

drivers/hsi/clients/ssi_protocol.c: In function ‘ssip_set_rxstate’:
drivers/hsi/clients/ssi_protocol.c:291:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
if (atomic_read(&ssi->tx_usecnt))

      ^

drivers/hsi/clients/ssi_protocol.c:294:2: note: here
case RECEIVING:
^~~~

drivers/hsi/clients/ssi_protocol.c: In function ‘ssip_keep_alive’:
drivers/hsi/clients/ssi_protocol.c:466:7: warning: this statement may fall through [-Wimplicit-fallthrough=]

    if (atomic_read(&ssi->tx_usecnt) == 0)
       ^
drivers/hsi/clients/ssi_protocol.c:472:3: note: here
   case SEND_IDLE:
   ^~~~
Quoted 5 lines

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

---

Thanks, queued to hsi-next.

-- Sebastian

Quoted 32 lines
 drivers/hsi/clients/ssi_protocol.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/hsi/clients/ssi_protocol.c +4 -3
index 9aeed98b87a1..504d00ec1ea7 100644
@@ -290,7 +290,7 @@ static void ssip_set_rxstate(struct ssi_protocol *ssi, unsigned int state)
 		/* CMT speech workaround */
 		if (atomic_read(&ssi->tx_usecnt))
 			break;
-		/* Otherwise fall through */
+		/* Else, fall through */
 	case RECEIVING:
 		mod_timer(&ssi->keep_alive, jiffies +
 						msecs_to_jiffies(SSIP_KATOUT));
@@ -465,9 +465,10 @@ static void ssip_keep_alive(struct timer_list *t)
 		case SEND_READY:
 			if (atomic_read(&ssi->tx_usecnt) == 0)
 				break;
+			/* Fall through */
 			/*
-			 * Fall through. Workaround for cmt-speech
-			 * in that case we relay on audio timers.
+			 * Workaround for cmt-speech in that case
+			 * we relay on audio timers.
 			 */
 		case SEND_IDLE:
 			spin_unlock(&ssi->lock);
Signature · 1 line
2.22.0