From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58001) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XS4I1-0002ME-G1 for qemu-devel@nongnu.org; Thu, 11 Sep 2014 09:20:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XS4Hs-0002Th-44 for qemu-devel@nongnu.org; Thu, 11 Sep 2014 09:19:57 -0400 Received: from lputeaux-656-01-25-125.w80-12.abo.wanadoo.fr ([80.12.84.125]:39791 helo=paradis.irqsave.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XS4Hr-0002So-Tv for qemu-devel@nongnu.org; Thu, 11 Sep 2014 09:19:48 -0400 Date: Thu, 11 Sep 2014 15:18:48 +0200 From: =?iso-8859-1?Q?Beno=EEt?= Canet Message-ID: <20140911131848.GB21458@irqsave.net> References: <1410336832-22160-1-git-send-email-armbru@redhat.com> <1410336832-22160-9-git-send-email-armbru@redhat.com> <20140911113433.GC8522@irqsave.net> <54119CF9.7000903@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <54119CF9.7000903@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 08/23] block: Eliminate BlockDriverState member device_name[] List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: =?iso-8859-1?Q?Beno=EEt?= Canet , kwolf@redhat.com, famz@redhat.com, Markus Armbruster , qemu-devel@nongnu.org, stefanha@redhat.com The Thursday 11 Sep 2014 =E0 07:00:41 (-0600), Eric Blake wrote : > On 09/11/2014 05:34 AM, Beno=EEt Canet wrote: > > The Wednesday 10 Sep 2014 =E0 10:13:37 (+0200), Markus Armbruster wro= te : > >> device_name[] is can become non-empty only in bdrv_new_named() and > >> bdrv_move_feature_fields(). The latter is used only to undo damage > >> done by bdrv_swap(). The former is called only by blk_new_with_bs()= . > >> Therefore, when a BlockDriverState's device_name[] is non-empty, the= n > >> it's owned by a BlockBackend. >=20 > [lots of lines trimmed - it's not only okay, but desirable to trim out > portions of a patch that you are okay with, in order to call attention > to the problem spots that you are commenting on without making the > reader have to scroll through pages of quoted context] >=20 > >> =20 > >> -const char *bdrv_get_device_name(BlockDriverState *bs) > >> +const char *bdrv_get_device_name(const BlockDriverState *bs) > >> { > >> - return bs->device_name; > >> + const char *name =3D bs->blk ? blk_name(bs->blk) : NULL; > >> + return name ?: ""; > >> } > >=20 > > Why not ? > >=20 > > return bs->blk ? blk_name(bs->blk) : ""; >=20 > If I understand right, it was because blk_name(bs->blk) may return NULL= , It think it can't: see patch 2 extract: > +BlockBackend *blk_new(const char *name, Error **errp) > +{ > + BlockBackend *blk =3D g_new0(BlockBackend, 1); > + =20 > + assert(name && name[0]); > but this function is guaranteed to return non-NULL.