From nobody Mon Feb 9 20:36:52 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1666610416; cv=none; d=zohomail.com; s=zohoarc; b=hMD1UYw2tviGLDyHBE3qGKzjGNeCXzRNkV6qWZ1tu7+M+vNq65NyksMfxgbJUbkghtOo/vih8Tpx85EMOMVS3IUxEmqVvm/wjJFna4KbJTGF2L1YNctTQ3WKSNxqFVDIB91z6K9ofNP1LfUnuAhunHqysnnZx48xkx+Xcb/t/Rk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666610416; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=j1qMYwjqZSsvOmRZN4Bn0S5B3o5/LmFGW4XKgo5pJBI=; b=Cqd3XAmEsEb//KqnTKOpsE4lBUBh2Rs9JtWMx8EAHxPW5Q9mPyEG6J4pSQ87NcriCvvwvDh0tkd+E9FB2wWt4PEDVyzW8M3CNg4Vo9Oz3suk+CPkGlBSv5L0IzY7mZfJmbi1uQy+zGTSiOfhVErQteykO/XtNjB64MOxtBL+Dhs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666610416374858.560753731876; Mon, 24 Oct 2022 04:20:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1omvMi-0000ef-W3; Mon, 24 Oct 2022 07:11:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3f3e9232207fc4f0e5cb5cf63f11ed9449efeefa@lizzy.crudebyte.com>) id 1omvLu-0000O3-UQ for qemu-devel@nongnu.org; Mon, 24 Oct 2022 07:10:42 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3f3e9232207fc4f0e5cb5cf63f11ed9449efeefa@lizzy.crudebyte.com>) id 1omvLg-0006np-1X for qemu-devel@nongnu.org; Mon, 24 Oct 2022 07:10:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=j1qMYwjqZSsvOmRZN4Bn0S5B3o5/LmFGW4XKgo5pJBI=; b=DF7Ls HoJ0CRoDFRLEqh4Y5dtrKUiOJ48GgQ7PUGAnhp/8img65DNcb6pFlHlkK5+wQHvpxkvybqbu+h9kB w0aE4XlyJq6tPpS3FNq8C6Nl6YM70HhBJN2iMp4r9z18bCLvmGv7EAV52GLpUziOYX0miGk7DOqpU 2cuFBCZv229bf8IeRWijQFbD1XoT6AUoKWNza/4B/KJyhK0PgYd019U+pJqDDsc89FdfQ+MXAXhNU CDHFG/NJRvLCOBGzugg82Jy4AwIJugxzxB7TdAc52+SB1vHN3CBRiFCLcSucCLliRDwKUsdWgrjRD y7Otum9nhrELqqd8YLsLIx5sz1kMQ==; Message-Id: <3f3e9232207fc4f0e5cb5cf63f11ed9449efeefa.1666608862.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Mon, 24 Oct 2022 12:54:23 +0200 Subject: [PULL 05/23] tests/9p: simplify callers of twalk() To: qemu-devel@nongnu.org, Stefan Hajnoczi Cc: Greg Kurz 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; Received-SPF: none client-ip=91.194.90.13; envelope-from=3f3e9232207fc4f0e5cb5cf63f11ed9449efeefa@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @crudebyte.com) X-ZM-MESSAGEID: 1666610418425100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Now as twalk() is using a declarative approach, simplify the code of callers of this function. Signed-off-by: Christian Schoenebeck Message-Id: <8b9d3c656ad43b6c953d6bdacd8d9f4c8e599b2a.1664917004.git.qemu_o= ss@crudebyte.com> --- tests/qtest/virtio-9p-test.c | 92 +++++++++++++----------------------- 1 file changed, 32 insertions(+), 60 deletions(-) diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c index cf5d6146ad..3c326451b1 100644 --- a/tests/qtest/virtio-9p-test.c +++ b/tests/qtest/virtio-9p-test.c @@ -90,19 +90,17 @@ static void fs_walk(void *obj, void *data, QGuestAlloca= tor *t_alloc) uint16_t nwqid; g_autofree v9fs_qid *wqid =3D NULL; int i; - P9Req *req; =20 for (i =3D 0; i < P9_MAXWELEM; i++) { wnames[i] =3D g_strdup_printf(QTEST_V9FS_SYNTH_WALK_FILE, i); } =20 do_attach(v9p); - req =3D twalk({ + twalk({ .client =3D v9p, .fid =3D 0, .newfid =3D 1, - .nwname =3D P9_MAXWELEM, .wnames =3D wnames, .requestOnly =3D true - }).req; - v9fs_req_wait_for_reply(req, NULL); - v9fs_rwalk(req, &nwqid, &wqid); + .nwname =3D P9_MAXWELEM, .wnames =3D wnames, + .rwalk =3D { .nwqid =3D &nwqid, .wqid =3D &wqid } + }); =20 g_assert_cmpint(nwqid, =3D=3D, P9_MAXWELEM); =20 @@ -134,12 +132,10 @@ static void fs_readdir(void *obj, void *data, QGuestA= llocator *t_alloc) P9Req *req; =20 do_attach(v9p); - req =3D twalk({ + twalk({ .client =3D v9p, .fid =3D 0, .newfid =3D 1, - .nwname =3D 1, .wnames =3D wnames, .requestOnly =3D true - }).req; - v9fs_req_wait_for_reply(req, NULL); - v9fs_rwalk(req, &nqid, NULL); + .nwname =3D 1, .wnames =3D wnames, .rwalk.nwqid =3D &nqid + }); g_assert_cmpint(nqid, =3D=3D, 1); =20 req =3D v9fs_tlopen(v9p, 1, O_DIRECTORY, 0); @@ -198,12 +194,10 @@ static void do_readdir_split(QVirtio9P *v9p, uint32_t= count) nentries =3D 0; tail =3D NULL; =20 - req =3D twalk({ + twalk({ .client =3D v9p, .fid =3D 0, .newfid =3D fid, - .nwname =3D 1, .wnames =3D wnames, .requestOnly =3D true - }).req; - v9fs_req_wait_for_reply(req, NULL); - v9fs_rwalk(req, &nqid, NULL); + .nwname =3D 1, .wnames =3D wnames, .rwalk.nwqid =3D &nqid + }); g_assert_cmpint(nqid, =3D=3D, 1); =20 req =3D v9fs_tlopen(v9p, fid, O_DIRECTORY, 0); @@ -266,18 +260,12 @@ static void fs_walk_no_slash(void *obj, void *data, Q= GuestAllocator *t_alloc) QVirtio9P *v9p =3D obj; v9fs_set_allocator(t_alloc); char *wnames[] =3D { g_strdup(" /") }; - P9Req *req; - uint32_t err; =20 do_attach(v9p); - req =3D twalk({ + twalk({ .client =3D v9p, .fid =3D 0, .newfid =3D 1, .nwname =3D 1, .wnames= =3D wnames, - .requestOnly =3D true - }).req; - v9fs_req_wait_for_reply(req, NULL); - v9fs_rlerror(req, &err); - - g_assert_cmpint(err, =3D=3D, ENOENT); + .expectErr =3D ENOENT + }); =20 g_free(wnames[0]); } @@ -312,7 +300,7 @@ static void fs_walk_2nd_nonexistent(void *obj, void *da= ta, do_attach_rqid(v9p, &root_qid); fid =3D twalk({ .client =3D v9p, .path =3D path, - .rwalk.nwqid =3D &nwqid, .rwalk.wqid =3D &wqid + .rwalk =3D { .nwqid =3D &nwqid, .wqid =3D &wqid } }).newfid; /* * The 9p2000 protocol spec says: "nwqid is therefore either nwname or= the @@ -345,12 +333,10 @@ static void fs_walk_none(void *obj, void *data, QGues= tAllocator *t_alloc) v9fs_req_wait_for_reply(req, NULL); v9fs_rattach(req, &root_qid); =20 - req =3D twalk({ + twalk({ .client =3D v9p, .fid =3D 0, .newfid =3D 1, .nwname =3D 0, .wnames= =3D NULL, - .requestOnly =3D true - }).req; - v9fs_req_wait_for_reply(req, NULL); - v9fs_rwalk(req, NULL, &wqid); + .rwalk.wqid =3D &wqid + }); =20 /* special case: no QID is returned if nwname=3D0 was sent */ g_assert(wqid =3D=3D NULL); @@ -376,12 +362,10 @@ static void fs_walk_dotdot(void *obj, void *data, QGu= estAllocator *t_alloc) v9fs_req_wait_for_reply(req, NULL); v9fs_rattach(req, &root_qid); =20 - req =3D twalk({ + twalk({ .client =3D v9p, .fid =3D 0, .newfid =3D 1, .nwname =3D 1, .wnames= =3D wnames, - .requestOnly =3D true - }).req; - v9fs_req_wait_for_reply(req, NULL); - v9fs_rwalk(req, NULL, &wqid); /* We now we'll get one qid */ + .rwalk.wqid =3D &wqid /* We now we'll get one qid */ + }); =20 g_assert_cmpmem(&root_qid, 13, wqid[0], 13); =20 @@ -396,12 +380,9 @@ static void fs_lopen(void *obj, void *data, QGuestAllo= cator *t_alloc) P9Req *req; =20 do_attach(v9p); - req =3D twalk({ - .client =3D v9p, .fid =3D 0, .newfid =3D 1, .nwname =3D 1, .wnames= =3D wnames, - .requestOnly =3D true - }).req; - v9fs_req_wait_for_reply(req, NULL); - v9fs_rwalk(req, NULL, NULL); + twalk({ + .client =3D v9p, .fid =3D 0, .newfid =3D 1, .nwname =3D 1, .wnames= =3D wnames + }); =20 req =3D v9fs_tlopen(v9p, 1, O_WRONLY, 0); v9fs_req_wait_for_reply(req, NULL); @@ -421,12 +402,9 @@ static void fs_write(void *obj, void *data, QGuestAllo= cator *t_alloc) P9Req *req; =20 do_attach(v9p); - req =3D twalk({ - .client =3D v9p, .fid =3D 0, .newfid =3D 1, .nwname =3D 1, .wnames= =3D wnames, - .requestOnly =3D true - }).req; - v9fs_req_wait_for_reply(req, NULL); - v9fs_rwalk(req, NULL, NULL); + twalk({ + .client =3D v9p, .fid =3D 0, .newfid =3D 1, .nwname =3D 1, .wnames= =3D wnames + }); =20 req =3D v9fs_tlopen(v9p, 1, O_WRONLY, 0); v9fs_req_wait_for_reply(req, NULL); @@ -450,12 +428,9 @@ static void fs_flush_success(void *obj, void *data, QG= uestAllocator *t_alloc) uint8_t should_block; =20 do_attach(v9p); - req =3D twalk({ - .client =3D v9p, .fid =3D 0, .newfid =3D 1, .nwname =3D 1, .wnames= =3D wnames, - .requestOnly =3D true - }).req; - v9fs_req_wait_for_reply(req, NULL); - v9fs_rwalk(req, NULL, NULL); + twalk({ + .client =3D v9p, .fid =3D 0, .newfid =3D 1, .nwname =3D 1, .wnames= =3D wnames + }); =20 req =3D v9fs_tlopen(v9p, 1, O_WRONLY, 0); v9fs_req_wait_for_reply(req, NULL); @@ -490,12 +465,9 @@ static void fs_flush_ignored(void *obj, void *data, QG= uestAllocator *t_alloc) uint8_t should_block; =20 do_attach(v9p); - req =3D twalk({ - .client =3D v9p, .fid =3D 0, .newfid =3D 1, .nwname =3D 1, .wnames= =3D wnames, - .requestOnly =3D true - }).req; - v9fs_req_wait_for_reply(req, NULL); - v9fs_rwalk(req, NULL, NULL); + twalk({ + .client =3D v9p, .fid =3D 0, .newfid =3D 1, .nwname =3D 1, .wnames= =3D wnames + }); =20 req =3D v9fs_tlopen(v9p, 1, O_WRONLY, 0); v9fs_req_wait_for_reply(req, NULL); --=20 2.30.2