From: Vincent Fu Date: Fri, 3 Dec 2021 21:10:10 +0000 (+0000) Subject: io_ddir: return appropriate string for DDIR_INVAL X-Git-Tag: fio-3.29~21 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=5ea6ec73f15e7eaa4fda497f76fd9dacba36c284;p=fio.git 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 --- 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";