From nobody Sun Feb 8 10:49:36 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1578335879; cv=none; d=zohomail.com; s=zohoarc; b=fMCAU53f3Sw+biSke1DUx6ApP3F7xeerWo93APyCnY4SmRWfKB3QBhSsOB+5hp/x9/wLW6B1Fu1IGHBWPLVvdq3BqjU0sDky/mUXv7grdOZq3fPBNWr1wGeU2xoqHiT3RMfdaRP2aoESqXLc2ItoDxBySycxyYh8hGNtuf755UI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578335879; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=1eNWCesezoeCHU4P6XXmYWzX+KWcO3wBsevjsS6K9fg=; b=EaIdxbom1IBPgVGAGF+ZvA3DqE5Z3AqBQ6TBc6ng7+mlrpPCvIRTmK+d+p/79CUjjtmffRCoXf70zbKZzmWtt/H9u4kkw7WrKwTQ435GtXOGBOL0NOe3X5U9KH47GdmgKLPtKCDqd/9vaomQCBUbGxUskRlgvqlis4sNEDwJcf4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1578335879019588.5303563222254; Mon, 6 Jan 2020 10:37:59 -0800 (PST) Received: from localhost ([::1]:57860 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ioXGH-0000zc-Kg for importer@patchew.org; Mon, 06 Jan 2020 13:37:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:45648) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ioX4L-0002LW-Jh for qemu-devel@nongnu.org; Mon, 06 Jan 2020 13:25:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ioX4K-0004N6-0o for qemu-devel@nongnu.org; Mon, 06 Jan 2020 13:25:37 -0500 Received: from mail-qv1-xf43.google.com ([2607:f8b0:4864:20::f43]:39292) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ioX4J-0004Mk-SN; Mon, 06 Jan 2020 13:25:35 -0500 Received: by mail-qv1-xf43.google.com with SMTP id y8so19431485qvk.6; Mon, 06 Jan 2020 10:25:35 -0800 (PST) Received: from rekt.ibmuc.com ([2804:431:c7c6:655b:9e1c:e865:3705:e1df]) by smtp.gmail.com with ESMTPSA id b81sm21026522qkc.135.2020.01.06.10.25.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2020 10:25:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1eNWCesezoeCHU4P6XXmYWzX+KWcO3wBsevjsS6K9fg=; b=Nu0kKN/mxLka/H/3rWIpQbIG6c9bN9JQ85u2Z01T8cvkL4gjy7BxQihZSMLpMLUklq Vqg76xrZlnb6wmDKUUeUpvbQxFZGd7JmKMFdPj/VoIBcDhCxEiqfSGd1GoEyroFDgFJa tHjY0lqU+XOQd458ZLr/EQO1Bd83NFE9CXCgZitBjxwJWZFXwkkkOm7ih9cBnxX6NmmN QgQa6CuISUm9Q9ntrKJAumoUi5MvmEryIh0IBODnTON0O8LSvTfaQpBivcbtLiz2EslZ ZQlRgJmQApUN06vFTQ1mfpGL9YGXImbdAHMkX0U07th7TSBEQLn2TV78jtUED5fwTRRd /kMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1eNWCesezoeCHU4P6XXmYWzX+KWcO3wBsevjsS6K9fg=; b=LEOxwHVuSspPIi63ArFbaQeqUDQvoLDg1Pb0Y4ZXdluk1eqMRLOhdatFP31MkMPxtJ krydVUgiDrsgm27MJZnrc9308Y4ZNZrQRuvGSD010anZraZplOPjf5dEqQOMinQoLgun GOlTts6o1gLvgVv/7PYmZGAhWRIap2UVW+c4RqtUHgVTqYGmkvbgZqSTyC3NsmbIq9GM 0JwTHC3iXuCvxPLxhPfK/kHTouHPU3wja9uGtjv3mHpI/g8SYxurA0TcaDD5hN7oUVG/ SvVtASKJmmSPyAhY2+LWNR+l4IaTwB8jg8ixk2jTyVggpSenpXIKDzOuV9fM5jQKKpzz z2bQ== X-Gm-Message-State: APjAAAXJvaITTws1rQX41Fwdeh3ddLk+QhdBVxrDd/zXtpAO7RVxWyg4 TENyIcypMEGFBubH4/tVhkCp4Xub X-Google-Smtp-Source: APXvYqw9VquKkGWHrF4hZ6jV1CoCcGb2PRdGGrSSPEADPaUlEEOsRNz2cwqWfgIdzM0AbV/oVRUjgw== X-Received: by 2002:a0c:fa87:: with SMTP id o7mr81007061qvn.160.1578335135150; Mon, 06 Jan 2020 10:25:35 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Subject: [PATCH v1 24/59] block/vhdx-log.c: remove unneeded labels Date: Mon, 6 Jan 2020 15:23:50 -0300 Message-Id: <20200106182425.20312-25-danielhb413@gmail.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200106182425.20312-1-danielhb413@gmail.com> References: <20200106182425.20312-1-danielhb413@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::f43 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-trivial@nongnu.org, Jeff Cody , Daniel Henrique Barboza , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Removing some 'exit' labels used in some functions that are unneeded, changing them for the adequate 'return' value for the context. CC: Jeff Cody CC: qemu-block@nongnu.org Signed-off-by: Daniel Henrique Barboza --- block/vhdx-log.c | 86 ++++++++++++++++++------------------------------ 1 file changed, 32 insertions(+), 54 deletions(-) diff --git a/block/vhdx-log.c b/block/vhdx-log.c index 13a49c2a33..ba89f0adc6 100644 --- a/block/vhdx-log.c +++ b/block/vhdx-log.c @@ -64,8 +64,7 @@ static int vhdx_log_peek_hdr(BlockDriverState *bs, VHDXLo= gEntries *log, =20 /* peek is only supported on sector boundaries */ if (log->read % VHDX_LOG_SECTOR_SIZE) { - ret =3D -EFAULT; - goto exit; + return -EFAULT; } =20 read =3D log->read; @@ -77,19 +76,17 @@ static int vhdx_log_peek_hdr(BlockDriverState *bs, VHDX= LogEntries *log, } =20 if (read =3D=3D log->write) { - ret =3D -EINVAL; - goto exit; + return -EINVAL; } =20 offset =3D log->offset + read; =20 ret =3D bdrv_pread(bs->file, offset, hdr, sizeof(VHDXLogEntryHeader)); if (ret < 0) { - goto exit; + return ret; } vhdx_log_entry_hdr_le_import(hdr); =20 -exit: return ret; } =20 @@ -179,7 +176,7 @@ static int vhdx_log_write_sectors(BlockDriverState *bs,= VHDXLogEntries *log, =20 ret =3D vhdx_user_visible_write(bs, s); if (ret < 0) { - goto exit; + return ret; } =20 write =3D log->write; @@ -196,7 +193,7 @@ static int vhdx_log_write_sectors(BlockDriverState *bs,= VHDXLogEntries *log, ret =3D bdrv_pwrite(bs->file, offset, buffer_tmp, VHDX_LOG_SECTOR_SIZE); if (ret < 0) { - goto exit; + return ret; } buffer_tmp +=3D VHDX_LOG_SECTOR_SIZE; =20 @@ -205,7 +202,6 @@ static int vhdx_log_write_sectors(BlockDriverState *bs,= VHDXLogEntries *log, num_sectors--; } =20 -exit: return ret; } =20 @@ -214,42 +210,37 @@ exit: static bool vhdx_log_hdr_is_valid(VHDXLogEntries *log, VHDXLogEntryHeader = *hdr, BDRVVHDXState *s) { - int valid =3D false; - if (hdr->signature !=3D VHDX_LOG_SIGNATURE) { - goto exit; + return false; } =20 /* if the individual entry length is larger than the whole log * buffer, that is obviously invalid */ if (log->length < hdr->entry_length) { - goto exit; + return false; } =20 /* length of entire entry must be in units of 4KB (log sector size) */ if (hdr->entry_length % (VHDX_LOG_SECTOR_SIZE)) { - goto exit; + return false; } =20 /* per spec, sequence # must be > 0 */ if (hdr->sequence_number =3D=3D 0) { - goto exit; + return false; } =20 /* log entries are only valid if they match the file-wide log guid * found in the active header */ if (!guid_eq(hdr->log_guid, s->headers[s->curr_header]->log_guid)) { - goto exit; + return false; } =20 if (hdr->descriptor_count * sizeof(VHDXLogDescriptor) > hdr->entry_len= gth) { - goto exit; + return false; } =20 - valid =3D true; - -exit: - return valid; + return true; } =20 /* @@ -274,10 +265,10 @@ static bool vhdx_log_desc_is_valid(VHDXLogDescriptor = *desc, bool ret =3D false; =20 if (desc->sequence_number !=3D hdr->sequence_number) { - goto exit; + return false; } if (desc->file_offset % VHDX_LOG_SECTOR_SIZE) { - goto exit; + return false; } =20 if (desc->signature =3D=3D VHDX_LOG_ZERO_SIGNATURE) { @@ -290,7 +281,6 @@ static bool vhdx_log_desc_is_valid(VHDXLogDescriptor *d= esc, ret =3D true; } =20 -exit: return ret; } =20 @@ -347,20 +337,18 @@ static int vhdx_log_read_desc(BlockDriverState *bs, B= DRVVHDXState *s, =20 ret =3D vhdx_log_peek_hdr(bs, log, &hdr); if (ret < 0) { - goto exit; + return ret; } =20 if (vhdx_log_hdr_is_valid(log, &hdr, s) =3D=3D false) { - ret =3D -EINVAL; - goto exit; + return -EINVAL; } =20 desc_sectors =3D vhdx_compute_desc_sectors(hdr.descriptor_count); desc_entries =3D qemu_try_blockalign(bs->file->bs, desc_sectors * VHDX_LOG_SECTOR_SIZE= ); if (desc_entries =3D=3D NULL) { - ret =3D -ENOMEM; - goto exit; + return -ENOMEM; } =20 ret =3D vhdx_log_read_sectors(bs, log, §ors_read, desc_entries, @@ -390,11 +378,10 @@ static int vhdx_log_read_desc(BlockDriverState *bs, B= DRVVHDXState *s, } =20 *buffer =3D desc_entries; - goto exit; + return ret; =20 free_and_exit: qemu_vfree(desc_entries); -exit: return ret; } =20 @@ -688,7 +675,7 @@ static int vhdx_log_search(BlockDriverState *bs, BDRVVH= DXState *s, ret =3D vhdx_validate_log_entry(bs, s, &curr_log, curr_seq, &seq_valid, &hdr); if (ret < 0) { - goto exit; + return ret; } =20 if (seq_valid) { @@ -704,7 +691,7 @@ static int vhdx_log_search(BlockDriverState *bs, BDRVVH= DXState *s, ret =3D vhdx_validate_log_entry(bs, s, &curr_log, curr_seq, &seq_valid, &hdr); if (ret < 0) { - goto exit; + return ret; } if (seq_valid =3D=3D false) { break; @@ -735,8 +722,6 @@ static int vhdx_log_search(BlockDriverState *bs, BDRVVH= DXState *s, s->log.sequence =3D candidate.hdr.sequence_number + 1; } =20 - -exit: return ret; } =20 @@ -766,29 +751,26 @@ int vhdx_parse_log(BlockDriverState *bs, BDRVVHDXStat= e *s, bool *flushed, =20 if (s->log.offset < VHDX_LOG_MIN_SIZE || s->log.offset % VHDX_LOG_MIN_SIZE) { - ret =3D -EINVAL; - goto exit; + return -EINVAL; } =20 /* per spec, only log version of 0 is supported */ if (hdr->log_version !=3D 0) { - ret =3D -EINVAL; - goto exit; + return -EINVAL; } =20 /* If either the log guid, or log length is zero, * then a replay log is not present */ if (guid_eq(hdr->log_guid, zero_guid)) { - goto exit; + return 0; } =20 if (hdr->log_length =3D=3D 0) { - goto exit; + return 0; } =20 if (hdr->log_length % VHDX_LOG_MIN_SIZE) { - ret =3D -EINVAL; - goto exit; + return -EINVAL; } =20 =20 @@ -797,13 +779,12 @@ int vhdx_parse_log(BlockDriverState *bs, BDRVVHDXStat= e *s, bool *flushed, =20 ret =3D vhdx_log_search(bs, s, &logs); if (ret < 0) { - goto exit; + return ret; } =20 if (logs.valid) { if (bs->read_only) { bdrv_refresh_filename(bs); - ret =3D -EPERM; error_setg(errp, "VHDX image file '%s' opened read-only, but " "contains a log that needs to be replayed", @@ -811,18 +792,16 @@ int vhdx_parse_log(BlockDriverState *bs, BDRVVHDXStat= e *s, bool *flushed, error_append_hint(errp, "To replay the log, run:\n" "qemu-img check -r all '%s'\n", bs->filename); - goto exit; + return -EPERM; } /* now flush the log */ ret =3D vhdx_log_flush(bs, s, &logs); if (ret < 0) { - goto exit; + return ret; } *flushed =3D true; } =20 - -exit: return ret; } =20 @@ -1048,29 +1027,28 @@ int vhdx_log_write_and_flush(BlockDriverState *bs, = BDRVVHDXState *s, * on disk, before creating log entry */ ret =3D bdrv_flush(bs); if (ret < 0) { - goto exit; + return ret; } =20 ret =3D vhdx_log_write(bs, s, data, length, offset); if (ret < 0) { - goto exit; + return ret; } logs.log =3D s->log; =20 /* Make sure log is stable on disk */ ret =3D bdrv_flush(bs); if (ret < 0) { - goto exit; + return ret; } =20 ret =3D vhdx_log_flush(bs, s, &logs); if (ret < 0) { - goto exit; + return ret; } =20 s->log =3D logs.log; =20 -exit: return ret; } =20 --=20 2.24.1