[rtems commit] cacheimpl.h: Avoid potential dead code

Sebastian Huber sebh at rtems.org
Wed Jan 27 18:11:28 UTC 2021


Module:    rtems
Branch:    master
Commit:    361ec32070d74af2747367699b7633deb95d7f96
Changeset: http://git.rtems.org/rtems/commit/?id=361ec32070d74af2747367699b7633deb95d7f96

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Wed Jan 27 16:33:01 2021 +0100

cacheimpl.h: Avoid potential dead code

If CPU_DATA_CACHE_ALIGNMENT == CPU_INSTRUCTION_CACHE_ALIGNMENT we had
dead code with the previous implementation.

This fix relates to CID 1399776 (DEADCODE).

---

 bsps/shared/cache/cacheimpl.h | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/bsps/shared/cache/cacheimpl.h b/bsps/shared/cache/cacheimpl.h
index 42ccdc1..3fceaba 100644
--- a/bsps/shared/cache/cacheimpl.h
+++ b/bsps/shared/cache/cacheimpl.h
@@ -83,6 +83,8 @@
 
 #include <rtems.h>
 
+#include <sys/param.h>
+
 #if defined(RTEMS_SMP) && defined(CPU_CACHE_NO_INSTRUCTION_CACHE_SNOOPING)
 #include <rtems/score/smpimpl.h>
 #include <rtems/score/threaddispatch.h>
@@ -437,22 +439,19 @@ size_t rtems_cache_get_maximal_line_size( void )
 #if defined(CPU_MAXIMAL_CACHE_ALIGNMENT)
   return CPU_MAXIMAL_CACHE_ALIGNMENT;
 #endif
-  size_t max_line_size = 0;
+  size_t data_line_size =
 #if defined(CPU_DATA_CACHE_ALIGNMENT)
-  {
-    size_t data_line_size = CPU_DATA_CACHE_ALIGNMENT;
-    if ( max_line_size < data_line_size )
-      max_line_size = data_line_size;
-  }
+    CPU_DATA_CACHE_ALIGNMENT;
+#else
+    0;
 #endif
+  size_t instruction_line_size =
 #if defined(CPU_INSTRUCTION_CACHE_ALIGNMENT)
-  {
-    size_t instruction_line_size = CPU_INSTRUCTION_CACHE_ALIGNMENT;
-    if ( max_line_size < instruction_line_size )
-      max_line_size = instruction_line_size;
-  }
+    CPU_INSTRUCTION_CACHE_ALIGNMENT;
+#else
+    0;
 #endif
-  return max_line_size;
+  return MAX( data_line_size, instruction_line_size );
 }
 
 /*



More information about the vc mailing list