All of lore.kernel.org
 help / color / mirror / Atom feed
* [XEN PATCH][for-4.19 v2] xen: Add SAF deviations for MISRA C:2012 Rule 7.1
@ 2023-10-19 11:04 Nicola Vetrini
  2023-10-19 15:57 ` Jan Beulich
  0 siblings, 1 reply; 14+ messages in thread
From: Nicola Vetrini @ 2023-10-19 11:04 UTC (permalink / raw)
  To: xen-devel
  Cc: sstabellini, michal.orzel, xenia.ragiadakou, ayan.kumar.halder,
	consulting, jbeulich, andrew.cooper3, roger.pau, Nicola Vetrini,
	Simone Ballarin, Doug Goldstein, George Dunlap, Julien Grall,
	Wei Liu

As specified in rules.rst, these constants can be used
in the code. Suitable deviations records are added in deviations.rst

Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
---
Changes in v2:
- replace some SAF deviations with configurations
---
 automation/eclair_analysis/ECLAIR/deviations.ecl | 8 ++++----
 docs/misra/deviations.rst                        | 6 ++++++
 docs/misra/safe.json                             | 8 ++++++++
 xen/common/inflate.c                             | 4 ++--
 4 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/automation/eclair_analysis/ECLAIR/deviations.ecl b/automation/eclair_analysis/ECLAIR/deviations.ecl
index fa56e5c00a27..3bf8e8b8fdec 100644
--- a/automation/eclair_analysis/ECLAIR/deviations.ecl
+++ b/automation/eclair_analysis/ECLAIR/deviations.ecl
@@ -85,10 +85,10 @@ conform to the directive."
 # Series 7.
 #

--doc_begin="Usage of the following constants is safe, since they are given as-is
-in the inflate algorithm specification and there is therefore no risk of them
-being interpreted as decimal constants."
--config=MC3R1.R7.1,literals={safe, "^0(007|37|070|213|236|300|321|330|331|332|333|334|335|337|371)$"}
+-doc_begin="Octal constants used as arguments to macro INSTR_ENC or MASK_EXTR
+can be used, because they appear as is in specifications, manuals, and
+algorithm descriptions."
+-config=MC3R1.R7.1,reports+={safe, "any_area(any_loc(any_exp(macro(^(INSTR_ENC|MASK_EXTR)$))))"}
 -doc_end

 -doc_begin="Violations in files that maintainers have asked to not modify in the
diff --git a/docs/misra/deviations.rst b/docs/misra/deviations.rst
index 8511a189253b..f26eb371f3e4 100644
--- a/docs/misra/deviations.rst
+++ b/docs/misra/deviations.rst
@@ -90,6 +90,12 @@ Deviations related to MISRA C:2012 Rules:
          - __emulate_2op and __emulate_2op_nobyte
          - read_debugreg and write_debugreg

+   * - R7.1
+     - It is safe to use certain octal constants the way they are defined in
+       specifications, manuals, and algorithm descriptions as arguments to
+       macros 'INSTR_ENC' and 'MASK_EXTR'.
+     - Tagged as `safe` for ECLAIR.
+
    * - R7.2
      - Violations caused by __HYPERVISOR_VIRT_START are related to the
        particular use of it done in xen_mk_ulong.
diff --git a/docs/misra/safe.json b/docs/misra/safe.json
index 39c5c056c7d4..7ea47344ffcc 100644
--- a/docs/misra/safe.json
+++ b/docs/misra/safe.json
@@ -20,6 +20,14 @@
         },
         {
             "id": "SAF-2-safe",
+            "analyser": {
+                "eclair": "MC3R1.R7.1"
+            },
+            "name": "Rule 7.1: constants defined in specifications, manuals, and algorithm descriptions",
+            "text": "It is safe to use certain octal constants the way they are defined in specifications, manuals, and algorithm descriptions."
+        },
+        {
+            "id": "SAF-3-safe",
             "analyser": {},
             "name": "Sentinel",
             "text": "Next ID to be used"
diff --git a/xen/common/inflate.c b/xen/common/inflate.c
index 8fa4b96d12a3..be6a9115187e 100644
--- a/xen/common/inflate.c
+++ b/xen/common/inflate.c
@@ -1201,8 +1201,8 @@ static int __init gunzip(void)
     magic[1] = NEXTBYTE();
     method   = NEXTBYTE();

-    if (magic[0] != 037 ||
-        ((magic[1] != 0213) && (magic[1] != 0236))) {
+    /* SAF-2-safe */
+    if (magic[0] != 037 || ((magic[1] != 0213) && (magic[1] != 0236))) {
         error("bad gzip magic numbers");
         return -1;
     }
--
2.34.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2023-10-23  9:10 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-19 11:04 [XEN PATCH][for-4.19 v2] xen: Add SAF deviations for MISRA C:2012 Rule 7.1 Nicola Vetrini
2023-10-19 15:57 ` Jan Beulich
2023-10-19 16:34   ` Nicola Vetrini
2023-10-20  6:38     ` Jan Beulich
2023-10-20 10:33       ` Nicola Vetrini
2023-10-20 13:24         ` Jan Beulich
2023-10-20 14:58           ` Nicola Vetrini
2023-10-23  6:34             ` Jan Beulich
2023-10-23  8:03               ` Nicola Vetrini
2023-10-23  8:17                 ` Jan Beulich
2023-10-23  8:44                   ` Nicola Vetrini
2023-10-23  8:46                     ` Nicola Vetrini
2023-10-23  8:47                     ` Jan Beulich
2023-10-23  9:10                       ` Nicola Vetrini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.