From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dario Faggioli Subject: Re: [PATCH v2 5/5] xl: improve return and exit codes of parse related functions Date: Mon, 26 Oct 2015 11:40:28 +0100 Message-ID: <1445856028.2717.57.camel@citrix.com> References: <1445664696-14258-1-git-send-email-write.harmandeep@gmail.com> <1445664696-14258-6-git-send-email-write.harmandeep@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============4382045475104852073==" Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ZqfCi-0006ps-J5 for xen-devel@lists.xenproject.org; Mon, 26 Oct 2015 10:40:40 +0000 In-Reply-To: <1445664696-14258-6-git-send-email-write.harmandeep@gmail.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: Harmandeep Kaur , xen-devel@lists.xenproject.org Cc: lars.kurth@citrix.com, wei.liu2@citrix.com, ian.campbell@citrix.com, stefano.stabellini@eu.citrix.com, ian.jackson@eu.citrix.com, george.dunlap@citrix.com List-Id: xen-devel@lists.xenproject.org --===============4382045475104852073== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-S0hTg1GaRCQA3K85XeMT" --=-S0hTg1GaRCQA3K85XeMT Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sat, 2015-10-24 at 11:01 +0530, Harmandeep Kaur wrote: > turning parsing related functions xl exit codes towards using the > EXIT_[SUCCESS|FAILURE] macros, instead of instead of arbitrary > numbers > or libxl return codes. >=20 > it doesn't include parse_config_data() which is big enough to deserve > its > own patch >=20 > Signed-off-by: Harmandeep Kaur > libxl_bitmap *cpumap) > static int cpurange_parse(const char *cpu, libxl_bitmap *cpumap) > { > char *ptr, *saveptr =3D NULL, *buf =3D strdup(cpu); > - int rc =3D 0; > =20 > for (ptr =3D strtok_r(buf, ",", &saveptr); ptr; > ptr =3D strtok_r(NULL, ",", &saveptr)) { > - rc =3D update_cpumap_range(ptr, cpumap); > - if (rc) > + if (update_cpumap_range(ptr, cpumap)) > break; > } > free(buf); > =20 > - return rc; > + return 0; > } > =20 Oh, and also, here: I think rc is needed, in this case, to properly deal with the failure of update_cpumap_range(), and poperly propagate that failure to the caller. If you want to get rid of it, you should do something like this, inside the loop: if (update_cpumap_range(ptr, cpumap)) { free(buf); return 1; } Regards, Dario --=20 <> (Raistlin Majere) ----------------------------------------------------------------- Dario Faggioli, Ph.D, http://about.me/dario.faggioli Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK) --=-S0hTg1GaRCQA3K85XeMT 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 v1 iEYEABECAAYFAlYuAxwACgkQk4XaBE3IOsQYVACgmQXQ6SQmR5knvOIJiZxSYpJH iDUAn0TnvJnkH8QdqFlKZOn9dCJMhanK =bSZm -----END PGP SIGNATURE----- --=-S0hTg1GaRCQA3K85XeMT-- --===============4382045475104852073== 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 --===============4382045475104852073==--