From nobody Sun Feb 8 18:43:22 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; spf=pass (zoho.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=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1570817073; cv=none; d=zoho.com; s=zohoarc; b=DBZzQnaTQSNfGq24q8UFc2md2uU+iBjve7saON7SdO00s1qTFNX/xAAVycSU0Yr7YBzF0LjiCmjoPDVC8zjvjHKbN0b6xZUQAd115dWbamFQ9w+YHTWA70w+YSjZq2LL79mxjy3/O2xEdKu0QmLuf5jLOgNfZCPjLNirq1/oTyM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570817073; 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=CjMhi5YzIZ7/erjpl/nJm94OR36uGvV5dJAb0zkaOgI=; b=PTvFNXRe3VmgbsnT7ISRDm3wM2I2axmo6jdqB26bah80AYoN1/4gAqZbY3fcStKb2aR+Oo79qGbCx6oZoqEuj5ZYzxtIJlsGbxftuZQGjB00Lv6pEAigr1gMwGLPhZ+0vmJsqaMGW1wkqGI9plY4465cm77mmu9xdYxr7c/CWeA= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 1570817073899169.80822375152263; Fri, 11 Oct 2019 11:04:33 -0700 (PDT) Received: from localhost ([::1]:55102 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iIzHA-0006ME-Eq for importer@patchew.org; Fri, 11 Oct 2019 14:04:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37256) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iIxRK-0006wf-Un for qemu-devel@nongnu.org; Fri, 11 Oct 2019 12:06:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iIxRI-0004w4-Vd for qemu-devel@nongnu.org; Fri, 11 Oct 2019 12:06:50 -0400 Received: from relay.sw.ru ([185.231.240.75]:48506) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iIxRI-0004Y4-Na; Fri, 11 Oct 2019 12:06:48 -0400 Received: from [10.94.3.0] (helo=kvm.qa.sw.ru) by relay.sw.ru with esmtp (Exim 4.92.2) (envelope-from ) id 1iIxQx-0003XG-7b; Fri, 11 Oct 2019 19:06:27 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org Subject: [RFC v5 093/126] VMDK: introduce ERRP_AUTO_PROPAGATE Date: Fri, 11 Oct 2019 19:05:19 +0300 Message-Id: <20191011160552.22907-94-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191011160552.22907-1-vsementsov@virtuozzo.com> References: <20191011160552.22907-1-vsementsov@virtuozzo.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 185.231.240.75 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: Kevin Wolf , Fam Zheng , vsementsov@virtuozzo.com, qemu-block@nongnu.org, armbru@redhat.com, Max Reitz , Greg Kurz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" If we want to add some info to errp (by error_prepend() or error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro. Otherwise, this info will not be added when errp =3D=3D &fatal_err (the program will exit prior to the error_append_hint() or error_prepend() call). Fix such cases. If we want to check error after errp-function call, we need to introduce local_err and than propagate it to errp. Instead, use ERRP_AUTO_PROPAGATE macro, benefits are: 1. No need of explicit error_propagate call 2. No need of explicit local_err variable: use errp directly 3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or &error_fatel, this means that we don't break error_abort (we'll abort on error_set, not on error_propagate) This commit (together with its neighbors) was generated by for f in $(git grep -l errp \*.[ch]); do \ spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \ --macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \ done; then fix a bit of compilation problems: coccinelle for some reason leaves several f() { ... goto out; ... out: } patterns, with "out:" at function end. then ./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)" (auto-msg was a file with this commit message) Still, for backporting it may be more comfortable to use only the first command and then do one huge commit. Reported-by: Kevin Wolf Reported-by: Greg Kurz Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/vmdk.c | 41 +++++++++++++++++------------------------ 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/block/vmdk.c b/block/vmdk.c index fed3b50c8a..bf1f2c4cac 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -1078,6 +1078,7 @@ static const char *next_line(const char *s) static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, QDict *options, Error **errp) { + ERRP_AUTO_PROPAGATE(); int ret; int matches; char access[11]; @@ -1092,7 +1093,6 @@ static int vmdk_parse_extents(const char *desc, Block= DriverState *bs, BDRVVmdkState *s =3D bs->opaque; VmdkExtent *extent; char extent_opt_prefix[32]; - Error *local_err =3D NULL; =20 for (p =3D desc; *p; p =3D next_line(p)) { /* parse extent line in one of below formats: @@ -1152,10 +1152,9 @@ static int vmdk_parse_extents(const char *desc, Bloc= kDriverState *bs, assert(ret < 32); =20 extent_file =3D bdrv_open_child(extent_path, options, extent_opt_p= refix, - bs, &child_file, false, &local_err); + bs, &child_file, false, errp); g_free(extent_path); - if (local_err) { - error_propagate(errp, local_err); + if (*errp) { ret =3D -EINVAL; goto out; } @@ -1251,11 +1250,11 @@ exit: static int vmdk_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { + ERRP_AUTO_PROPAGATE(); char *buf; int ret; BDRVVmdkState *s =3D bs->opaque; uint32_t magic; - Error *local_err =3D NULL; =20 bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file, false, errp); @@ -1303,9 +1302,8 @@ static int vmdk_open(BlockDriverState *bs, QDict *opt= ions, int flags, error_setg(&s->migration_blocker, "The vmdk format used by node '%s' " "does not support live migration", bdrv_get_device_or_node_name(bs)); - ret =3D migrate_add_blocker(s->migration_blocker, &local_err); - if (local_err) { - error_propagate(errp, local_err); + ret =3D migrate_add_blocker(s->migration_blocker, errp); + if (*errp) { error_free(s->migration_blocker); goto fail; } @@ -2223,21 +2221,19 @@ static int vmdk_create_extent(const char *filename,= int64_t filesize, BlockBackend **pbb, QemuOpts *opts, Error **errp) { + ERRP_AUTO_PROPAGATE(); int ret; BlockBackend *blk =3D NULL; - Error *local_err =3D NULL; =20 - ret =3D bdrv_create_file(filename, opts, &local_err); + ret =3D bdrv_create_file(filename, opts, errp); if (ret < 0) { - error_propagate(errp, local_err); goto exit; } =20 blk =3D blk_new_open(filename, NULL, NULL, BDRV_O_RDWR | BDRV_O_RESIZE | BDRV_O_PROTOCOL, - &local_err); + errp); if (blk =3D=3D NULL) { - error_propagate(errp, local_err); ret =3D -EIO; goto exit; } @@ -2333,10 +2329,10 @@ static int coroutine_fn vmdk_co_do_create(int64_t s= ize, void *opaque, Error **errp) { + ERRP_AUTO_PROPAGATE(); int extent_idx; BlockBackend *blk =3D NULL; BlockBackend *extent_blk; - Error *local_err =3D NULL; char *desc =3D NULL; int ret =3D 0; bool flat, split, compress; @@ -2440,9 +2436,8 @@ static int coroutine_fn vmdk_co_do_create(int64_t siz= e, char *full_backing =3D bdrv_get_full_backing_filename_from_filename(blk_bs(blk)->file= name, backing_file, - &local_err); - if (local_err) { - error_propagate(errp, local_err); + errp); + if (*errp) { ret =3D -ENOENT; goto exit; } @@ -2591,7 +2586,7 @@ exit: static int coroutine_fn vmdk_co_create_opts(const char *filename, QemuOpts= *opts, Error **errp) { - Error *local_err =3D NULL; + ERRP_AUTO_PROPAGATE(); char *desc =3D NULL; int64_t total_size =3D 0; char *adapter_type =3D NULL; @@ -2634,9 +2629,8 @@ static int coroutine_fn vmdk_co_create_opts(const cha= r *filename, QemuOpts *opts adapter_type_enum =3D qapi_enum_parse(&BlockdevVmdkAdapterType_loo= kup, adapter_type, BLOCKDEV_VMDK_ADAPTER_TYPE_IDE, - &local_err); - if (local_err) { - error_propagate(errp, local_err); + errp); + if (*errp) { ret =3D -EINVAL; goto exit; } @@ -2651,9 +2645,8 @@ static int coroutine_fn vmdk_co_create_opts(const cha= r *filename, QemuOpts *opts subformat =3D qapi_enum_parse(&BlockdevVmdkSubformat_lookup, fmt, BLOCKDEV_VMDK_SUBFORMAT_MONOLITHICSPAR= SE, - &local_err); - if (local_err) { - error_propagate(errp, local_err); + errp); + if (*errp) { ret =3D -EINVAL; goto exit; } --=20 2.21.0