From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54335) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aQgZP-0003Tb-Vn for qemu-devel@nongnu.org; Tue, 02 Feb 2016 14:25:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aQgZO-0000Hs-Ql for qemu-devel@nongnu.org; Tue, 02 Feb 2016 14:24:59 -0500 References: <1CF37786-9AAA-4E5E-B571-DE20E7A463EB@gmail.com> <20160202171606.GM18461@redhat.com> <72A30A67-5846-4835-B8D2-B7F545F76C0B@gmail.com> <20160202173111.GN18461@redhat.com> <70C3852E-1807-419B-9205-F24B5409EABF@gmail.com> From: Eric Blake Message-ID: <56B10282.1030609@redhat.com> Date: Tue, 2 Feb 2016 12:24:50 -0700 MIME-Version: 1.0 In-Reply-To: <70C3852E-1807-419B-9205-F24B5409EABF@gmail.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="TgsdwNcrg3LlsdAkVoPcvqPvq9h2KmBOT" Subject: Re: [Qemu-devel] ping: [PATCH v13] block/raw-posix.c: Make physical devices usable in QEMU under Mac OS X host List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Programmingkid , "Daniel P. Berrange" Cc: Kevin Wolf , qemu-devel qemu-devel , Qemu-block This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --TgsdwNcrg3LlsdAkVoPcvqPvq9h2KmBOT Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 02/02/2016 12:10 PM, Programmingkid wrote: >> There was/is no leak because it qdict_get_str() returns 'const char *'= and >> so nothing needs freeing. So your change is still a backwards steps IM= HO. >=20 > char filename[MAXPATHLEN]; > snprintf(filename, MAXPATHLEN, "%s", qdict_get_str(options, "filename")= ); >=20 > So you want the above to be changed so that it goes back to this: >=20 > const char *filename =3D qdict_get_str(options, "filename"); Correct. >=20 > then this code would have to be changed: >=20 > snprintf(filename, MAXPATHLEN, "%s", bsd_path); > qdict_put(options, "filename", qstring_from_str(filename)); >=20 > I could change it to this: >=20 > qdict_put(options, "filename", qstring_from_str(bsd_path)); Correct. >=20 > If I did that, then this part would not be accurate anymore: >=20 > if (strncmp(filename, "/dev/", 5) =3D=3D 0) { > print_unmounting_directions(filename); > return -1; > } >=20 > filename would be just "/dev/cdrom" for when the user uses the optical = drive. This would print incorrect unmounting directions.=20 So fix it to call print_unmounting_directions(bsd_path), after hoisting the declaration of bsd_path to be earlier to have a long enough scope. >=20 > I could add another variable that keeps track of the real device name, = but that would consume more memory. It is so much easier and simpler to j= ust use the fixed array. And why isn't bsd_path usable for that purpose? --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --TgsdwNcrg3LlsdAkVoPcvqPvq9h2KmBOT 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/ iQEcBAEBCAAGBQJWsQKCAAoJEKeha0olJ0Nq0/YH/jJA9kLPrNc/m2nWEKrLVqZZ kq3t/LylA8UyZOHoOd+Cp6mG5mruz+9vFFh3RRIjbQsISyWCasr9Vyk5lXnOT/rZ 4dyBPe4FQo+Y4sECW+pYxmazcK3a+WucgPxHQhmLRs9iDyNGjgHVmlqW+gxrzCn/ a+jvCRZmlwq2v3wytBKIgtrhI99g5w2fLEjescdWbwJjhUlQ03nEaj0AsYm2Rr7x nci3AgWnG8zRyJfefaQ38/Rkl/toxFFUIRFoLyTwVNz5FwINRKMzTsXmH+ehi9gg 0eU7ihtbiX0okXoRuqWCtz/u/N8H+4jyvyG3245tZVZ5Wmlb1hoqB91MZgX0zbQ= =QbGS -----END PGP SIGNATURE----- --TgsdwNcrg3LlsdAkVoPcvqPvq9h2KmBOT--