From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46148) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aQnDB-0007DO-Sw for qemu-devel@nongnu.org; Tue, 02 Feb 2016 21:30:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aQnDA-000268-VF for qemu-devel@nongnu.org; Tue, 02 Feb 2016 21:30:29 -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> <56B10282.1030609@redhat.com> <54A3ED84-6284-48A5-AF16-3B2BE27917C6@gmail.com> <56B12802.8010208@redhat.com> From: Eric Blake Message-ID: <56B1663C.5040600@redhat.com> Date: Tue, 2 Feb 2016 19:30:20 -0700 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="29oOsxqm0wd1NO86M33aNmQCE8LUWfK4k" 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 Cc: Kevin Wolf , qemu-devel qemu-devel , Qemu-block This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --29oOsxqm0wd1NO86M33aNmQCE8LUWfK4k Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 02/02/2016 06:15 PM, Programmingkid wrote: >> No, keep filename as a const char * pointer. It's easy to avoid use o= f >> uninitialized memory. Try this: >> >> const char *filename; >> char bsd_path[MAXPATHLEN] =3D ""; >> ... >> if (strncmp("/dev/cdrom"...) { >> bsd_path =3D ... >> } >> ... >> if (strncmp("/dev/"...) { >> print_unmounting_directions(*bsd_path ? bsd_path : filename); >=20 > At first I thought this code looked unusual, but it does work. Is this = ok? >=20 > #if defined(__APPLE__) && defined(__MACH__) > /* if a physical device experienced an error while being opened= */ > if (strncmp((*bsd_path ? bsd_path : filename), "/dev/", 5) =3D=3D= 0) { > print_unmounting_directions(*bsd_path ? bsd_path : filename= ); > return -1; > } A bit repetitive. You don't use filename after the fact, so shorter would be: #if defined(__APPLE__)... if (*bsd_path) { filename =3D filename; if (strncmp(filename, "/dev/"...) { print...(filename); --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --29oOsxqm0wd1NO86M33aNmQCE8LUWfK4k 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/ iQEcBAEBCAAGBQJWsWY9AAoJEKeha0olJ0NqBDgIAJbRlUo9a47rkazYtzRVRuc3 OWeOvieh/+KMDdd6eMn6UKIpDGK/B/JKgasLvmz56QgDW9KrYPzttfdwWPjnHopf FyCTa8Q1d090eE5UwyFUIk0MYK+l+7amow0qDoYh/zh99pi7POg0dTHjYR82Evjc HdWjTPWhSdBj2wTQX/JME14WjuuzxiFr7eQ7zRKQ2IX+IK94NGmlFRiGqeZXRtiD QL5tmDMX9JkDVDOJdlzKQajc9mS6Nszg9bWX6FPRHEBdQaldcKagRhMFB9JdpI8d FKIdjM/Vf4W3hlZs0WSXtbBwfvq8652nZr1LUqnMrHavfpgqPoyZawY51HB+fdY= =8I4A -----END PGP SIGNATURE----- --29oOsxqm0wd1NO86M33aNmQCE8LUWfK4k--