From: Wei Liu Subject: Re: [PATCH 2/2] tools/libxl: Alter the use of rand() in testidl Date: Fri, 7 Aug 2015 15:27:18 +0100 Message-ID: <20150807142718.GU6005@zion.uk.xensource.com> References: <1438956384-7309-1-git-send-email-andrew.cooper3@citrix.com> <1438956384-7309-3-git-send-email-andrew.cooper3@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <1438956384-7309-3-git-send-email-andrew.cooper3@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Andrew Cooper Cc: Wei Liu , Ian Jackson , Ian Campbell , Xen-devel List-Id: xen-devel@lists.xenproject.org On Fri, Aug 07, 2015 at 03:06:24PM +0100, Andrew Cooper wrote: > 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 Acked-by: Wei Liu