From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43356) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjqQl-0001uS-UM for qemu-devel@nongnu.org; Tue, 13 Sep 2016 12:19:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bjqQl-0000YB-16 for qemu-devel@nongnu.org; Tue, 13 Sep 2016 12:19:31 -0400 Date: Tue, 13 Sep 2016 17:19:21 +0100 From: Stefan Hajnoczi Message-ID: <20160913161921.GF5677@stefanha-x1.localdomain> References: <20160826091643.15841-1-fullmanet@gmail.com> <20160826091643.15841-6-fullmanet@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="L2Brqb15TUChFOBK" Content-Disposition: inline In-Reply-To: <20160826091643.15841-6-fullmanet@gmail.com> Subject: Re: [Qemu-devel] [PATCH v2 5/7] qemu-img: add status option to dd List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Reda Sallahi Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Kevin Wolf , Max Reitz , Fam Zheng --L2Brqb15TUChFOBK Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Aug 26, 2016 at 11:16:41AM +0200, Reda Sallahi wrote: > +static int img_dd_status(const char *arg, > + struct DdIo *in, struct DdIo *out, > + struct DdInfo *dd) > +{ > + const struct DdSymbols dd_status[] =3D { > + { "none", C_STATUS_NONE }, > + { "noxfer", C_STATUS_NOXFER }, > + { NULL, 0 } > + }; > + > + for (int j =3D 0; dd_status[j].name !=3D NULL; j++) { > + if (!strcmp(arg, dd_status[j].name)) { > + dd->status =3D dd_status[j].value; > + return 0; > + } > + } Here you can use the existing flags parsing function if you change the function argument to unsigned int *flags_bits as mentioned in another reply. Then you can pass in &dd->status. > + > + error_report("invalid status level: '%s'", arg); > + return 1; > +} > =20 > static int img_dd(int argc, char **argv) > { > @@ -4067,13 +4097,16 @@ static int img_dd(int argc, char **argv) > const char *out_filename; > int64_t size =3D 0, out_size =3D 0; > int64_t out_pos, in_pos, sparse_count =3D 0; > + int64_t in_read =3D 0, out_wrt =3D 0; /* Read/write count for status= =3D */ > bool writethrough =3D false; > int flags =3D 0; > int ibsz =3D 0, obsz =3D 0, bsz; > + struct timeval starttv, endtv; Please use qemu_timeval instead of the system timeval type. --L2Brqb15TUChFOBK Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEcBAEBAgAGBQJX2CcJAAoJEJykq7OBq3PI+70H/3ZKIeTDBdwpi5G9V5vf/56G juTUiYJoX0vDyCG46pVv0VOmVcEFEDUjqE0vMfe+9d2h50ESom1GCQKTetimxEnt pqBp7r69NTI5vE5LSCLDzgG/vKezCcZfH1pA0bQXtfxUoM3Jsp8ORe81lZXBEma7 IxIqkQ6Ksuw8uI4XKlUiCBOY/hY5SGsZn3UOSGRtm6khuajvExt55pnDoae7nHx4 ljY9m/QjkDxnP10cznFodZeGDjzt5P9BFCTJdVwe7l/iDWLfZVAZaQ1uYLae7ACb Cth4v+fFeFWbaCI//l5keBrz6zIuTntZXcP1as/JoUqkKhv9Hr+oyJyh+WG0Y+E= =15Ow -----END PGP SIGNATURE----- --L2Brqb15TUChFOBK--