From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41593) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YYrtg-0007nb-JW for qemu-devel@nongnu.org; Fri, 20 Mar 2015 04:03:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YYrtb-0002Wv-Hk for qemu-devel@nongnu.org; Fri, 20 Mar 2015 04:03:12 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:35260 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YYrtb-0002WY-C9 for qemu-devel@nongnu.org; Fri, 20 Mar 2015 04:03:07 -0400 Date: Fri, 20 Mar 2015 09:03:04 +0100 From: Alberto Garcia Message-ID: <20150320080304.GA26277@igalia.com> References: <1300de97ea0a05962e60de5aba0eb56b5b77c6ee.1426779661.git.berto@igalia.com> <87twxgi0b3.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87twxgi0b3.fsf@blackfin.pond.sub.org> Subject: Re: [Qemu-devel] [PATCH 1/3] block: add bdrv_get_device_or_node_name() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: Kevin Wolf , qemu-devel@nongnu.org, Stefan Hajnoczi On Fri, Mar 20, 2015 at 08:40:32AM +0100, Markus Armbruster wrote: > > +const char *bdrv_get_device_or_node_name(const BlockDriverState *bs) > > +{ > > + return bs->blk ? blk_name(bs->blk) : bs->node_name; > > +} > > + > > Does this have uses beyond identifying @bs to the user? None that I can think of, although apart from error messages it can also be used in data types, like the cases of BLOCK_IMAGE_CORRUPTED and BlockJobInfo that are being discussed: https://lists.gnu.org/archive/html/qemu-devel/2015-03/msg03651.html > > static void quorum_report_failure(QuorumAIOCB *acb) > > { > > - const char *reference = bdrv_get_device_name(acb->common.bs)[0] ? > > - bdrv_get_device_name(acb->common.bs) : > > - acb->common.bs->node_name; > > - > > + const char *reference = bdrv_get_device_or_node_name(acb->common.bs); > > qapi_event_send_quorum_failure(reference, acb->sector_num, > > acb->nb_sectors, &error_abort); > > } > > Preexisting: what if reference is null? It can't happen, both the device and the node name strings are guaranteed to be non-null. The latter is actually a static string so there's no chance bs->node_name returns a null pointer. Berto