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 <vincent.fu@xxxxxxxxxxx> --- 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