From nobody Sun May 19 06:23:15 2024 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=1615894044; cv=none; d=zohomail.com; s=zohoarc; b=F1ySWEMdn64anmEcg/vtOJYLIXAP9Qa3ROoajQT7gOy8vrYoprY7dys2DPoEbUFUUNgFFAbopM3Jh7VgY7LK6xHM56Ci2YDrGvGddreAhNAk23XBde2i9QysGw5G6hWoDTME1/4n4d6ado1uhdr5gDNKlZysEw1BLLkfwy9mwpw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615894044; 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=7CsDD69PwbqI+ESS67+lxfdSPQTaohMwtsnDvh737Vo=; b=jP4AiDLOOND7//8Lx/9jEMrxdlbPCwxETaeUDutPdIRpnXCNAEKmK1mswPGl8yzNjwwUxDjPejMe22iHoi+avDbCr/dE2kag8W/q2QjBiN2Gnjaxorxxbfk7e4y3UT2K2qg6nTP4K1AhxVhO9EXiSzqWNtbWVE/+53CcHHigW9w= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1615894044165344.5864891172114; Tue, 16 Mar 2021 04:27:24 -0700 (PDT) Received: from localhost ([::1]:56096 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lM7r8-0002u4-Vh for importer@patchew.org; Tue, 16 Mar 2021 07:27:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57036) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lM7pe-0002B3-4b for qemu-devel@nongnu.org; Tue, 16 Mar 2021 07:25:50 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:39687) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lM7pc-0005Hh-BZ for qemu-devel@nongnu.org; Tue, 16 Mar 2021 07:25:49 -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=7CsDD69PwbqI+ESS67+lxfdSPQTaohMwtsnDvh737Vo=; b=WxqJe R/E9qwq4iBK0tmdBbY2KfMFByQftkCtAE0g66gYRy5r3hRwg56MJoUypQd1u8rWrRpUW6wsj4OCu+ rC856knouFoYlPx9JxgYqQ7HP/oJIuZ3kvGUqv5uvtQf7+qU+JVNdZmDDm+rd1ULqf5pR/EQwQVXU Y8DzZqp3JRIdlGXMfmO+Guu4A8fwYtvwJw7ASFL0qK+uwzA6/PFhIj+97C8grkOAT19U9WGXIeVSp Zs8JuBXcUi+xjwUu+dt5aIJwCy9CQf/cczHbsEkI8m1z+M9TKDLK0CVr1T6aQ4D9etc4oPhbUr8c6 lWiRFzEku8ycs04NNRTJpJtSJ4rsg==; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Tue, 16 Mar 2021 11:49:29 +0100 Subject: [PULL 1/1] hw/9pfs/9p-synth: Replaced qemu_mutex_lock with QEMU_LOCK_GUARD To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz , Mahmoud Mandour 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=e4fd889f51094a8e76274ca1e9e0ed70375166f0@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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Mahmoud Mandour Replaced a call to qemu_mutex_lock and its respective call to qemu_mutex_unlock and used QEMU_LOCK_GUARD macro in their place. This simplifies the code by removing the call required to unlock and also eliminates goto paths. Signed-off-by: Mahmoud Mandour Acked-by: Greg Kurz Reviewed-by: Christian Schoenebeck Message-Id: <20210311031538.5325-9-ma.mandourr@gmail.com> Signed-off-by: Christian Schoenebeck --- hw/9pfs/9p-synth.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/hw/9pfs/9p-synth.c b/hw/9pfs/9p-synth.c index 7eb210ffa8..473ef914b0 100644 --- a/hw/9pfs/9p-synth.c +++ b/hw/9pfs/9p-synth.c @@ -79,11 +79,11 @@ int qemu_v9fs_synth_mkdir(V9fsSynthNode *parent, int mo= de, if (!parent) { parent =3D &synth_root; } - qemu_mutex_lock(&synth_mutex); + QEMU_LOCK_GUARD(&synth_mutex); QLIST_FOREACH(tmp, &parent->child, sibling) { if (!strcmp(tmp->name, name)) { ret =3D EEXIST; - goto err_out; + return ret; } } /* Add the name */ @@ -94,8 +94,6 @@ int qemu_v9fs_synth_mkdir(V9fsSynthNode *parent, int mode, node->attr, node->attr->inode); *result =3D node; ret =3D 0; -err_out: - qemu_mutex_unlock(&synth_mutex); return ret; } =20 @@ -116,11 +114,11 @@ int qemu_v9fs_synth_add_file(V9fsSynthNode *parent, i= nt mode, parent =3D &synth_root; } =20 - qemu_mutex_lock(&synth_mutex); + QEMU_LOCK_GUARD(&synth_mutex); QLIST_FOREACH(tmp, &parent->child, sibling) { if (!strcmp(tmp->name, name)) { ret =3D EEXIST; - goto err_out; + return ret; } } /* Add file type and remove write bits */ @@ -136,8 +134,6 @@ int qemu_v9fs_synth_add_file(V9fsSynthNode *parent, int= mode, pstrcpy(node->name, sizeof(node->name), name); QLIST_INSERT_HEAD_RCU(&parent->child, node, sibling); ret =3D 0; -err_out: - qemu_mutex_unlock(&synth_mutex); return ret; } =20 --=20 2.20.1