From: Bart Van Assche Date: Fri, 8 Jan 2021 03:03:45 +0000 (-0800) Subject: engines/cpu: Fix td_vmsg() call X-Git-Tag: fio-3.26~67^2 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=f0fb0d1403ccd4789ee599b1cb22e50539e1434e;p=fio.git engines/cpu: Fix td_vmsg() call Make sure that the third td_vmsg() argument is a fully expanded string and also that the fourth argument is a string argument. This was detected by Coverity. Fixes: b213922390fe ("engines/cpu: style cleanups") Signed-off-by: Bart Van Assche --- diff --git a/engines/cpu.c b/engines/cpu.c index 68fe202a..ccbfe003 100644 --- a/engines/cpu.c +++ b/engines/cpu.c @@ -245,6 +245,7 @@ static int fio_cpuio_init(struct thread_data *td) struct thread_options *o = &td->o; struct cpu_options *co = td->eo; int td_previous_state; + char *msg; if (!co->cpuload) { td_vmsg(td, EINVAL, "cpu thread needs rate (cpuload=)","cpuio"); @@ -281,7 +282,10 @@ static int fio_cpuio_init(struct thread_data *td) qsort_init(td); break; default: - td_vmsg(td, EINVAL, "cpu engine mode bad: %d", co->cpumode); + if (asprintf(&msg, "bad cpu engine mode: %d", co->cpumode) < 0) + msg = NULL; + td_vmsg(td, EINVAL, msg ? : "(?)", __func__); + free(msg); return 1; }