From 378ffb7cca7fca1cb64ff3a2e50496c18011dd07 Mon Sep 17 00:00:00 2001
From: Michal Schmidt <mschmidt@redhat.com>
Date: Wed, 12 Aug 2015 14:25:53 +0200
Subject: [PATCH] avoid calling memset with zero length
This avoids the following build error:
In file included from /usr/include/string.h:638:0,
from ./include/opa_user.h:77,
from psm_user.h:67,
from psm_diags.c:56:
In function 'memset',
inlined from 'memcpy_check_one.constprop.4' at psm_diags.c:278:8,
inlined from 'memcpy_check_size.constprop.2' at psm_diags.c:335:30,
inlined from 'psmi_test_memcpy.constprop.1' at psm_diags.c:230:6,
inlined from 'psmi_diags' at psm_diags.c:84:25:
/usr/include/bits/string3.h:81:30: error: call to
'__warn_memset_zero_len' declared with attribute warning: memset used
with constant zero length parameter; this could be due to transposed
parameters [-Werror]
__warn_memset_zero_len ();
^
---
psm_diags.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/psm_diags.c b/psm_diags.c
index 286e72bd8a..152968750c 100644
--- a/psm_diags.c
+++ b/psm_diags.c
@@ -275,6 +275,10 @@ void *memcpy_check_one(memcpy_fn_t fn, void *dst, void *src, size_t n)
((uintptr_t) dst ^ (uintptr_t) src ^ (uintptr_t) n);
unsigned int state;
size_t i;
+
+ if (!n)
+ return dst;
+
memset(src, 0x55, n);
memset(dst, 0xaa, n);
srand(seed);
--
2.4.3