From nobody Mon Feb 9 01:20:05 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=1570816269; cv=none; d=zoho.com; s=zohoarc; b=MbYZyILXDjEMIZbYPgj+c4ix4YVFHUqSmBgoQ/M3iUv/4HzUnIZ/MBKZyONHhdAEo8lrffnYfcRx83VRuosKWs9z5rbhwCXacwCBs0Pr+bKGaOtR4aChqSV60J5WuBKWD6I71JeYKbAkWVrGHjQoGjutbrmJeQ4qvtsKTCCl84Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570816269; 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=8Q4tHFujYHYwbPVT2nyJFs1S+i0gAJ5RZT8eAAUtOpk=; b=l0LSn+k5L/vsMub0t0rC8Ar7T6KSF3n0KRjk0xZP5CJvTwcqdWw42Vjn4yZ/t6owgCGOnghIUFjvr/G4zbI+fIF3qYclJJ4KuxiSeg+B1sVy0h+XoumnU8k5PtUDsT2I6902it0zd44o4IpHBUGVs5k2m5xT+BHhHZLH7ndgH2Y= 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 1570816269875653.9582971725449; Fri, 11 Oct 2019 10:51:09 -0700 (PDT) Received: from localhost ([::1]:54930 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iIz4G-00006A-6C for importer@patchew.org; Fri, 11 Oct 2019 13:51:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41708) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iIxmd-0007vk-1b for qemu-devel@nongnu.org; Fri, 11 Oct 2019 12:28:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iIxma-0003Cy-Ty for qemu-devel@nongnu.org; Fri, 11 Oct 2019 12:28:50 -0400 Received: from relay.sw.ru ([185.231.240.75]:50016) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iIxmZ-0003Ca-TE; Fri, 11 Oct 2019 12:28: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 1iIxR4-0003XG-1s; Fri, 11 Oct 2019 19:06:34 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org Subject: [RFC v5 106/126] Quorum: introduce ERRP_AUTO_PROPAGATE Date: Fri, 11 Oct 2019 19:05:32 +0300 Message-Id: <20191011160552.22907-107-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 , vsementsov@virtuozzo.com, Alberto Garcia , 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/quorum.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/block/quorum.c b/block/quorum.c index df68adcfaa..5c531e1ec5 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -861,8 +861,8 @@ static QemuOptsList quorum_runtime_opts =3D { static int quorum_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { + ERRP_AUTO_PROPAGATE(); BDRVQuorumState *s =3D bs->opaque; - Error *local_err =3D NULL; QemuOpts *opts =3D NULL; const char *pattern_str; bool *opened; @@ -874,27 +874,27 @@ static int quorum_open(BlockDriverState *bs, QDict *o= ptions, int flags, /* count how many different children are present */ s->num_children =3D qdict_array_entries(options, "children."); if (s->num_children < 0) { - error_setg(&local_err, "Option children is not a valid array"); + error_setg(errp, "Option children is not a valid array"); ret =3D -EINVAL; goto exit; } if (s->num_children < 1) { - error_setg(&local_err, + error_setg(errp, "Number of provided children must be 1 or more"); ret =3D -EINVAL; goto exit; } =20 opts =3D qemu_opts_create(&quorum_runtime_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, options, &local_err); - if (local_err) { + qemu_opts_absorb_qdict(opts, options, errp); + if (*errp) { ret =3D -EINVAL; goto exit; } =20 s->threshold =3D qemu_opt_get_number(opts, QUORUM_OPT_VOTE_THRESHOLD, = 0); /* and validate it against s->num_children */ - ret =3D quorum_valid_threshold(s->threshold, s->num_children, &local_e= rr); + ret =3D quorum_valid_threshold(s->threshold, s->num_children, errp); if (ret < 0) { goto exit; } @@ -907,7 +907,7 @@ static int quorum_open(BlockDriverState *bs, QDict *opt= ions, int flags, -EINVAL, NULL); } if (ret < 0) { - error_setg(&local_err, "Please set read-pattern as fifo or quorum"= ); + error_setg(errp, "Please set read-pattern as fifo or quorum"); goto exit; } s->read_pattern =3D ret; @@ -915,7 +915,7 @@ static int quorum_open(BlockDriverState *bs, QDict *opt= ions, int flags, if (s->read_pattern =3D=3D QUORUM_READ_PATTERN_QUORUM) { s->is_blkverify =3D qemu_opt_get_bool(opts, QUORUM_OPT_BLKVERIFY, = false); if (s->is_blkverify && (s->num_children !=3D 2 || s->threshold != =3D 2)) { - error_setg(&local_err, "blkverify=3Don can only be set if ther= e are " + error_setg(errp, "blkverify=3Don can only be set if there are " "exactly two files and vote-threshold is 2"); ret =3D -EINVAL; goto exit; @@ -924,7 +924,7 @@ static int quorum_open(BlockDriverState *bs, QDict *opt= ions, int flags, s->rewrite_corrupted =3D qemu_opt_get_bool(opts, QUORUM_OPT_REWRIT= E, false); if (s->rewrite_corrupted && s->is_blkverify) { - error_setg(&local_err, + error_setg(errp, "rewrite-corrupted=3Don cannot be used with blkveri= fy=3Don"); ret =3D -EINVAL; goto exit; @@ -941,8 +941,8 @@ static int quorum_open(BlockDriverState *bs, QDict *opt= ions, int flags, assert(ret < 32); =20 s->children[i] =3D bdrv_open_child(NULL, options, indexstr, bs, - &child_format, false, &local_err); - if (local_err) { + &child_format, false, errp); + if (*errp) { ret =3D -EINVAL; goto close_exit; } @@ -969,7 +969,6 @@ close_exit: exit: qemu_opts_del(opts); /* propagate error */ - error_propagate(errp, local_err); return ret; } =20 --=20 2.21.0