]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/xen.git/commit
tools/libxl: Alter the use of rand() in testidl
authorAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 7 Aug 2015 14:06:24 +0000 (15:06 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Thu, 13 Aug 2015 09:47:08 +0000 (10:47 +0100)
commitc91d0f58dc94074cdc77c40c39ecf8e80d7b82e4
treeb1b9391d24302872428f302a5ee4099fae3a5aa9
parent4289820507df2913300d9fe6caf733e0600f0d54
tools/libxl: Alter the use of rand() in testidl

Coverity warns for every occurrence of rand(), which is made worse
because each time the IDL changes, some of the calls get re-flagged.

Collect all calls to rand() in a single function, test_rand(), which
takes a modulo parameter for convenience.  This turns 40 defects
currently into 1, which won't get re-flagged when the IDL changes.

In addition, fix the erroneous random choice for libxl_defbool_set().
"!!rand() % 1" is unconditionally 0, and even without the "% 1" would
still be very heavily skewed in one direction.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
tools/libxl/gentest.py