From 5ea6ec73f15e7eaa4fda497f76fd9dacba36c284 Mon Sep 17 00:00:00 2001 From: Vincent Fu Date: Fri, 3 Dec 2021 21:10:10 +0000 Subject: [PATCH] io_ddir: return appropriate string for DDIR_INVAL When looking up the appropriate name for a data direction, make sure the array index is non-negative. This ensures that we return an appropriate string for DDIR_INVAL. Signed-off-by: Vincent Fu Link: https://lore.kernel.org/r/20211203211050.51241-2-vincent.fu@samsung.com Signed-off-by: Jens Axboe --- io_ddir.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/io_ddir.h b/io_ddir.h index a42da97a..296a9d04 100644 --- a/io_ddir.h +++ b/io_ddir.h @@ -24,7 +24,7 @@ static inline const char *io_ddir_name(enum fio_ddir ddir) "datasync", "sync_file_range", "wait", }; - if (ddir < DDIR_LAST) + if (ddir >= 0 && ddir < DDIR_LAST) return name[ddir]; return "invalid"; -- 2.25.1