From patchwork Tue Jun 5 14:19:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jeff Cody X-Patchwork-Id: 10448431 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C2A596024A for ; Tue, 5 Jun 2018 14:25:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B0F30201B0 for ; Tue, 5 Jun 2018 14:25:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A571E29588; Tue, 5 Jun 2018 14:25:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 51905201B0 for ; Tue, 5 Jun 2018 14:25:15 +0000 (UTC) Received: from localhost ([::1]:47131 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQCte-00017N-JZ for patchwork-qemu-devel@patchwork.kernel.org; Tue, 05 Jun 2018 10:25:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40610) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQCoI-0005PW-KB for qemu-devel@nongnu.org; Tue, 05 Jun 2018 10:19:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fQCoH-0002uH-O2 for qemu-devel@nongnu.org; Tue, 05 Jun 2018 10:19:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59450) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fQCoC-0002ql-SL; Tue, 05 Jun 2018 10:19:36 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 289C830BE9D0; Tue, 5 Jun 2018 14:19:36 +0000 (UTC) Received: from localhost (ovpn-116-175.phx2.redhat.com [10.3.116.175]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0ABD4608F0; Tue, 5 Jun 2018 14:19:34 +0000 (UTC) From: Jeff Cody To: qemu-block@nongnu.org Date: Tue, 5 Jun 2018 10:19:32 -0400 Message-Id: <20180605141933.30169-2-jcody@redhat.com> In-Reply-To: <20180605141933.30169-1-jcody@redhat.com> References: <20180605141933.30169-1-jcody@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Tue, 05 Jun 2018 14:19:36 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 1/2] sheepdog: cleanup repeated expression X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, jcody@redhat.com, qemu-devel@nongnu.org, pbonzini@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Paolo Bonzini The expression "SD_INODE_SIZE - sizeof(inode.data_vdi_id)" already has a macro defined for the same value (though with a nicer definition using offsetof). Replace it. Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Fam Zheng Reviewed-by: Jeff Cody Signed-off-by: Paolo Bonzini Message-Id: <20180523160721.14018-2-pbonzini@redhat.com> Signed-off-by: Jeff Cody --- block/sheepdog.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/block/sheepdog.c b/block/sheepdog.c index 2a5bc0a59a..cfc0e28aa5 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -2335,7 +2335,7 @@ static int sd_truncate(BlockDriverState *bs, int64_t offset, } /* we don't need to update entire object */ - datalen = SD_INODE_SIZE - sizeof(s->inode.data_vdi_id); + datalen = SD_INODE_HEADER_SIZE; s->inode.vdi_size = offset; ret = write_object(fd, s->bs, (char *)&s->inode, vid_to_vdi_oid(s->inode.vdi_id), s->inode.nr_copies, @@ -2703,7 +2703,7 @@ static int sd_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info) */ strncpy(s->inode.tag, sn_info->name, sizeof(s->inode.tag)); /* we don't need to update entire object */ - datalen = SD_INODE_SIZE - sizeof(s->inode.data_vdi_id); + datalen = SD_INODE_HEADER_SIZE; inode = g_malloc(datalen); /* refresh inode. */ @@ -2989,7 +2989,7 @@ static int sd_snapshot_list(BlockDriverState *bs, QEMUSnapshotInfo **psn_tab) /* we don't need to read entire object */ ret = read_object(fd, s->bs, (char *)&inode, vid_to_vdi_oid(vid), - 0, SD_INODE_SIZE - sizeof(inode.data_vdi_id), 0, + 0, SD_INODE_HEADER_SIZE, 0, s->cache_flags); if (ret) {