Fix return value of make_filename() when no filename_format
authorTomohiro Kusumi <tkusumi@tuxera.com>
Tue, 28 Mar 2017 20:02:49 +0000 (23:02 +0300)
committerJens Axboe <axboe@fb.com>
Tue, 28 Mar 2017 21:14:20 +0000 (15:14 -0600)
This is unlikely to happen in the first place since ->filename_format
has a default value, and option parser can also detect an empty string,
but it should return buf which is sprintf'd right before returning.

A caller expects this function to return filename string (which is
buf arg itself in this case), and it also doesn't handle NULL return.

Signed-off-by: Tomohiro Kusumi <tkusumi@tuxera.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
init.c

diff --git a/init.c b/init.c
index 4a722555fda9ae612540b96c7d32023ed3a7bed9..6af6c450fb6c3f98bfdee648344ae9dc69923ed1 100644 (file)
--- a/init.c
+++ b/init.c
@@ -1121,7 +1121,7 @@ static char *make_filename(char *buf, size_t buf_size,struct thread_options *o,
 
        if (!o->filename_format || !strlen(o->filename_format)) {
                sprintf(buf, "%s.%d.%d", jobname, jobnum, filenum);
-               return NULL;
+               return buf;
        }
 
        for (f = &fpre_keywords[0]; f->keyword; f++)