Blame SOURCES/0013-Fix-gcc-11-compiler-warning-on-kvmdump.c.patch

56ae9b
From 75739a08e952b6bd7434f4625a8fbe921361cbe8 Mon Sep 17 00:00:00 2001
56ae9b
From: Kazuhito Hagio <k-hagio-ab@nec.com>
56ae9b
Date: Fri, 22 Jul 2022 13:44:50 +0900
56ae9b
Subject: [PATCH 13/28] Fix gcc-11 compiler warning on kvmdump.c
56ae9b
56ae9b
Without the patch, the following gcc-11 compiler warning is emitted for
56ae9b
kvmdump.c:
56ae9b
56ae9b
In function 'write_mapfile_registers',
56ae9b
    inlined from 'write_mapfile_trailer' at kvmdump.c:947:3,
56ae9b
    inlined from 'kvmdump_init' at kvmdump.c:145:4:
56ae9b
kvmdump.c:972:13: warning: 'write' reading 8 bytes from a region of size 4 [-Wstringop-overread]
56ae9b
  972 |         if (write(kvm->mapfd, &kvm->cpu_devices, sizeof(uint64_t)) != sizeof(uint64_t))
56ae9b
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
56ae9b
In file included from kvmdump.c:19:
56ae9b
kvmdump.c: In function 'kvmdump_init':
56ae9b
kvmdump.h:67:18: note: source object 'cpu_devices' of size 4
56ae9b
   67 |         uint32_t cpu_devices;
56ae9b
      |                  ^~~~~~~~~~~
56ae9b
In file included from defs.h:26,
56ae9b
                 from kvmdump.c:18:
56ae9b
/usr/include/unistd.h:378:16: note: in a call to function 'write' declared with attribute 'access (read_only, 2, 3)'
56ae9b
  378 | extern ssize_t write (int __fd, const void *__buf, size_t __n) __wur
56ae9b
      |                ^~~~~
56ae9b
56ae9b
Signed-off-by: Kazuhito Hagio <k-hagio-ab@nec.com>
56ae9b
Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
56ae9b
---
56ae9b
 kvmdump.c | 2 +-
56ae9b
 kvmdump.h | 2 +-
56ae9b
 2 files changed, 2 insertions(+), 2 deletions(-)
56ae9b
56ae9b
diff --git a/kvmdump.c b/kvmdump.c
56ae9b
index 4db96bd844e9..e515bf0ce9a1 100644
56ae9b
--- a/kvmdump.c
56ae9b
+++ b/kvmdump.c
56ae9b
@@ -297,7 +297,7 @@ kvmdump_memory_dump(FILE *ofp)
56ae9b
 				(ulonglong)kvm->page_cache[i].paddr);
56ae9b
 	}
56ae9b
 
56ae9b
-	fprintf(ofp, "      cpu_devices: %d\n", kvm->cpu_devices);
56ae9b
+	fprintf(ofp, "      cpu_devices: %ld\n", kvm->cpu_devices);
56ae9b
 	fprintf(ofp, "           iohole: %llx (%llx - %llx)\n", 
56ae9b
 		(ulonglong)kvm->iohole, 0x100000000ULL - kvm->iohole,
56ae9b
 		0x100000000ULL);
56ae9b
diff --git a/kvmdump.h b/kvmdump.h
56ae9b
index 07e047bb171c..2e408aebef0b 100644
56ae9b
--- a/kvmdump.h
56ae9b
+++ b/kvmdump.h
56ae9b
@@ -64,7 +64,7 @@ struct kvmdump_data {
56ae9b
 	ulong compresses;
56ae9b
 	uint64_t kvbase;
56ae9b
 	ulong *debug;
56ae9b
-	uint32_t cpu_devices;
56ae9b
+	uint64_t cpu_devices;
56ae9b
 	struct register_set *registers;
56ae9b
 	uint64_t iohole;
56ae9b
 };
56ae9b
-- 
56ae9b
2.37.1
56ae9b