From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33973) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Veiis-0005dg-3K for qemu-devel@nongnu.org; Fri, 08 Nov 2013 04:51:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Veiin-0007Yk-3T for qemu-devel@nongnu.org; Fri, 08 Nov 2013 04:51:26 -0500 Received: from mx1.redhat.com ([209.132.183.28]:30036) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Veiim-0007YV-Rp for qemu-devel@nongnu.org; Fri, 08 Nov 2013 04:51:21 -0500 Date: Fri, 8 Nov 2013 10:51:11 +0100 From: Kevin Wolf Message-ID: <20131108095111.GA2675@dhcp-200-207.str.redhat.com> References: <1383836503-25447-1-git-send-email-benoit@irqsave.net> <1383836503-25447-2-git-send-email-benoit@irqsave.net> <527BF6CF.8070407@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="XsQoSWH+UP9D9v3l" Content-Disposition: inline In-Reply-To: <527BF6CF.8070407@redhat.com> Subject: Re: [Qemu-devel] [PATCH 1/2] block: Add bs->node_name to hold the name of a bs node of the bs graph. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: armbru@redhat.com, famz@redhat.com, =?iso-8859-1?Q?Beno=EEt?= Canet , stefanha@redhat.com, qemu-devel@nongnu.org --XsQoSWH+UP9D9v3l Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Am 07.11.2013 um 21:23 hat Eric Blake geschrieben: > On 11/07/2013 08:01 AM, Beno=EEt Canet wrote: > > Add the minimum of code to prepare the followings patches. > >=20 > > If no node_name is provided to bdrv_new the bs->node_name is set to "un= defined". > > This will allow to have some default string to communicate in QMP and H= MP. > > This also make "undefined" a reserved string for bs->node_name. > >=20 > > Signed-off-by: Benoit Canet > > --- >=20 > > + /* if node name is given store it in bs and insert bs in the graph= bs list > > + * note: undefined is a reserved node name > > + */ > > + if (node_name && > > + node_name[0] !=3D '\0' && > > + strcmp(node_name, "undefined")) { > > + pstrcpy(bs->node_name, sizeof(bs->node_name), node_name); > > + QTAILQ_INSERT_TAIL(&graph_bdrv_states, bs, node_list); > > + /* else set the bs node name to undefined for QMP and HMP */ > > + } else { > > + sprintf(bs->node_name, "undefined"); >=20 > strcpy() is more efficient than sprintf() with no % in the format string. pstrcpy() please, even if the string is currently clearly short enough for the buffer size. Or well, get rid of the "undefined" string in favour of NULL or "", then you don't even have to think about this. The magic "undefined" value is ugly anyway. Kevin --XsQoSWH+UP9D9v3l Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.14 (GNU/Linux) iQIcBAEBAgAGBQJSfLQPAAoJEH8JsnLIjy/WqPQP+gJHBPkoobYAsEwNhZXi9mZ7 f0tgha+Huuq986GTnVzgQw8Ieu6KmwJt4FtCWo/IeqbUgujlQnQSd02k/HSsDO0y puoMBgT61Ymv3vNXtX3HY+q31d1dFm2JTYjgH7A3HTxEw55g1hWk4rv21SLm/1We vPOYszqlcu6YkLqTTjQaGkk0T/34w4ZuCUDhF3odWsvEpwqpgW5i/FdkGspLoahu SZP3vkbz+cS+NjQEe6GdIpADcLluP+69VfFATvRc2dm9DpILDBhZnIajfrfJVWIv f76X9FB81547nfkjDqE2gx64zevUt3Xb/XToUUFvov2nrCqTwp/XFbwBHkI8dvSv W5kfA7UtJb477klvbnTUHB5cD/jy4q40urqyV/QasrGkM9z78UicA3exQVS9GBND ERuogi3nv7LP5kBDW2tawltaLbKqhCfok53gjVcPFPNFPu84cYBO5iRdO+A0Q7gY cAnoeGmfd2bYiU/ch0RSWLzGasU97IqT5KRhXhiQ41ja/VhazsYm7yGrHE3lEKS0 1uMGlA1lKnVsH+PNLqhexgZmguis8xAoLJnU3+tyUQzj3zgo5ci4B4WcRyMqYYOc nOBHX9+lG3fCK+zMRD6O8oKfKBSMX+bPVxvQodhVlAu0ehhN11rn2ECRH/J5j966 TwPAmfc8m/ZweGyaQ4Hh =RbmE -----END PGP SIGNATURE----- --XsQoSWH+UP9D9v3l--