Commit be21683e authored by Max Gurtovoy's avatar Max Gurtovoy Committed by Jens Axboe

block: t10-pi: fix -Wswitch warning

Changing the switch() statement to symbolic constants made the compiler
(at least clang-9, did not check gcc) notice that there is one enum value
that is not handled here:

block/t10-pi.c:62:11: error: enumeration value 'T10_PI_TYPE0_PROTECTION'
not handled in switch [-Werror,-Wswitch]

Add a BUG_ON statement if we ever get to t10_pi_verify function with
TYPE0 and replace the switch() statement with if/else clause for the
valid types.

Fixes: 9b2061b1a262 ("block: use symbolic constants for t10_pi type")
Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarMax Gurtovoy <maxg@mellanox.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent eb09b3cc
...@@ -55,13 +55,14 @@ static blk_status_t t10_pi_verify(struct blk_integrity_iter *iter, ...@@ -55,13 +55,14 @@ static blk_status_t t10_pi_verify(struct blk_integrity_iter *iter,
{ {
unsigned int i; unsigned int i;
BUG_ON(type == T10_PI_TYPE0_PROTECTION);
for (i = 0 ; i < iter->data_size ; i += iter->interval) { for (i = 0 ; i < iter->data_size ; i += iter->interval) {
struct t10_pi_tuple *pi = iter->prot_buf; struct t10_pi_tuple *pi = iter->prot_buf;
__be16 csum; __be16 csum;
switch (type) { if (type == T10_PI_TYPE1_PROTECTION ||
case T10_PI_TYPE1_PROTECTION: type == T10_PI_TYPE2_PROTECTION) {
case T10_PI_TYPE2_PROTECTION:
if (pi->app_tag == T10_PI_APP_ESCAPE) if (pi->app_tag == T10_PI_APP_ESCAPE)
goto next; goto next;
...@@ -73,12 +74,10 @@ static blk_status_t t10_pi_verify(struct blk_integrity_iter *iter, ...@@ -73,12 +74,10 @@ static blk_status_t t10_pi_verify(struct blk_integrity_iter *iter,
iter->seed, be32_to_cpu(pi->ref_tag)); iter->seed, be32_to_cpu(pi->ref_tag));
return BLK_STS_PROTECTION; return BLK_STS_PROTECTION;
} }
break; } else if (type == T10_PI_TYPE3_PROTECTION) {
case T10_PI_TYPE3_PROTECTION:
if (pi->app_tag == T10_PI_APP_ESCAPE && if (pi->app_tag == T10_PI_APP_ESCAPE &&
pi->ref_tag == T10_PI_REF_ESCAPE) pi->ref_tag == T10_PI_REF_ESCAPE)
goto next; goto next;
break;
} }
csum = fn(iter->data_buf, iter->interval); csum = fn(iter->data_buf, iter->interval);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment