From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54573) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XAhKK-0001fh-3G for qemu-devel@nongnu.org; Fri, 25 Jul 2014 11:22:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XAhKC-0004AL-JP for qemu-devel@nongnu.org; Fri, 25 Jul 2014 11:22:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45521) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XAhKC-0004AH-AL for qemu-devel@nongnu.org; Fri, 25 Jul 2014 11:22:24 -0400 Date: Fri, 25 Jul 2014 16:22:19 +0100 From: Stefan Hajnoczi Message-ID: <20140725152219.GD1855@stefanha-thinkpad.redhat.com> References: <1406226665-1710-1-git-send-email-marc.mari.barcelo@gmail.com> <1406226665-1710-4-git-send-email-marc.mari.barcelo@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="XvKFcGCOAo53UbWW" Content-Disposition: inline In-Reply-To: <1406226665-1710-4-git-send-email-marc.mari.barcelo@gmail.com> Subject: Re: [Qemu-devel] [PATCH 3/7] libqtest: add QTEST_LOG for debugging qtest testcases List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Marc =?iso-8859-1?Q?Mar=ED?= Cc: Paolo Bonzini , qemu-devel@nongnu.org --XvKFcGCOAo53UbWW Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jul 24, 2014 at 08:31:01PM +0200, Marc Mar=ED wrote: > @@ -397,10 +398,18 @@ QDict *qtest_qmpv(QTestState *s, const char *fmt, v= a_list ap) > =20 > /* No need to send anything for an empty QObject. */ > if (qobj) { > + size_t len; > + int log =3D getenv("QTEST_LOG") !=3D NULL; > QString *qstr =3D qobject_to_json(qobj); > const char *str =3D qstring_get_str(qstr); > size_t size =3D qstring_get_length(qstr); > =20 > + if (log) { > + len =3D write(2, str, size); > + if (len !=3D size) { > + fprintf(stderr, "Could not log\n"); It's a bit funny that we print an error message to stderr after failing to write to stderr. Why not just fprintf(stderr, "%s", str) instead of using write()? --XvKFcGCOAo53UbWW Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJT0nYqAAoJEJykq7OBq3PISZUH/2QUZugJHFDi8uO8v5UM6hjG OxCUGt/L/nlgFE1+nnIU4PN662CBNQRCi/mmMI0wStf66JBhOg//1ogHJLcpbbVN yX/E20YJRqMy+mcgboHQNn+jC1c7LMF0q9wtDeNOuYczANVCuou0KJBVmbVO/wWw kgoaZSlQy/f9Go9VOR1hgLLM5x5I/kOMk9ytwIyHe2mH5R4KvTz5SKwxCPdTxoSc VFs8rCP5krlysraOqAF4MGefuDVCiyEoKdZjIwI7VisuQ8qEYoGlvK2AI/3bpn+j g3Bbe/ZH8ciqM/W44/wNd2op/ZiN5oReosQqP/gpjZzg7fz9a5SSBYsDPMppbL8= =ycHj -----END PGP SIGNATURE----- --XvKFcGCOAo53UbWW--