From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38461) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZU07N-00071g-1M for qemu-devel@nongnu.org; Mon, 24 Aug 2015 18:21:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZU07I-00061N-37 for qemu-devel@nongnu.org; Mon, 24 Aug 2015 18:21:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44481) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZU07H-000617-RV for qemu-devel@nongnu.org; Mon, 24 Aug 2015 18:21:24 -0400 References: <29C62C49-06A5-4F99-8062-7269A28C29A3@gmail.com> From: Eric Blake Message-ID: <55DB98E1.600@redhat.com> Date: Mon, 24 Aug 2015 16:21:21 -0600 MIME-Version: 1.0 In-Reply-To: <29C62C49-06A5-4F99-8062-7269A28C29A3@gmail.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="0GcEtSu1mu8S8rFbpSttSdvOfwFOkJEaG" Subject: Re: [Qemu-devel] [PATCH] qdev-monitor.c: Add device id generation List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Programmingkid , qemu-devel qemu-devel , Markus Armbruster This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --0GcEtSu1mu8S8rFbpSttSdvOfwFOkJEaG Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 08/24/2015 12:53 PM, Programmingkid wrote: > Add device ID generation to each device if an ID isn't given. >=20 > Signed-off-by: John Arbuckle >=20 > --- > dev->id =3D id; > + } else { /* create an id for a device if none is provided */ > + static int device_id_count; > + > + /* Add one for '\0' character */ > + char *device_id =3D (char *) malloc(sizeof(char) * > + MAX_NUM_DIGITS_FOR_USB_ID = + 1); > + sprintf(device_id, "%d", device_id_count++); g_strdup_printf() is a lot nicer about avoiding the risk of arbitrary overflow... > + dev->id =3D (const char *) device_id; > + > + /* if device_id_count >=3D 10^MAX_NUM_DIGITS_FOR_USB_ID */ > + if (device_id_count >=3D pow(10, MAX_NUM_DIGITS_FOR_USB_ID)) {= > + printf("Warning: Maximum number of device ID's generated!\= n\a"); > + printf("Time for you to make your own device ID's.\n"); besides, printf() is probably the wrong way to do error reporting, and we don't use \a BEL sequences anywhere else in qemu code. > + } > } > =20 > if (dev->id) { This if would now be a dead check if your patch is applied. > object_property_add_child(qdev_get_peripheral(), dev->id, > OBJECT(dev), NULL); > - } else { > - static int anon_count; > - gchar *name =3D g_strdup_printf("device[%d]", anon_count++); > - object_property_add_child(qdev_get_peripheral_anon(), name, > - OBJECT(dev), NULL); > - g_free(name); > } It looks like your goal was to move this code earlier, but you changed enough aspects of it that I'm not sure what the right fix should be. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --0GcEtSu1mu8S8rFbpSttSdvOfwFOkJEaG Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV25jiAAoJEKeha0olJ0NqCNIH/ib/1H9rjWlW+UwfL/0ko7JZ +tFB7vywXWK8nQxCMugm6ya8StxFuj+3KF/R2ecYN9ijSFSSIVGT4vj5ZUvtuc9t zb8Yr5hS9S7OJGdvUB1tHR0vNIRvUMO2rxgapAA9KsCHTeeHw+9ijjACGLJclktr sgGdGMNOVTqzOfLikN2JrOU+fZV0eXUJA0GOAGeD0D4yAb++XfX68DNCGR4Ms/6q YZc6TS2xwnZT6JBRd46GTCuSg7Zi3/SUkq8MUXygOcuizYS2mHACZSLbRQsFyqUl X9gNqfplQkLl9g99WpVBBIeFYKJbU4Y3uKL3bbRAYIrzjOmjPyuLVEQE8LntCgo= =NlZV -----END PGP SIGNATURE----- --0GcEtSu1mu8S8rFbpSttSdvOfwFOkJEaG--