]> git.baikalelectronics.ru Git - kernel.git/commitdiff
block: Change the type of req_op() and bio_op() into enum req_op
authorBart Van Assche <bvanassche@acm.org>
Thu, 14 Jul 2022 18:06:30 +0000 (11:06 -0700)
committerJens Axboe <axboe@kernel.dk>
Thu, 14 Jul 2022 18:14:30 +0000 (12:14 -0600)
Improve static type checking by changing the type of the value returned by
req_op() and bio_op() from unsigned int into enum req_op. Insert
'default: break;' in switch statements on the enum req_op type to prevent
that the compiler warns about these switch statements.

Cc: Christoph Hellwig <hch@lst.de>
Cc: Ming Lei <ming.lei@redhat.com>
Cc: Hannes Reinecke <hare@suse.de>
Cc: Damien Le Moal <damien.lemoal@wdc.com>
Cc: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Cc: Tim Waugh <tim@cyberelk.net>
Cc: Alasdair Kergon <agk@redhat.com>
Cc: Mike Snitzer <snitzer@kernel.org>
Cc: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Link: https://lore.kernel.org/r/20220714180729.1065367-5-bvanassche@acm.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-merge.c
drivers/block/paride/pd.c
drivers/md/dm.c
include/linux/blk-mq.h
include/linux/blk_types.h

index 5abf5aa5a5f0eaae1334436c05332f07318717a4..de178a8b4c820cfe7db36fb4fdbc149dd85eb860 100644 (file)
@@ -405,6 +405,8 @@ unsigned int blk_recalc_rq_segments(struct request *rq)
                return 1;
        case REQ_OP_WRITE_ZEROES:
                return 0;
+       default:
+               break;
        }
 
        rq_for_each_bvec(bv, rq, iter)
index c8c14c6f5c3a273ec91f31fb8122d317882697f9..f8a75bc90f70c8b4af8d7f095957fa872342aff1 100644 (file)
@@ -501,6 +501,8 @@ static enum action do_pd_io_start(void)
                        return do_pd_read_start();
                else
                        return do_pd_write_start();
+       default:
+               break;
        }
        return Fail;
 }
index 33d3799bb66ecb77a0abea15f8cc3f5c3e651521..6c21922b87d0c537bd3a8a1313f30013e9bde761 100644 (file)
@@ -1542,6 +1542,8 @@ static blk_status_t __process_abnormal_io(struct clone_info *ci,
        case REQ_OP_WRITE_ZEROES:
                num_bios = ti->num_write_zeroes_bios;
                break;
+       default:
+               break;
        }
 
        /*
index d74f6a6b7e69b7e3b672378faed7f0259106a403..677195de06630f0eedbb75ab02b15de182375f1c 100644 (file)
@@ -198,8 +198,10 @@ struct request {
        void *end_io_data;
 };
 
-#define req_op(req) \
-       ((req)->cmd_flags & REQ_OP_MASK)
+static inline enum req_op req_op(const struct request *req)
+{
+       return req->cmd_flags & REQ_OP_MASK;
+}
 
 static inline bool blk_rq_is_passthrough(struct request *rq)
 {
index cce8768bc00b16ce531d169e419b1b6401e58195..e66cbe377ae8f9a0c4a73fd56fa61d0d813af6ca 100644 (file)
@@ -463,8 +463,10 @@ enum stat_group {
        NR_STAT_GROUPS
 };
 
-#define bio_op(bio) \
-       ((bio)->bi_opf & REQ_OP_MASK)
+static inline enum req_op bio_op(const struct bio *bio)
+{
+       return bio->bi_opf & REQ_OP_MASK;
+}
 
 /* obsolete, don't use in new code */
 static inline void bio_set_op_attrs(struct bio *bio, unsigned op,