On 12.09.2017 15:32, Eric Blake wrote: > On 09/12/2017 05:14 AM, Thomas Huth wrote: >> On 11.09.2017 19:20, Eric Blake wrote: >>> We have several callers that were formatting the argument strings >>> themselves; consolidate this effort by adding new convenience >>> functions directly in libqtest, and update all call-sites that >>> can benefit from it. [...] >>> static void test_mon_partial(const void *data) >>> { >>> char *s; >>> - char *cli; >>> + const char *args = data; >>> >>> - cli = make_cli(data, "-smp 8 " >>> - "-numa node,nodeid=0,cpus=0-1 " >>> - "-numa node,nodeid=1,cpus=4-5 "); >>> - qtest_start(cli); >>> + global_qtest = qtest_startf("%s -smp 8 " >>> + "-numa node,nodeid=0,cpus=0-1 " >>> + "-numa node,nodeid=1,cpus=4-5 ", args); >> >> Does GCC emit a warning if you'd used data here directly? Otherwise I >> think you could simply do this without the local args variable... > > Passing void* through varargs, with the intent of the receiver parsing > it as char*, is technically undefined in C. I don't know if gcc warns, > but I'm also worried that clang might warn. I prefer to err on the side > of defined behavior in this case, even though it annoyingly requires a > temporary variable.
OK, sounds reasonable, so let's keep it! Thomas
signature.asc
Description: OpenPGP digital signature