Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B1421C6FD1C for ; Sat, 11 Mar 2023 14:36:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230373AbjCKOgK (ORCPT ); Sat, 11 Mar 2023 09:36:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230372AbjCKOgH (ORCPT ); Sat, 11 Mar 2023 09:36:07 -0500 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65A2FE502E for ; Sat, 11 Mar 2023 06:36:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=date:from:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=jMouezBBL3soxbH8ICdrUfcoEX4o/23uUVRU1belL5g=; b=GlR/HC9kkXXaCptGLEXGraiUmvEnantMZ+bt+V1FCAVQEXVbs0ztVP1o uJgIqdmw2aE5Njv0KuVAIZsXZqEFSoiMyTyXc1EJaoVo0MmFVmYiNDMlg lKDSVceKin35Lt8rHYta2Idi2pCFAn5NjgNrLidLaWLclhyKpIIDEwHoo s=; Authentication-Results: mail2-relais-roc.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=julia.lawall@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="5.98,252,1673910000"; d="scan'208";a="96649449" Received: from 231.85.89.92.rev.sfr.net (HELO hadrien) ([92.89.85.231]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Mar 2023 15:36:01 +0100 Date: Sat, 11 Mar 2023 15:36:01 +0100 (CET) From: Julia Lawall X-X-Sender: jll@hadrien To: Menna Mahmoud cc: outreachy@lists.linux.dev, pure.logic@nexus-software.ie, johan@kernel.org, elder@kernel.org, gregkh@linuxfoundation.org, greybus-dev@lists.linaro.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH] staging: greybus: eclose macro in a do - while loop In-Reply-To: <20230311135919.9129-1-eng.mennamahmoud.mm@gmail.com> Message-ID: References: <20230311135919.9129-1-eng.mennamahmoud.mm@gmail.com> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Menna, There is a typo in the subject line. On Sat, 11 Mar 2023, Menna Mahmoud wrote: > " ERROR: Macros with multiple statements should be enclosed in a do - > while loop" > > Reported by checkpath. > > do loop with the conditional expression set to a constant > value of zero (0).This creates a loop that > will execute exactly one time.This is a coding idiom that > allows a multi-line macro to be used anywhere > that a single statement can be used. > > So, enclose `gb_loopback_stats_attrs` macro in do - while (0) to > fix checkpath error The log message should focus on what is done and why. The checkpatch warning text and the fact that the problem was detected using checkpatch is useful, but less, so it should come last, not first. Here, what is done is to enclose a sequence of statements in a macro definition in a do-while loop with a test expression 0. The reason why is to make it safe to use the sequence anywhere a single statement can be used. A period at the end of a sentence should be followed by some whitespace before starting the next sentence. julia > Signed-off-by: Menna Mahmoud > --- > drivers/staging/greybus/loopback.c | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) > > diff --git a/drivers/staging/greybus/loopback.c b/drivers/staging/greybus/loopback.c > index 1a61fce98056..e86d50638cb5 100644 > --- a/drivers/staging/greybus/loopback.c > +++ b/drivers/staging/greybus/loopback.c > @@ -162,10 +162,12 @@ static ssize_t name##_avg_show(struct device *dev, \ > } \ > static DEVICE_ATTR_RO(name##_avg) > > -#define gb_loopback_stats_attrs(field) \ > - gb_loopback_ro_stats_attr(field, min, u); \ > - gb_loopback_ro_stats_attr(field, max, u); \ > - gb_loopback_ro_avg_attr(field) > +#define gb_loopback_stats_attrs(field) \ > + do { \ > + gb_loopback_ro_stats_attr(field, min, u); \ > + gb_loopback_ro_stats_attr(field, max, u); \ > + gb_loopback_ro_avg_attr(field); \ > + } while (0) > > #define gb_loopback_attr(field, type) \ > static ssize_t field##_show(struct device *dev, \ > -- > 2.34.1 > > >