From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CEEECC433DB for ; Thu, 11 Mar 2021 10:50:29 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 61A6964F94 for ; Thu, 11 Mar 2021 10:50:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 61A6964F94 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=crudebyte.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:51930 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lKItg-0006n3-8c for qemu-devel@archiver.kernel.org; Thu, 11 Mar 2021 05:50:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51962) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lKIse-00069L-5W for qemu-devel@nongnu.org; Thu, 11 Mar 2021 05:49:24 -0500 Received: from kylie.crudebyte.com ([5.189.157.229]:53321) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lKIsb-00079s-VR for qemu-devel@nongnu.org; Thu, 11 Mar 2021 05:49:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=kylie; h=Content-Type:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Content-ID:Content-Description; bh=BYizOT9dUfHktlagf9MIgomr+zf4PRe15NfuDnSjGZg=; b=Frs/Bejdu4w8XsjuKrZ51fIOtp a7Ej00MNI/1bR4fkfQ2Ct3YOyyusu2tOS+0bSWxiaeVBRsSajirVgw47A1bRgAL9SOUVfsBFbnuTz UHYj0eQsYWuXkTorZzEd3eMBf2ObhLtlvJqKZz5oongkap/3RRvvUwYvlG5yaaErV7rVSZB6364p7 7MPy8VoRVMhgPjBfjcq5qF4wa06scsXJnZRezCVslDX9PbSF8XD2/F86BoNt2L/8HyLI7DcfLoj0S kd/9gJ1fNZDyhjSEG+tW9JRXI+Jm1cCbLA3cT/jHT03Eq/hn/hWLwUTkZ+aJBjMmseCspBFZuDbwy YXh8/cXLacpIHmj/7JYhSv+6aqxJLhwJ2dA0neZCoKxwak8CJ4rEupO9NPfgK0J0+EIwigtnpxJiS ntW+BmZ728iJk2Tz0olm7N1Ld74fH0mB3invr/DjKBuY8E4NbytSZxN+N68aGTq6g8a/qfoIYE4ZF XdoKCBx0mMtT1J+BD4X21F4aK1quJTPUj/OaCpn+TiDZZJg6SwbkHh1Lw9+MjP0UOm0K1sONGBnPi IrY+/DVUZGkqQJjiROyAAr/kNPP9DG6vCOMxMLtwEcxYL+g9axleSU9jkKJ1jOdmiWDofHtrjviXq lHyX8oHLkc5SOJ8AKZy43nBHp8TLE2yJ3bjERSWp4=; From: Christian Schoenebeck To: qemu-devel@nongnu.org Cc: Mahmoud Mandour , Greg Kurz Subject: Re: [PATCH 8/9] hw/9pfs/9p-synth: Replaced qemu_mutex_lock with QEMU_LOCK_GUARD Date: Thu, 11 Mar 2021 11:49:06 +0100 Message-ID: <2248579.lIZarMFqrv@silver> In-Reply-To: <20210311031538.5325-9-ma.mandourr@gmail.com> References: <20210311031538.5325-1-ma.mandourr@gmail.com> <20210311031538.5325-9-ma.mandourr@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="iso-8859-1" Received-SPF: pass client-ip=5.189.157.229; envelope-from=qemu_oss@crudebyte.com; helo=kylie.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_PASS=-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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On Donnerstag, 11. M=E4rz 2021 04:15:37 CET Mahmoud Mandour wrote: > 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. >=20 > Signed-off-by: Mahmoud Mandour > --- > hw/9pfs/9p-synth.c | 12 ++++-------- > 1 file changed, 4 insertions(+), 8 deletions(-) >=20 > 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 > mode, 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 mo= de, > 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, > int 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, i= nt > 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; > } Reviewed-by: Christian Schoenebeck Greg, I suggest I'll push this onto my queue as you seem to be busy. Best regards, Christian Schoenebeck