Merge branch 'msys2' of https://github.com/sitsofe/fio into master
authorJens Axboe <axboe@kernel.dk>
Tue, 15 Sep 2020 01:43:39 +0000 (19:43 -0600)
committerJens Axboe <axboe@kernel.dk>
Tue, 15 Sep 2020 01:43:39 +0000 (19:43 -0600)
* 'msys2' of https://github.com/sitsofe/fio:
  travis: cleanup build script
  configure: cleanup lex/yacc tests
  memlock: avoid type confusion in format string
  Makefile: introduce FIO_CFLAGS
  appveyor: cleanup and add separate install script
  Makefile/ci: Don't pass CFLAGS when linking
  configure/Makefile: add option to generate pdb symbols
  configure: be explicit about "XP" Windows API version
  windows: fix DWORD format string complaints
  windows: fix wrong format strings
  net: coerce the result of htonl before printing
  configure: pass non-null pointer to (v)asprintf

backend.c

index 05453ae2dea1fd0105ce49414fb49bfdf7b383ff..f91f3caf9b7d82fe31b0385d5942a7b4f4414318 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -1458,16 +1458,17 @@ static bool keep_running(struct thread_data *td)
        return false;
 }
 
-static int exec_string(struct thread_options *o, const char *string, const char *mode)
+static int exec_string(struct thread_options *o, const char *string,
+                      const char *mode)
 {
-       size_t newlen = strlen(string) + strlen(o->name) + strlen(mode) + 13 + 1;
        int ret;
        char *str;
 
-       str = malloc(newlen);
-       sprintf(str, "%s > %s.%s.txt 2>&1", string, o->name, mode);
+       if (asprintf(&str, "%s > %s.%s.txt 2>&1", string, o->name, mode) < 0)
+               return -1;
 
-       log_info("%s : Saving output of %s in %s.%s.txt\n",o->name, mode, o->name, mode);
+       log_info("%s : Saving output of %s in %s.%s.txt\n", o->name, mode,
+                o->name, mode);
        ret = system(str);
        if (ret == -1)
                log_err("fio: exec of cmd <%s> failed\n", str);
@@ -1731,7 +1732,7 @@ static void *thread_main(void *data)
        if (!init_random_map(td))
                goto err;
 
-       if (o->exec_prerun && exec_string(o, o->exec_prerun, (const char *)"prerun"))
+       if (o->exec_prerun && exec_string(o, o->exec_prerun, "prerun"))
                goto err;
 
        if (o->pre_read && !pre_read_files(td))
@@ -1890,7 +1891,7 @@ static void *thread_main(void *data)
        rate_submit_exit(td);
 
        if (o->exec_postrun)
-               exec_string(o, o->exec_postrun, (const char *)"postrun");
+               exec_string(o, o->exec_postrun, "postrun");
 
        if (exitall_on_terminate || (o->exitall_error && td->error))
                fio_terminate_threads(td->groupid, td->o.exit_what);