From nobody Sun May 19 00:17:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1661892526; cv=none; d=zohomail.com; s=zohoarc; b=XazJ+WJaHUAngHZZZsm9k+A3VN9Vnzy4LltFhrJfVnHx2H8GfYGtuCGG+Vm3F/KsgLKHb0BxFQ91K9RSof3J0dKG+HSJRq2YejPtpFDmsBcvlcG5mc6tFDpIF7tbWFE/gqnMg9x32+NDnSS/jrC8PnfAPHFx1+2z2GywVF0ADHY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661892526; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=QlxW8fxVxO+DakXYQ5ScpHK2jDTcDSsFw0JIb0kLB2g=; b=DUnFiuF7KwRtfqHB/2dHm9ezHSz6swmNBQZDoGYaobliCLlDYO1vx0QgzNOt6/IPWmrOvsQCvpQncRPWXucjzIuukG26xJ8jv7n143lCHEwmXgScW3ECG3G72MwVZs0sCdQEFuJLSUdtjA+6YJCAYj7ivgWlDCJXKQpshiFPt+o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1661892526784896.9345520145409; Tue, 30 Aug 2022 13:48:46 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.395156.634741 (Exim 4.92) (envelope-from ) id 1oT89s-0002Cp-DR; Tue, 30 Aug 2022 20:48:28 +0000 Received: by outflank-mailman (output) from mailman id 395156.634741; Tue, 30 Aug 2022 20:48:28 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oT89s-0002Ci-At; Tue, 30 Aug 2022 20:48:28 +0000 Received: by outflank-mailman (input) for mailman id 395156; Tue, 30 Aug 2022 20:48:26 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oT89q-0002Cc-OJ for xen-devel@lists.xenproject.org; Tue, 30 Aug 2022 20:48:26 +0000 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [2a00:1450:4864:20::629]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 1803c121-28a5-11ed-a60c-1f1ba7de4fb0; Tue, 30 Aug 2022 22:48:25 +0200 (CEST) Received: by mail-ej1-x629.google.com with SMTP id qh18so4329994ejb.7 for ; Tue, 30 Aug 2022 13:48:25 -0700 (PDT) Received: from uni.. (adsl-47.176.58.181.tellas.gr. [176.58.181.47]) by smtp.googlemail.com with ESMTPSA id j17-20020a17090623f100b0074182109623sm3594527ejg.39.2022.08.30.13.48.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 13:48:24 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 1803c121-28a5-11ed-a60c-1f1ba7de4fb0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc; bh=QlxW8fxVxO+DakXYQ5ScpHK2jDTcDSsFw0JIb0kLB2g=; b=RYKuBA/L4kTdkOMKoagUGEzUbqT8LDfmIcL4xCfdJ5yBbuf9aazz3UwPCxMe8TO1fO dDtzJnDliA+j5vm6IQzhWWymKDIboyK6v3GoGUkTjA5MJcKuglgcyGeGzQlbNCdchNFT YZtFEySi02X2xDPudnYZ2yreGk2w6q9GoY4UpMkxGPSnH7lmcxwUMfAD57UNF/EUvAwF ucpdy2xnaOgHN96gtY6m/9FaKoSlg2vdPG4rzc1GoGxE28Gg2+ZRRd4IygFJI/FZzSHJ +ec/zo7frJ7SkbgjhV6I1Zv9y+aeMYepYQy+i23L1VDc+Wvnle1Qcg6U810WRDlUzSOT Hi0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc; bh=QlxW8fxVxO+DakXYQ5ScpHK2jDTcDSsFw0JIb0kLB2g=; b=uoRFmA30bp4SZEzE627hIIvRkJBWFv0zchRCsZq2s6cGLQ6YXkcxm+/jaMUcl5j2Xt aEE4NsqJCO4kARUplKOCYUwzSWQsGomJbBlFy8fXyTHyPD+1A4w5WAH7e3H0YFmZJ8wd 0brUG/ve7cEDSq3cMQja+91EV6j81kbm53l5cBaqBAmQmJcZGd8j+5hchTpgU46rg0oP 8yI0+EdHPPZu37k7o75pb69oBAGoJCYC9pzmR+EM3mImRewqNnE08urPLdNatPBAy/fv LI+VlRWyXwrliv2njgAuGLrl5fo4wrWXavCSxL4vrJpUH4lSLKRhCggun/BrrTm46ii3 /a3w== X-Gm-Message-State: ACgBeo3Re3+68apwsj6qv8yJ43wSciECpf9oQsJDgs9N6Ssy3kt2lbGm zTAV3Ab+Y85onWkC3uNmrOK0mIEbDyM= X-Google-Smtp-Source: AA6agR5rf3UuGZBEchVthOgkTUUc10jQ7Fa3Gp2209wD4YCC5/XU1cEqVOORpYYpLx2yT1mZXcP9UQ== X-Received: by 2002:a17:906:8b81:b0:733:183b:988e with SMTP id nr1-20020a1709068b8100b00733183b988emr17995652ejc.457.1661892505105; Tue, 30 Aug 2022 13:48:25 -0700 (PDT) From: Xenia Ragiadakou To: xen-devel@lists.xenproject.org Cc: Stefano Stabellini , Julien Grall Subject: [PATCH v2] xen/device_tree: Fix MISRA C 2012 Rule 20.7 violations Date: Tue, 30 Aug 2022 23:48:18 +0300 Message-Id: <20220830204818.1374930-1-burzalodowa@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1661892529081100001 Content-Type: text/plain; charset="utf-8" Add parentheses around the macro parameters that are used as expressions to prevent against unintended expansions during macro substitution. Signed-off-by: Xenia Ragiadakou --- Changes in v2: - apply rule 20.7 as is, without deviating from it - adjust commit message accordingly Also, in this file, the macro dt_irq(irq) has not been defined properly but since it is not used, the bug has not been uncovered yet. I can either fix it or remove it along with macro dt_irq_flags(irq) under rule 2.5 "A project should not contain unused macro declarations" (advisory) xen/include/xen/device_tree.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h index 430a1ef445..6e253f5763 100644 --- a/xen/include/xen/device_tree.h +++ b/xen/include/xen/device_tree.h @@ -37,11 +37,11 @@ struct dt_device_match { const void *data; }; =20 -#define __DT_MATCH_PATH(p) .path =3D p -#define __DT_MATCH_TYPE(typ) .type =3D typ -#define __DT_MATCH_COMPATIBLE(compat) .compatible =3D compat +#define __DT_MATCH_PATH(p) .path =3D (p) +#define __DT_MATCH_TYPE(typ) .type =3D (typ) +#define __DT_MATCH_COMPATIBLE(compat) .compatible =3D (compat) #define __DT_MATCH_NOT_AVAILABLE() .not_available =3D 1 -#define __DT_MATCH_PROP(p) .prop =3D p +#define __DT_MATCH_PROP(p) .prop =3D (p) =20 #define DT_MATCH_PATH(p) { __DT_MATCH_PATH(p) } #define DT_MATCH_TYPE(typ) { __DT_MATCH_TYPE(typ) } @@ -222,13 +222,13 @@ dt_find_interrupt_controller(const struct dt_device_m= atch *matches); #define DT_ROOT_NODE_SIZE_CELLS_DEFAULT 1 =20 #define dt_for_each_property_node(dn, pp) \ - for ( pp =3D dn->properties; pp !=3D NULL; pp =3D pp->next ) + for ( (pp) =3D (dn)->properties; (pp) !=3D NULL; (pp) =3D (pp)->next ) =20 #define dt_for_each_device_node(dt, dn) \ - for ( dn =3D dt; dn !=3D NULL; dn =3D dn->allnext ) + for ( (dn) =3D (dt); (dn) !=3D NULL; (dn) =3D (dn)->allnext ) =20 #define dt_for_each_child_node(dt, dn) \ - for ( dn =3D dt->child; dn !=3D NULL; dn =3D dn->sibling ) + for ( (dn) =3D (dt)->child; (dn) !=3D NULL; (dn) =3D (dn)->sibling ) =20 /* Helper to read a big number; size is in cells (not bytes) */ static inline u64 dt_read_number(const __be32 *cell, int size) --=20 2.34.1