From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dario Faggioli Subject: Re: [PATCH] xl: convert vcpuid to signed in main_vcpupin() Date: Wed, 3 Sep 2014 17:20:29 +0200 Message-ID: <1409757629.2673.77.camel@Solace.lan> References: <20140820153600.20604.97575.stgit@Solace.lan> <1409752371.23789.22.camel@kazak.uk.xensource.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============4686573534323911661==" Return-path: Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XPCMO-0004FF-PT for xen-devel@lists.xenproject.org; Wed, 03 Sep 2014 15:20:36 +0000 In-Reply-To: <1409752371.23789.22.camel@kazak.uk.xensource.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: Ian Campbell Cc: xen-devel , Ian Jackson List-Id: xen-devel@lists.xenproject.org --===============4686573534323911661== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-UjDZocYEcYV5J//qJLUE" --=-UjDZocYEcYV5J//qJLUE Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On mer, 2014-09-03 at 14:52 +0100, Ian Campbell wrote: > On Wed, 2014-08-20 at 17:36 +0200, Dario Faggioli wrote: > > No functional changes, it just looks more correct, considering > > that at some point in the function we assign -1 to it (and > > at some other later point we check for it to be -1), >=20 > I think that's more than just "looks more correct", it's just wrong to > compare an unsigned to -1, or to assign it. >=20 > And there may well be a functional change since gcc is no longer allowed > to assume that the number is +ve and therefore cannot discard some of > these checks any more. We are probably just lucky that gcc isn't doing > so already (and unlucky that it isn't generating a warning...) >=20 Right, and thanks for all the details. :-) Should I change the changelog, if I repost? > > Signed-off-by: Dario Faggioli > > --- > > tools/libxl/xl_cmdimpl.c | 14 +++++++------- > > 1 file changed, 7 insertions(+), 7 deletions(-) > >=20 > > diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c > > index f1c136a..a29a579 100644 > > --- a/tools/libxl/xl_cmdimpl.c > > +++ b/tools/libxl/xl_cmdimpl.c > > @@ -4601,8 +4601,9 @@ int main_vcpupin(int argc, char **argv) > > libxl_vcpuinfo *vcpuinfo; > > libxl_bitmap cpumap_hard, cpumap_soft;; > > libxl_bitmap *soft =3D &cpumap_soft, *hard =3D &cpumap_hard; > > - uint32_t vcpuid, domid; > > const char *vcpu, *hard_str, *soft_str; > > + uint32_t domid; > > + long vcpuid; >=20 > I think an int would be sufficiently large for this. >=20 The only reason why I used a long is that the function used to do the actual conversion is strtol(), which returns a long. Strictly speaking, if using an int, I think I should then be checking for the returned value to be within [INT_MIN, INT_MAX] and error out if it's not. That being said, we can probably use int and leave the range checking alone, as, if someone tries to pin vCPU INT_MAX+1, he/she deserves all the bad that will happen, but since I was polishing the code... :-P Just let me know if you want it to be and int, and if you think the range checking should be there, and I'll copy. Thanks and regards, Dario --=20 <> (Raistlin Majere) ----------------------------------------------------------------- Dario Faggioli, Ph.D, http://about.me/dario.faggioli Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK) --=-UjDZocYEcYV5J//qJLUE Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iEYEABECAAYFAlQHMb0ACgkQk4XaBE3IOsSG9gCggygeVAFWecFM8LnyPQsWgL6N xPYAn3fHJmnbVbMaJjT2AYJ7nQqczlJB =BIZG -----END PGP SIGNATURE----- --=-UjDZocYEcYV5J//qJLUE-- --===============4686573534323911661== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --===============4686573534323911661==--