Received: from eggs.gnu.org ([2001:4830:134:3::10]:48017) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a3mAC-0004Q8-5B for qemu-devel@nongnu.org; Tue, 01 Dec 2015 09:44:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a3mAB-0001Fg-AI for qemu-devel@nongnu.org; Tue, 01 Dec 2015 09:44:16 -0500 From: Alberto Garcia In-Reply-To: <1447127063-4662-8-git-send-email-mreitz@redhat.com> References: <1447127063-4662-1-git-send-email-mreitz@redhat.com> <1447127063-4662-8-git-send-email-mreitz@redhat.com> Date: Tue, 01 Dec 2015 15:44:06 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [Qemu-devel] [Qemu-block] [PATCH 7/8] block: Make bdrv_open() return a BDS List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz , qemu-block@nongnu.org Cc: Kevin Wolf , qemu-devel@nongnu.org On Tue 10 Nov 2015 04:44:22 AM CET, Max Reitz wrote: > @@ -1398,32 +1397,21 @@ static int bdrv_open_inherit(BlockDriverState **pbs, const char *filename, > bool options_non_empty = options ? qdict_size(options) : false; > QDECREF(options); > > - if (*pbs) { > - error_setg(errp, "Cannot reuse an existing BDS when referencing " > - "another block device"); > - return -EINVAL; > - } > - > if (filename || options_non_empty) { > error_setg(errp, "Cannot reference an existing block device with " > "additional options or a new filename"); > - return -EINVAL; > + return NULL; > } > > bs = bdrv_lookup_bs(reference, reference, errp); > if (!bs) { > - return -ENODEV; > + return NULL; > } > bdrv_ref(bs); > - *pbs = bs; > - return 0; > + return bs; > } This last part is probably a bit simpler with just one return statement: bs = bdrv_lookup_bs(reference, reference, errp); if (bs) { bdrv_ref(bs); } return bs; but I'm fine either way. Reviewed-by: Alberto Garcia Berto