diff mbox series

hw/xive.c: Fix memcmp() in DEBUG build to compare struct not ptr

Message ID 20190520235106.10081-1-stewart@linux.ibm.com
State Accepted
Headers show
Series hw/xive.c: Fix memcmp() in DEBUG build to compare struct not ptr | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success Successfully applied on branch master (68284c21173978e384f605954423a088b61c7540)
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot success Test snowpatch/job/snowpatch-skiboot on branch master
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot-dco success Signed-off-by present

Commit Message

Stewart Smith May 20, 2019, 11:51 p.m. UTC
With GCC9:

hw/xive.c: In function ‘xive_check_eq_update’:
hw/xive.c:3034:29: error: argument to ‘sizeof’ in ‘__builtin_memcmp’ call is the same expression as the first source; did you mean to dereference it? [-Werror=sizeof-pointer-memaccess]
  if (memcmp(eq, &eq2, sizeof(eq)) != 0) {
                             ^
hw/xive.c: In function ‘xive_check_vpc_update’:
hw/xive.c:3056:29: error: argument to ‘sizeof’ in ‘__builtin_memcmp’ call is the same expression as the first source; did you mean to dereference it? [-Werror=sizeof-pointer-memaccess]
  if (memcmp(vp, &vp2, sizeof(vp)) != 0) {
                             ^
cc1: all warnings being treated as errors

Fixes: 2eea386767728
Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
---
 hw/xive.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Stewart Smith May 21, 2019, 3:19 a.m. UTC | #1
Stewart Smith <stewart@linux.ibm.com> writes:
> With GCC9:
>
> hw/xive.c: In function ‘xive_check_eq_update’:
> hw/xive.c:3034:29: error: argument to ‘sizeof’ in ‘__builtin_memcmp’ call is the same expression as the first source; did you mean to dereference it? [-Werror=sizeof-pointer-memaccess]
>   if (memcmp(eq, &eq2, sizeof(eq)) != 0) {
>                              ^
> hw/xive.c: In function ‘xive_check_vpc_update’:
> hw/xive.c:3056:29: error: argument to ‘sizeof’ in ‘__builtin_memcmp’ call is the same expression as the first source; did you mean to dereference it? [-Werror=sizeof-pointer-memaccess]
>   if (memcmp(vp, &vp2, sizeof(vp)) != 0) {
>                              ^
> cc1: all warnings being treated as errors
>
> Fixes: 2eea386767728
> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>

Merged as of 59bdc3a2d199a0d2599732e9ff05f4efb4213c10
diff mbox series

Patch

diff --git a/hw/xive.c b/hw/xive.c
index 5edcaedf5875..a9f1e7707ac9 100644
--- a/hw/xive.c
+++ b/hw/xive.c
@@ -3027,7 +3027,7 @@  static bool xive_check_eq_update(struct xive *x, uint32_t idx, struct xive_eq *e
 
 	assert(eq_p);
 	eq2 = *eq_p;
-	if (memcmp(eq, &eq2, sizeof(eq)) != 0) {
+	if (memcmp(eq, &eq2, sizeof(struct xive_eq)) != 0) {
 		xive_err(x, "EQ update mismatch idx %d\n", idx);
 		xive_err(x, "want: %08x %08x %08x %08x\n",
 			 eq->w0, eq->w1, eq->w2, eq->w3);
@@ -3049,7 +3049,7 @@  static bool xive_check_vpc_update(struct xive *x, uint32_t idx, struct xive_vp *
 
 	assert(vp_p);
 	vp2 = *vp_p;
-	if (memcmp(vp, &vp2, sizeof(vp)) != 0) {
+	if (memcmp(vp, &vp2, sizeof(struct xive_vp)) != 0) {
 		xive_err(x, "VP update mismatch idx %d\n", idx);
 		xive_err(x, "want: %08x %08x %08x %08x\n",
 			 vp->w0, vp->w1, vp->w2, vp->w3);