Fix gcc-11 compiler warning on kvmdump.c

Without the patch, the following gcc-11 compiler warning is emitted for
kvmdump.c:

In function 'write_mapfile_registers',
    inlined from 'write_mapfile_trailer' at kvmdump.c:947:3,
    inlined from 'kvmdump_init' at kvmdump.c:145:4:
kvmdump.c:972:13: warning: 'write' reading 8 bytes from a region of size 4 [-Wstringop-overread]
  972 |         if (write(kvm->mapfd, &kvm->cpu_devices, sizeof(uint64_t)) != sizeof(uint64_t))
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from kvmdump.c:19:
kvmdump.c: In function 'kvmdump_init':
kvmdump.h:67:18: note: source object 'cpu_devices' of size 4
   67 |         uint32_t cpu_devices;
      |                  ^~~~~~~~~~~
In file included from defs.h:26,
                 from kvmdump.c:18:
/usr/include/unistd.h:378:16: note: in a call to function 'write' declared with attribute 'access (read_only, 2, 3)'
  378 | extern ssize_t write (int __fd, const void *__buf, size_t __n) __wur
      |                ^~~~~

Signed-off-by: Kazuhito Hagio <k-hagio-ab@nec.com>
This commit is contained in:
Kazuhito Hagio 2022-07-22 13:44:50 +09:00
parent 7591e3c07c
commit f37df7df8a
2 changed files with 2 additions and 2 deletions

View File

@ -297,7 +297,7 @@ kvmdump_memory_dump(FILE *ofp)
(ulonglong)kvm->page_cache[i].paddr);
}
fprintf(ofp, " cpu_devices: %d\n", kvm->cpu_devices);
fprintf(ofp, " cpu_devices: %ld\n", kvm->cpu_devices);
fprintf(ofp, " iohole: %llx (%llx - %llx)\n",
(ulonglong)kvm->iohole, 0x100000000ULL - kvm->iohole,
0x100000000ULL);

View File

@ -64,7 +64,7 @@ struct kvmdump_data {
ulong compresses;
uint64_t kvbase;
ulong *debug;
uint32_t cpu_devices;
uint64_t cpu_devices;
struct register_set *registers;
uint64_t iohole;
};