From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33391) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aQgul-00059N-Un for qemu-devel@nongnu.org; Tue, 02 Feb 2016 14:47:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aQgui-0005aE-NK for qemu-devel@nongnu.org; Tue, 02 Feb 2016 14:47:03 -0500 Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii From: Programmingkid In-Reply-To: <56B10282.1030609@redhat.com> Date: Tue, 2 Feb 2016 14:46:57 -0500 Content-Transfer-Encoding: quoted-printable Message-Id: 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> <56B10282.1030609@redhat.com> 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: Eric Blake Cc: Kevin Wolf , qemu-devel qemu-devel , Qemu-block On Feb 2, 2016, at 2:24 PM, Eric Blake wrote: > On 02/02/2016 12:10 PM, Programmingkid wrote: >=20 >>> 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 = IMHO. >>=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"); >=20 > Correct. >=20 >>=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)); >=20 > Correct. >=20 >>=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 >=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. ok >=20 >>=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 just use the fixed array. >=20 > And why isn't bsd_path usable for that purpose? bsd_path can be used for that purpose.=20=