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=-7.5 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no 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 CD960C433E0 for ; Thu, 11 Mar 2021 10:10:00 +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 4ED0164F45 for ; Thu, 11 Mar 2021 10:10:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4ED0164F45 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:55694 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lKIGV-0001yL-9i for qemu-devel@archiver.kernel.org; Thu, 11 Mar 2021 05:09:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:37496) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lKICE-0005ci-P3 for qemu-devel@nongnu.org; Thu, 11 Mar 2021 05:05:34 -0500 Received: from mail-ed1-x535.google.com ([2a00:1450:4864:20::535]:38697) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lKICC-0004Yi-Tn for qemu-devel@nongnu.org; Thu, 11 Mar 2021 05:05:34 -0500 Received: by mail-ed1-x535.google.com with SMTP id h13so1860212eds.5 for ; Thu, 11 Mar 2021 02:05:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Hbuo7BNkfdNVplF+xs0lk0+0tJnOIupYbC+a6MpKJ1o=; b=uNO6T8pzRztP5FbVL8z9t+2eb5HD8yUuvaqWQqQ0HHzUbKvVx0X9D3iklQtvSsOq79 HmZBdlJ3mMtwfriESpq15JzN9Fu/HTkc/80L331CAERTPLexmGkv0FkWapHj3gc+W7fI UCC3kA91gvi3sxyO6voNX8nQABXytBTpwIdbG4MuK//yloKJYc047XXU7Uet2Ny1/yTM IfkhuiLpfrpJS/2K6BwGhyNpmKg1G5UKKFGIeYyitSiWRVZX7X+TJgXlVIalLEc8tB7/ lwMkM4vSNwcnO3y2jbivRkoig7enmH9xjKKGchdeKSLKlctzRZdVCN4PbES9K4P9vdMs f25g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Hbuo7BNkfdNVplF+xs0lk0+0tJnOIupYbC+a6MpKJ1o=; b=fDYLxdvbnAH3eZy1JFHZH3X2iyEYX8B/OSVrkwfDGeFWEzlgZ82+siFkC1F7sYIp8M LxbVJCMur0n5OroQGVV70+bHLh69XYDHduFoFwlKPWz1gMBoebqN/InTp4a7f48YyN3E /zo1s1CtYmFiWMzWyzYer5WSAmJakniB1hKpW69TEnR+VooRF+jMIzcYztevDk4ni+vz KvVSGWfdwOtDIpYcCWSuxxig0bamDZcAhWl9WT0jEhyOxDX0Q8FSS5+1lNLgOcypFlS6 6DaHcGd1IJBBeJXRdG+AvAzymO2w30L/0wdST3uZQDYL2kH0j4KEoTBDEA6cp0WbTtpj e3Fw== X-Gm-Message-State: AOAM530ooTckI+zx/vp+bnu1wIT6HHDW3sHiDzCFS9L4RGdaOfxw5bAu pImIYGGOKwDrgstHaofs/0EvhFV2xujQ2jUgr6I= X-Google-Smtp-Source: ABdhPJz6BdF2qOZsH2WqoVBe0zsHUhfFwAViLOZdGL0Z8wB8CfjuJYsTqM6+RbzKglPHERo/eZXklzyzL4ZBmwFjQc8= X-Received: by 2002:aa7:cf17:: with SMTP id a23mr7916001edy.30.1615457131575; Thu, 11 Mar 2021 02:05:31 -0800 (PST) MIME-Version: 1.0 References: <20210311031538.5325-1-ma.mandourr@gmail.com> <20210311031538.5325-4-ma.mandourr@gmail.com> In-Reply-To: <20210311031538.5325-4-ma.mandourr@gmail.com> From: =?UTF-8?B?TWFyYy1BbmRyw6kgTHVyZWF1?= Date: Thu, 11 Mar 2021 14:05:20 +0400 Message-ID: Subject: Re: [PATCH 3/9] char: Replaced a qemu_mutex_lock with QEMU_LOCK_GUARD To: Mahmoud Mandour Content-Type: multipart/alternative; boundary="0000000000007a3d8205bd3fecd7" Received-SPF: pass client-ip=2a00:1450:4864:20::535; envelope-from=marcandre.lureau@gmail.com; helo=mail-ed1-x535.google.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, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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: , Cc: Paolo Bonzini , QEMU Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" --0000000000007a3d8205bd3fecd7 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Mar 11, 2021 at 1:28 PM Mahmoud Mandour wrote: > Removed a pair of qemu_mutex_lock and its respective qemu_mutex_unlock > and used a QEMU_LOCK_GUARD instead. This improves readability by > removing the call to qemu_mutex_unlock. > > Signed-off-by: Mahmoud Mandour > Reviewed-by: Marc-Andr=C3=A9 Lureau --- > chardev/char.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/chardev/char.c b/chardev/char.c > index 97cafd6849..2b0bc1325c 100644 > --- a/chardev/char.c > +++ b/chardev/char.c > @@ -115,7 +115,7 @@ static int qemu_chr_write_buffer(Chardev *s, > int res =3D 0; > *offset =3D 0; > > - qemu_mutex_lock(&s->chr_write_lock); > + QEMU_LOCK_GUARD(&s->chr_write_lock); > while (*offset < len) { > retry: > res =3D cc->chr_write(s, buf + *offset, len - *offset); > @@ -153,7 +153,6 @@ static int qemu_chr_write_buffer(Chardev *s, > */ > qemu_chr_write_log(s, buf, len); > } > - qemu_mutex_unlock(&s->chr_write_lock); > > return res; > } > -- > 2.25.1 > > > --=20 Marc-Andr=C3=A9 Lureau --0000000000007a3d8205bd3fecd7 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Thu, Mar 11, 2021 at 1:28 PM Mahmo= ud Mandour <ma.mandourr@gmail.c= om> wrote:
ma.mandourr@gmail.com>

<= /div>
Reviewed-by: Marc-Andr=C3=A9 Lureau <marcandre.lureau@redhat.com>=C2=A0
<= div>
---
=C2=A0chardev/char.c | 3 +--
=C2=A01 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/chardev/char.c b/chardev/char.c
index 97cafd6849..2b0bc1325c 100644
--- a/chardev/char.c
+++ b/chardev/char.c
@@ -115,7 +115,7 @@ static int qemu_chr_write_buffer(Chardev *s,
=C2=A0 =C2=A0 =C2=A0int res =3D 0;
=C2=A0 =C2=A0 =C2=A0*offset =3D 0;

-=C2=A0 =C2=A0 qemu_mutex_lock(&s->chr_write_lock);
+=C2=A0 =C2=A0 QEMU_LOCK_GUARD(&s->chr_write_lock);
=C2=A0 =C2=A0 =C2=A0while (*offset < len) {
=C2=A0 =C2=A0 =C2=A0retry:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0res =3D cc->chr_write(s, buf + *offset= , len - *offset);
@@ -153,7 +153,6 @@ static int qemu_chr_write_buffer(Chardev *s,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 */
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0qemu_chr_write_log(s, buf, len);
=C2=A0 =C2=A0 =C2=A0}
-=C2=A0 =C2=A0 qemu_mutex_unlock(&s->chr_write_lock);

=C2=A0 =C2=A0 =C2=A0return res;
=C2=A0}
--
2.25.1




--
Marc-Andr=C3=A9 Lureau
--0000000000007a3d8205bd3fecd7--