From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60081) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VT6L1-0005qw-1E for qemu-devel@nongnu.org; Mon, 07 Oct 2013 04:38:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VT6Kn-0000vd-VB for qemu-devel@nongnu.org; Mon, 07 Oct 2013 04:38:46 -0400 Received: from mail-wg0-x22c.google.com ([2a00:1450:400c:c00::22c]:37364) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VT6Kn-0000uu-Oj for qemu-devel@nongnu.org; Mon, 07 Oct 2013 04:38:33 -0400 Received: by mail-wg0-f44.google.com with SMTP id b13so6822646wgh.35 for ; Mon, 07 Oct 2013 01:38:32 -0700 (PDT) Date: Mon, 7 Oct 2013 10:38:30 +0200 From: Stefan Hajnoczi Message-ID: <20131007083830.GE6254@stefanha-thinkpad.redhat.com> References: <1380029714-5239-1-git-send-email-pl@kamp.de> <1380029714-5239-21-git-send-email-pl@kamp.de> <524C53A9.6060607@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <524C53A9.6060607@redhat.com> Subject: Re: [Qemu-devel] [PATCHv3 20/20] block/raw: copy BlockLimits on raw_open List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: kwolf@redhat.com, stefanha@redhat.com, Peter Lieven , qemu-devel@nongnu.org, anthony@codemonkey.ws, pbonzini@redhat.com, ronniesahlberg@gmail.com On Wed, Oct 02, 2013 at 11:11:05AM -0600, Eric Blake wrote: > On 09/24/2013 07:35 AM, Peter Lieven wrote: > > Signed-off-by: Peter Lieven > > --- > > block/raw_bsd.c | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/block/raw_bsd.c b/block/raw_bsd.c > > index 8dc7bba..7af26ad 100644 > > --- a/block/raw_bsd.c > > +++ b/block/raw_bsd.c > > @@ -159,6 +159,7 @@ static int raw_open(BlockDriverState *bs, QDict *options, int flags, > > Error **errp) > > { > > bs->sg = bs->file->sg; > > + memcpy(&bs->bl, &bs->file->bl, sizeof(struct BlockLimits)); > > Personally, I think that sizeof(var) is more robust, because if the > declaration of var is ever changed, you don't have to remember to also > touch up the memcpy. As in: > > memcpy(&bs->bl, &bs->file->bl, sizeof(bs->bl)); > > But there's plenty of examples of sizeof(type) in the codebase even when > a var is handy, so you are not alone, and that's not a reason for me to > request a respin. > > On the other hand, why use memcpy() at all? > > bs->bl = bs->file->bl; > > should do the same trick, with less typing. Yes, please use struct assignment. Stefan