[rtems-central commit] spec: Add STATIC_ANALYSIS and NOINIT specs

Sebastian Huber sebh at rtems.org
Fri Sep 24 11:32:07 UTC 2021


Module:    rtems-central
Branch:    master
Commit:    f256d34e8fe56e711d0efde14b22f926b8a05086
Changeset: http://git.rtems.org/rtems-central/commit/?id=f256d34e8fe56e711d0efde14b22f926b8a05086

Author:    Frank Kühndel <frank.kuehndel at embedded-brains.de>
Date:      Thu Sep 16 18:55:57 2021 +0200

spec: Add STATIC_ANALYSIS and NOINIT specs

This specification is up to date for
./cpukit/include/rtems/score/basedefs.h with
commit 9e13cbe8721e725c67d2d8bd16df66265c39a75b

---

 spec/rtems/basedefs/req/noinit-0.yml          | 20 +++++++++
 spec/rtems/basedefs/req/section-0.yml         |  2 +-
 spec/rtems/basedefs/req/static-analysis-0.yml | 15 +++++++
 spec/rtems/basedefs/req/static-analysis-1.yml | 15 +++++++
 spec/rtems/basedefs/val/basedefs.yml          | 60 ++++++++++++++++++++++++++-
 5 files changed, 110 insertions(+), 2 deletions(-)

diff --git a/spec/rtems/basedefs/req/noinit-0.yml b/spec/rtems/basedefs/req/noinit-0.yml
new file mode 100644
index 0000000..b60d0c3
--- /dev/null
+++ b/spec/rtems/basedefs/req/noinit-0.yml
@@ -0,0 +1,20 @@
+SPDX-License-Identifier: CC-BY-SA-4.0
+copyrights:
+- Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de)
+enabled-by: true
+links:
+- role: interface-function
+  uid: ../if/noinit
+non-functional-type: interface
+rationale: null
+references: []
+requirement-type: non-functional
+text: |
+  When the code is compiled with the GNU C compiler,
+  and the ${../if/section:/name} macro is attached to a
+  global variable definition,
+  and the file format used supports arbitrary sections,
+  the macro shall cause the compiler to store the
+  variable in a section where its value is not initialized
+  during initial start up.
+type: requirement
diff --git a/spec/rtems/basedefs/req/section-0.yml b/spec/rtems/basedefs/req/section-0.yml
index 7aa5dae..133069b 100644
--- a/spec/rtems/basedefs/req/section-0.yml
+++ b/spec/rtems/basedefs/req/section-0.yml
@@ -18,6 +18,6 @@ text: |
   C sting containing valid linker section name,
   and the file format used supports arbitary sections,
   the macro shall cause the compiler to store the function or
-  variable is a section named like the result of the pre-processor
+  variable in a section named like the result of the pre-processor
   substitutions on its argument ${../if/section:/params[0]/name}.
 type: requirement
diff --git a/spec/rtems/basedefs/req/static-analysis-0.yml b/spec/rtems/basedefs/req/static-analysis-0.yml
new file mode 100644
index 0000000..346cf33
--- /dev/null
+++ b/spec/rtems/basedefs/req/static-analysis-0.yml
@@ -0,0 +1,15 @@
+SPDX-License-Identifier: CC-BY-SA-4.0
+copyrights:
+- Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de)
+enabled-by: true
+links:
+- role: interface-function
+  uid: ../if/static-analysis
+non-functional-type: interface
+rationale: null
+references: []
+requirement-type: non-functional
+text: |
+  When the macro ``__COVERITY__`` is defined,
+  the macro ${../if/static-analysis:/name} shall be defined.
+type: requirement
diff --git a/spec/rtems/basedefs/req/static-analysis-1.yml b/spec/rtems/basedefs/req/static-analysis-1.yml
new file mode 100644
index 0000000..ee33b87
--- /dev/null
+++ b/spec/rtems/basedefs/req/static-analysis-1.yml
@@ -0,0 +1,15 @@
+SPDX-License-Identifier: CC-BY-SA-4.0
+copyrights:
+- Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de)
+enabled-by: true
+links:
+- role: interface-function
+  uid: ../if/static-analysis
+non-functional-type: interface
+rationale: null
+references: []
+requirement-type: non-functional
+text: |
+  When the macro ``__COVERITY__`` is not defined,
+  the macro ${../if/static-analysis:/name} shall be not defined.
+type: requirement
diff --git a/spec/rtems/basedefs/val/basedefs.yml b/spec/rtems/basedefs/val/basedefs.yml
index d357081..617920e 100644
--- a/spec/rtems/basedefs/val/basedefs.yml
+++ b/spec/rtems/basedefs/val/basedefs.yml
@@ -1,6 +1,6 @@
 SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
 copyrights:
-- Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
+- Copyright (C) 2020, 2021 embedded brains GmbH (http://www.embedded-brains.de)
 enabled-by: true
 links: []
 test-actions:
@@ -755,6 +755,22 @@ test-actions:
       uid: ../req/no-return-0
   links: []
 - action-brief: |
+    Use the ${../if/noinit:/name} macro on ``noinit_variable`` at the
+    beginning of this file.
+  action-code: |
+    /* No action */
+  checks:
+  - brief: |
+      It cannot be checked that the ${../if/noinit:/name}
+      macro has the desired effect. Yet, the check confirms that such a
+      macro exists and can be used.
+    code: |
+      T_step_not_null( ${step}, &noinit_variable );
+    links:
+    - role: validation
+      uid: ../req/noinit-0
+  links: []
+- action-brief: |
     Use the ${../if/obfuscate-variable:/name} macro.
   action-code: |
     short obfuscate_variable = 66;
@@ -935,6 +951,46 @@ test-actions:
       uid: ../req/section-0
   links: []
 - action-brief: |
+    Use the ${../if/static-analysis:/name} macro.
+  action-code: |
+    /* No action */
+  checks:
+  - brief: |
+      It cannot be automatically check that
+      the ${../if/static-analysis:/name} macro has the desired effect.
+    code: |
+      #if defined(__COVERITY__)
+      #  if defined(RTEMS_STATIC_ANALYSIS)
+        T_quiet_true( true, "test passes, no output" );
+      #  else
+        T_quiet_true( false, "RTEMS_STATIC_ANALYSIS not defined" );
+      #  endif
+      #endif
+    links:
+    - role: validation
+      uid: ../req/static-analysis-0
+  links: []
+- action-brief: |
+    Use the ${../if/static-analysis:/name} macro.
+  action-code: |
+    /* No action */
+  checks:
+  - brief: |
+      It cannot be automatically check that
+      the ${../if/static-analysis:/name} macro has the desired effect.
+    code: |
+      #if !defined(__COVERITY__)
+      #  if !defined(RTEMS_STATIC_ANALYSIS)
+        T_quiet_true( true, "test passes, no output" );
+      #  else
+        T_quiet_true( false, "RTEMS_STATIC_ANALYSIS defined" );
+      #  endif
+      #endif
+    links:
+    - role: validation
+      uid: ../req/static-analysis-1
+  links: []
+- action-brief: |
     Use the ${../if/static-assert:/name} macro.
   action-code: |
     RTEMS_STATIC_ASSERT( STATIC_ASSERT_COND 1, RTEMS_STATIC_ASSERT_test );
@@ -1509,6 +1565,8 @@ test-support: |
     }
   }
 
+  RTEMS_NOINIT static uint32_t noinit_variable;
+
   static int ori_func( int x )
   {
      return 2 * x;



More information about the vc mailing list