File 0416-erts-Silence-CodeChecker-in-size_shared.patch of Package erlang

From 6f7ed7e09137e06cab11471ece73bb08b22ac7eb Mon Sep 17 00:00:00 2001
From: Sverker Eriksson <sverker@erlang.org>
Date: Mon, 8 Feb 2021 20:44:11 +0100
Subject: [PATCH 16/34] erts: Silence CodeChecker in size_shared()

---
 erts/emulator/beam/copy.c   | 12 +++++++++++-
 erts/emulator/beam/global.h |  3 +++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/erts/emulator/beam/copy.c b/erts/emulator/beam/copy.c
index 9d13b6eca3..23335fe595 100644
--- a/erts/emulator/beam/copy.c
+++ b/erts/emulator/beam/copy.c
@@ -276,6 +276,7 @@ do {									\
 do {                                                                    \
     UWord result;                                                       \
     if (WSTK_CONCAT(s,_bitoffs) <= 0) {                                 \
+        ASSERT(WSTK_CONCAT(s,_offset) < (s.wsp - s.wstart));            \
         WSTK_CONCAT(s,_buffer) = s.wstart[WSTK_CONCAT(s,_offset)];      \
         WSTK_CONCAT(s,_offset)++;                                       \
         WSTK_CONCAT(s,_bitoffs) = 8*sizeof(UWord);                      \
@@ -1036,11 +1037,17 @@ do {								\
     /* no WSTK_CONCAT(s,_offset), write-only */		\
     UWord WSTK_CONCAT(s,_buffer) = 0
 
+#ifdef DEBUG
+# define DEBUG_COND(D,E) D
+#else
+# define DEBUG_COND(D,E) E
+#endif
+
 #define DECLARE_BITSTORE_FROM_INFO(s, info)		\
     /* no WSTK_DEF_STACK(s), read-only */		\
     ErtsWStack s = {					\
         info->bitstore_start,  /* wstart */		\
-        NULL,                  /* wsp,  read-only */	\
+        DEBUG_COND(info->bitstore_stop, NULL), /* wsp,  read-only */ \
         NULL,                  /* wend, read-only */	\
         NULL,                  /* wdef, read-only */	\
         info->bitstore_alloc_type /* alloc_type */	\
@@ -1330,6 +1337,9 @@ Uint copy_shared_calculate(Eterm obj, erts_shcopy_t *info)
                 info->queue_end = s.end;
                 info->queue_alloc_type = s.alloc_type;
                 info->bitstore_start = b.wstart;
+#ifdef DEBUG
+                info->bitstore_stop = b.wsp;
+#endif
                 info->bitstore_alloc_type = b.alloc_type;
                 info->shtable_start = t.start;
                 info->shtable_alloc_type = t.alloc_type;
diff --git a/erts/emulator/beam/global.h b/erts/emulator/beam/global.h
index 133e1cfa51..dabf0ee06d 100644
--- a/erts/emulator/beam/global.h
+++ b/erts/emulator/beam/global.h
@@ -1023,6 +1023,9 @@ typedef struct {
     ErtsAlcType_t queue_alloc_type;
     UWord  bitstore_default[DEF_WSTACK_SIZE];
     UWord* bitstore_start;
+#ifdef DEBUG
+    UWord* bitstore_stop;
+#endif
     ErtsAlcType_t bitstore_alloc_type;
     Eterm  shtable_default[DEF_ESTACK_SIZE];
     Eterm* shtable_start;
-- 
2.26.2

openSUSE Build Service is sponsored by