[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v1] misra: add deviation of Rule 5.5


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: <victorm.lira@xxxxxxx>
  • Date: Wed, 23 Apr 2025 10:54:28 -0700
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=YKFZrKOZiJ4lCI2I4BIQggJos/VogNtDwCWL86GgUSg=; b=ECJnzfdJb0ffifPb+MA889KZ7txkcH2ntoP3ICoaVD5iiSHWbL/TGNnjqS7UPJQFfylLl95SxSSYrcIfbnRbbUZyPhtfnlE4Ip6NCN1AK+A2UcbIoMcqmlWoLvB9XSqYlnWkbP6+sKwpqwhj6pSJlgQp9RHMP9JUtBwaToAXq+FQxT2JizgHEqNjEwBy9Y+V6Cd9v/IG+sQXXPlg//W3zVO6CfVM+mIZjKvvGjU746+DZbTMCcpFvipmY+z+sS5D7c0Zaxts/4KDeKJAMJ5zwXzloqbR6etvVN9JikuzFodrHJYl2kHWbQay8eQcIfh9906IIjZi1JXVeQQkZ7cvtw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=gwtTFL9sT1dcay8mAApgdW7s35a+v5+VRUQbexzPCKe/VbMnR1u2/DbMFE8Z3a1c381kYHtB/WM4jga2rcXJ0E5uSD2cxECA54Q4Yt9HGsaPm4v87U/ip0MiF/9Dv2nGfsnYE3FySpxWn07bwwnGDfSPcqvEXeiCuam9jaN9/0VWL600UERxWbDHqLzeLf/r0lHBmxF9gMzH3c2auma5MwUTiPvrrcV5E7mJZ8GKEtDHGja7ueR2SHdMvnrQ77jABnAMEzQJ70wdOThLBW4KRq6BAGEiLRxoPY69Ey2TvIVp6OHg2g67tiVMlsnQjMEx3x5mztSmIgUMI1dzOT9I8g==
  • Cc: Federico Serafini <federico.serafini@xxxxxxxxxxx>, Victor Lira <victorm.lira@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, "Anthony PERARD" <anthony.perard@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, "Stefano Stabellini" <sstabellini@xxxxxxxxxx>, Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>
  • Delivery-date: Wed, 23 Apr 2025 17:56:40 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

From: Federico Serafini <federico.serafini@xxxxxxxxxxx>

MISRA C Rule 5.5 states that:
"Identifiers shall be distinct from macro names".

A common pattern in Xen is to have a function-like macro that acts as a
"wrapper" for the function to be called:
before calling the function, the macro adds additional checks or
increase/decrease the number of parameters depending on the
configuration.

Update ECLAIR configuration and deviations.rst.

Signed-off-by: Federico Serafini <federico.serafini@xxxxxxxxxxx>
Signed-off-by: Victor Lira <victorm.lira@xxxxxxx>
---
Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
Cc: Anthony PERARD <anthony.perard@xxxxxxxxxx>
Cc: Michal Orzel <michal.orzel@xxxxxxx>
Cc: Jan Beulich <jbeulich@xxxxxxxx>
Cc: Julien Grall <julien@xxxxxxx>
Cc: Roger Pau Monné <roger.pau@xxxxxxxxxx>
Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>
Cc: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
Cc: Federico Serafini <federico.serafini@xxxxxxxxxxx>
Cc: Bertrand Marquis <bertrand.marquis@xxxxxxx>
---
 automation/eclair_analysis/ECLAIR/deviations.ecl | 8 ++++++++
 docs/misra/deviations.rst                        | 8 ++++++++
 2 files changed, 16 insertions(+)

diff --git a/automation/eclair_analysis/ECLAIR/deviations.ecl 
b/automation/eclair_analysis/ECLAIR/deviations.ecl
index ffa23b53b7..303b06203a 100644
--- a/automation/eclair_analysis/ECLAIR/deviations.ecl
+++ b/automation/eclair_analysis/ECLAIR/deviations.ecl
@@ -114,6 +114,14 @@ it defines would (in the common case) be already defined. 
Peer reviewed by the c
 -config=MC3A2.R5.5,reports+={deliberate, 
"any_area(decl(kind(function))||any_loc(macro(name(memcpy||memset||memmove))))&&any_area(any_loc(file(^xen/common/libelf/libelf-private\\.h$)))"}
 -doc_end

+-doc_begin="Clashes between function-like macros and function names are
+deliberate since a common pattern in Xen is to have a function-like macro
+that acts as a \"wrapper\" for the function to be called:
+before calling the function, the macro adds additional checks or
+increase/decrease the number of parameters depending on the configuration."
+-config=MC3A2.R5.5,reports+={deliberate, 
"all_area(macro(function_like())||decl(kind(function)))"}
+-doc_end
+
 -doc_begin="The type \"ret_t\" is deliberately defined multiple times,
 depending on the guest."
 -config=MC3A2.R5.6,reports+={deliberate,"any_area(any_loc(text(^.*ret_t.*$)))"}
diff --git a/docs/misra/deviations.rst b/docs/misra/deviations.rst
index 88328eaa8a..cfdd1a9838 100644
--- a/docs/misra/deviations.rst
+++ b/docs/misra/deviations.rst
@@ -130,6 +130,14 @@ Deviations related to MISRA C:2012 Rules:
        memmove.
      - Tagged as `deliberate` for ECLAIR.

+   * - R5.5
+     - Clashes between function-like macros and function names are
+       deliberate since a common pattern in Xen is to have a function-like
+       macro that acts as a "wrapper" for the function to be called:
+       before calling the function, the macro adds additional checks or
+       increase/decrease the number of parameters depending on the 
configuration.
+     - Tagged as `deliberate` for ECLAIR.
+
    * - R5.6
      - The type ret_t is deliberately defined multiple times depending on the
        type of guest to service.
--
2.47.0



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.