Skip to content

Commit 6fa9932

Browse files
johnpgarryaxboe
authored andcommitted
block: Catch possible entries missing from cmd_flag_name[]
Add a BUILD_BUG_ON() call to ensure that we are not missing entries in cmd_flag_name[]. Reviewed-by: Bart Van Assche <[email protected]> Signed-off-by: John Garry <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 26d3bdb commit 6fa9932

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

block/blk-mq-debugfs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,8 @@ int __blk_mq_debugfs_rq_show(struct seq_file *m, struct request *rq)
281281
const enum req_op op = req_op(rq);
282282
const char *op_str = blk_op_str(op);
283283

284+
BUILD_BUG_ON(ARRAY_SIZE(cmd_flag_name) != __REQ_NR_BITS);
285+
284286
seq_printf(m, "%p {.op=", rq);
285287
if (strcmp(op_str, "UNKNOWN") == 0)
286288
seq_printf(m, "%u", op);

include/linux/blk_types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ enum req_op {
354354
REQ_OP_LAST = (__force blk_opf_t)36,
355355
};
356356

357+
/* Keep cmd_flag_name[] in sync with the definitions below */
357358
enum req_flag_bits {
358359
__REQ_FAILFAST_DEV = /* no driver retries of device errors */
359360
REQ_OP_BITS,

0 commit comments

Comments
 (0)