A new user interface for you! Read more...

File 0275-erl_interface-fix-bad-memset.patch of Package erlang

From bd31798262cd20354e64cca8654b0781b33d7ede Mon Sep 17 00:00:00 2001
From: Mikael Pettersson <mikpelinux@gmail.com>
Date: Sat, 21 Apr 2018 14:08:14 +0200
Subject: [PATCH] erl_interface: fix bad memset

Compiling OTP-20.3.4 with GCC-7 generates the following warning:

 CC     /tmp/otp_src_20.3.4/lib/erl_interface/obj.st/x86_64-unknown-linux-gnu/erl_marshal.o
legacy/erl_marshal.c: In function 'erl_init_marshal':
legacy/erl_marshal.c:110:5: warning: 'memset' used with length equal to number of elements without multiplication by element size [-Wmemset-elt-size]
     memset(cmp_array, 0, CMP_ARRAY_SIZE);
     ^~~~~~

CMP_ARRAY_SIZE (256) is the number of elements in that array, but the
elements are not char but enum, which is 4 bytes on e.g. x86-64.
This results in 3/4 of the array not being correctly initialized.

Idiomatic C is to pass sizeof cmp_array to memset(), so that's what I did.
---
 lib/erl_interface/src/legacy/erl_marshal.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/erl_interface/src/legacy/erl_marshal.c b/lib/erl_interface/src/legacy/erl_marshal.c
index caa171858d..6435754823 100644
--- a/lib/erl_interface/src/legacy/erl_marshal.c
+++ b/lib/erl_interface/src/legacy/erl_marshal.c
@@ -107,7 +107,7 @@ static int init_cmp_num_class_p=1; /* initialize array, the first time */
 void erl_init_marshal(void)
 {
   if (init_cmp_array_p) {
-    memset(cmp_array, 0, CMP_ARRAY_SIZE);
+    memset(cmp_array, 0, sizeof cmp_array);
     cmp_array[ERL_SMALL_INTEGER_EXT] = ERL_NUM_CMP;
     cmp_array[ERL_INTEGER_EXT]       = ERL_NUM_CMP;
     cmp_array[ERL_FLOAT_EXT]         = ERL_NUM_CMP;
-- 
2.16.3