Accepting request 497394 from home:bfrogers:branches:Virtualization

Fixes for gcc7 compatibility.

OBS-URL: https://build.opensuse.org/request/show/497394
OBS-URL: https://build.opensuse.org/package/show/Virtualization/qemu?expand=0&rev=341
This commit is contained in:
Bruce Rogers 2017-05-23 00:39:19 +00:00 committed by Git OBS Bridge
parent 19556f7295
commit 3a5eecf011
10 changed files with 373 additions and 0 deletions

View File

@ -0,0 +1,41 @@
From 5369a4b1932f7c298ae360789fd182c24e14c569 Mon Sep 17 00:00:00 2001
From: Paolo Bonzini <pbonzini@redhat.com>
Date: Wed, 3 May 2017 12:44:41 +0200
Subject: [PATCH] jazz_led: fix bad snprintf
Detected by GCC 7's -Wformat-truncation. snprintf writes at most
2 bytes here including the terminating NUL, so the result is
truncated. In addition, the newline at the end is pointless.
Fix the buffer size and the format string.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
(cherry picked from commit e9c6ab62c760e333a6cf0f3f9ab021633723434c)
[LY: BSC#1040228]
Signed-off-by: Liang Yan <lyan@suse.com>
---
hw/display/jazz_led.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/display/jazz_led.c b/hw/display/jazz_led.c
index b72fdb1717..3c97d56434 100644
--- a/hw/display/jazz_led.c
+++ b/hw/display/jazz_led.c
@@ -227,13 +227,13 @@ static void jazz_led_invalidate_display(void *opaque)
static void jazz_led_text_update(void *opaque, console_ch_t *chardata)
{
LedState *s = opaque;
- char buf[2];
+ char buf[3];
dpy_text_cursor(s->con, -1, -1);
qemu_console_resize(s->con, 2, 1);
/* TODO: draw the segments */
- snprintf(buf, 2, "%02hhx\n", s->segments);
+ snprintf(buf, 3, "%02hhx", s->segments);
console_write_ch(chardata++, ATTR2CHTYPE(buf[0], QEMU_COLOR_BLUE,
QEMU_COLOR_BLACK, 1));
console_write_ch(chardata++, ATTR2CHTYPE(buf[1], QEMU_COLOR_BLUE,

View File

@ -0,0 +1,117 @@
From 94cc81bb7e1655b2b8ce0f1c996877ffb156bfb2 Mon Sep 17 00:00:00 2001
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Date: Fri, 7 Apr 2017 15:32:54 +0100
Subject: [PATCH] slirp/smb: Replace constant strings by glib string
gcc 7 (on fedora 26) objects to many of the snprintf's
in the smb path and command creation because it can't
figure out that the smb_dir (i.e. the /tmp dir for the configuration)
is known to be short.
Replace all these fixed length buffers by g_str* functions that dynamically
allocate and use g_dir_make_tmp to make the directory.
(It's fairly new glib but we have a compat function for it).
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
(cherry picked from commit f95cc8b6cc3ad8c4b687f305a978d67091c28138)
[LY: BSC#1040228]
Signed-off-by: Liang Yan <lyan@suse.com>
---
net/slirp.c | 30 +++++++++++++++++-------------
1 file changed, 17 insertions(+), 13 deletions(-)
diff --git a/net/slirp.c b/net/slirp.c
index f97ec23345..9f6521190b 100644
--- a/net/slirp.c
+++ b/net/slirp.c
@@ -80,7 +80,7 @@ typedef struct SlirpState {
Slirp *slirp;
Notifier exit_notifier;
#ifndef _WIN32
- char smb_dir[128];
+ gchar *smb_dir;
#endif
} SlirpState;
@@ -558,11 +558,10 @@ int net_slirp_redir(const char *redir_str)
/* automatic user mode samba server configuration */
static void slirp_smb_cleanup(SlirpState *s)
{
- char cmd[128];
int ret;
- if (s->smb_dir[0] != '\0') {
- snprintf(cmd, sizeof(cmd), "rm -rf %s", s->smb_dir);
+ if (s->smb_dir) {
+ gchar *cmd = g_strdup_printf("rm -rf %s", s->smb_dir);
ret = system(cmd);
if (ret == -1 || !WIFEXITED(ret)) {
error_report("'%s' failed.", cmd);
@@ -570,15 +569,17 @@ static void slirp_smb_cleanup(SlirpState *s)
error_report("'%s' failed. Error code: %d",
cmd, WEXITSTATUS(ret));
}
- s->smb_dir[0] = '\0';
+ g_free(cmd);
+ g_free(s->smb_dir);
+ s->smb_dir = NULL;
}
}
static int slirp_smb(SlirpState* s, const char *exported_dir,
struct in_addr vserver_addr)
{
- char smb_conf[128];
- char smb_cmdline[128];
+ char *smb_conf;
+ char *smb_cmdline;
struct passwd *passwd;
FILE *f;
@@ -600,19 +601,19 @@ static int slirp_smb(SlirpState* s, const char *exported_dir,
return -1;
}
- snprintf(s->smb_dir, sizeof(s->smb_dir), "/tmp/qemu-smb.XXXXXX");
- if (!mkdtemp(s->smb_dir)) {
- error_report("could not create samba server dir '%s'", s->smb_dir);
- s->smb_dir[0] = 0;
+ s->smb_dir = g_dir_make_tmp("qemu-smb.XXXXXX", NULL);
+ if (!s->smb_dir) {
+ error_report("could not create samba server dir");
return -1;
}
- snprintf(smb_conf, sizeof(smb_conf), "%s/%s", s->smb_dir, "smb.conf");
+ smb_conf = g_strdup_printf("%s/%s", s->smb_dir, "smb.conf");
f = fopen(smb_conf, "w");
if (!f) {
slirp_smb_cleanup(s);
error_report("could not create samba server configuration file '%s'",
smb_conf);
+ g_free(smb_conf);
return -1;
}
fprintf(f,
@@ -651,15 +652,18 @@ static int slirp_smb(SlirpState* s, const char *exported_dir,
);
fclose(f);
- snprintf(smb_cmdline, sizeof(smb_cmdline), "%s -l %s -s %s",
+ smb_cmdline = g_strdup_printf("%s -l %s -s %s",
CONFIG_SMBD_COMMAND, s->smb_dir, smb_conf);
+ g_free(smb_conf);
if (slirp_add_exec(s->slirp, 0, smb_cmdline, &vserver_addr, 139) < 0 ||
slirp_add_exec(s->slirp, 0, smb_cmdline, &vserver_addr, 445) < 0) {
slirp_smb_cleanup(s);
+ g_free(smb_cmdline);
error_report("conflicting/invalid smbserver address");
return -1;
}
+ g_free(smb_cmdline);
return 0;
}

View File

@ -0,0 +1,28 @@
From 355047e16c0834b88d7df8ef86efef8b0d3b6adc Mon Sep 17 00:00:00 2001
From: Paolo Bonzini <pbonzini@redhat.com>
Date: Mon, 22 May 2017 17:46:40 -0600
Subject: [PATCH] altera_timer: fix incorrect memset
Use sizeof instead of ARRAY_SIZE, fixing -Wmemset-elt-size with recent
GCC versions.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
[LY: BSC#1040228]
Signed-off-by: Liang Yan <lyan@suse.com>
---
hw/timer/altera_timer.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/timer/altera_timer.c b/hw/timer/altera_timer.c
index 6d4862661d..c9a0fc5dca 100644
--- a/hw/timer/altera_timer.c
+++ b/hw/timer/altera_timer.c
@@ -204,7 +204,7 @@ static void altera_timer_reset(DeviceState *dev)
ptimer_stop(t->ptimer);
ptimer_set_limit(t->ptimer, 0xffffffff, 1);
- memset(t->regs, 0, ARRAY_SIZE(t->regs));
+ memset(t->regs, 0, sizeof(t->regs));
}
static Property altera_timer_properties[] = {

View File

@ -0,0 +1,133 @@
From 694037b618e2d331c38c287857da993fdab1f011 Mon Sep 17 00:00:00 2001
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Date: Mon, 22 May 2017 17:48:13 -0600
Subject: [PATCH] Hacks for building on gcc 7 / Fedora 26
Hi,
Fedora 26 has gcc 7.0.1 which has the normal compliment
of new fussy warnings; so far I've posted :
tests/check-qdict: Fix missing brackets
slirp/smb: Replace constant strings by glib string
that fix one actual mistake and work around something it's being
fussy over.
But I've also got a pile of hacks, attached below that I'm
not too sure what I'll do with them yet, but they're attached
for anyone else trying to build. Note they're smoke-only-tested.
I also have gcc bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80346
filed for what I reckon is a couple of overly pessimistic warnings.
Enjoy,
Dave
From 15353ce59e35e1d85927138982241491ea65cee2 Mon Sep 17 00:00:00 2001
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Date: Thu, 6 Apr 2017 15:44:50 +0100
Subject: [HACK!] Hacks for f26 build
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
[LY: BSC#1040228]
Signed-off-by: Liang Yan <lyan@suse.com>
---
block/blkdebug.c | 4 ++--
block/blkverify.c | 4 ++--
hw/usb/bus.c | 5 +++--
include/qemu/iov.h | 4 ++--
tests/bios-tables-test.c | 2 +-
5 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/block/blkdebug.c b/block/blkdebug.c
index 67e8024e36..34c645d095 100644
--- a/block/blkdebug.c
+++ b/block/blkdebug.c
@@ -689,9 +689,9 @@ static void blkdebug_refresh_filename(BlockDriverState *bs, QDict *options)
}
if (!force_json && bs->file->bs->exact_filename[0]) {
- snprintf(bs->exact_filename, sizeof(bs->exact_filename),
+ g_assert_cmpint(snprintf(bs->exact_filename, sizeof(bs->exact_filename),
"blkdebug:%s:%s", s->config_file ?: "",
- bs->file->bs->exact_filename);
+ bs->file->bs->exact_filename), <, sizeof(bs->exact_filename));
}
opts = qdict_new();
diff --git a/block/blkverify.c b/block/blkverify.c
index 9a1e21c6ad..d038947a5a 100644
--- a/block/blkverify.c
+++ b/block/blkverify.c
@@ -305,10 +305,10 @@ static void blkverify_refresh_filename(BlockDriverState *bs, QDict *options)
if (bs->file->bs->exact_filename[0]
&& s->test_file->bs->exact_filename[0])
{
- snprintf(bs->exact_filename, sizeof(bs->exact_filename),
+ g_assert_cmpint(snprintf(bs->exact_filename, sizeof(bs->exact_filename),
"blkverify:%s:%s",
bs->file->bs->exact_filename,
- s->test_file->bs->exact_filename);
+ s->test_file->bs->exact_filename), <, sizeof(bs->exact_filename));
}
}
diff --git a/hw/usb/bus.c b/hw/usb/bus.c
index 24f1608b4b..6023f3b419 100644
--- a/hw/usb/bus.c
+++ b/hw/usb/bus.c
@@ -8,6 +8,7 @@
#include "monitor/monitor.h"
#include "trace.h"
#include "qemu/cutils.h"
+#include <glib.h>
static void usb_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent);
@@ -407,8 +408,8 @@ void usb_register_companion(const char *masterbus, USBPort *ports[],
void usb_port_location(USBPort *downstream, USBPort *upstream, int portnr)
{
if (upstream) {
- snprintf(downstream->path, sizeof(downstream->path), "%s.%d",
- upstream->path, portnr);
+ g_assert_cmpint(snprintf(downstream->path, sizeof(downstream->path), "%s.%d",
+ upstream->path, portnr), <, sizeof(downstream->path));
downstream->hubcount = upstream->hubcount + 1;
} else {
snprintf(downstream->path, sizeof(downstream->path), "%d", portnr);
diff --git a/include/qemu/iov.h b/include/qemu/iov.h
index bd9fd55b0a..ebb0221140 100644
--- a/include/qemu/iov.h
+++ b/include/qemu/iov.h
@@ -46,7 +46,7 @@ static inline size_t
iov_from_buf(const struct iovec *iov, unsigned int iov_cnt,
size_t offset, const void *buf, size_t bytes)
{
- if (__builtin_constant_p(bytes) && iov_cnt &&
+ if (__builtin_constant_p(bytes) && iov_cnt && bytes <= INT_MAX &&
offset <= iov[0].iov_len && bytes <= iov[0].iov_len - offset) {
memcpy(iov[0].iov_base + offset, buf, bytes);
return bytes;
@@ -59,7 +59,7 @@ static inline size_t
iov_to_buf(const struct iovec *iov, const unsigned int iov_cnt,
size_t offset, void *buf, size_t bytes)
{
- if (__builtin_constant_p(bytes) && iov_cnt &&
+ if (__builtin_constant_p(bytes) && iov_cnt && bytes <= INT_MAX &&
offset <= iov[0].iov_len && bytes <= iov[0].iov_len - offset) {
memcpy(buf, iov[0].iov_base + offset, bytes);
return bytes;
diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index 88dbf97853..c55de4f65b 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -98,7 +98,7 @@ static void test_acpi_rsdt_table(test_data *data)
AcpiRsdtDescriptorRev1 *rsdt_table = &data->rsdt_table;
uint32_t addr = data->rsdp_table.rsdt_physical_address;
uint32_t *tables;
- int tables_nr;
+ unsigned int tables_nr;
uint8_t checksum;
/* read the header */

View File

@ -1,3 +1,13 @@
-------------------------------------------------------------------
Mon May 22 23:52:15 UTC 2017 - brogers@suse.com
- Patch queue updated from git://github.com/openSUSE/qemu.git opensuse-2.9
* Patches added:
0056-jazz_led-fix-bad-snprintf.patch
0057-slirp-smb-Replace-constant-strings-.patch
0058-altera_timer-fix-incorrect-memset.patch
0059-Hacks-for-building-on-gcc-7-Fedora-.patch
-------------------------------------------------------------------
Mon May 22 19:06:25 UTC 2017 - brogers@suse.com

View File

@ -81,6 +81,10 @@ Patch0052: 0052-audio-release-capture-buffers.patch
Patch0053: 0053-scsi-avoid-an-off-by-one-error-in-m.patch
Patch0054: 0054-vmw_pvscsi-check-message-ring-page-.patch
Patch0055: 0055-9pfs-local-forbid-client-access-to-.patch
Patch0056: 0056-jazz_led-fix-bad-snprintf.patch
Patch0057: 0057-slirp-smb-Replace-constant-strings-.patch
Patch0058: 0058-altera_timer-fix-incorrect-memset.patch
Patch0059: 0059-Hacks-for-building-on-gcc-7-Fedora-.patch
# Please do not add QEMU patches manually here.
# Run update_git.sh to regenerate this queue.
Source400: update_git.sh
@ -189,6 +193,10 @@ run cross-architecture builds.
%patch0053 -p1
%patch0054 -p1
%patch0055 -p1
%patch0056 -p1
%patch0057 -p1
%patch0058 -p1
%patch0059 -p1
%build
./configure \

View File

@ -1,3 +1,13 @@
-------------------------------------------------------------------
Mon May 22 23:52:12 UTC 2017 - brogers@suse.com
- Fixes for gcc7 compatability (bsc#1040228) (in behalf of Liang Yan)
0056-jazz_led-fix-bad-snprintf.patch
0057-slirp-smb-Replace-constant-strings-.patch
0058-altera_timer-fix-incorrect-memset.patch
0059-Hacks-for-building-on-gcc-7-Fedora-.patch
- Patch queue updated from git://github.com/openSUSE/qemu.git opensuse-2.9
-------------------------------------------------------------------
Mon May 22 19:06:22 UTC 2017 - brogers@suse.com

View File

@ -185,6 +185,10 @@ Patch0052: 0052-audio-release-capture-buffers.patch
Patch0053: 0053-scsi-avoid-an-off-by-one-error-in-m.patch
Patch0054: 0054-vmw_pvscsi-check-message-ring-page-.patch
Patch0055: 0055-9pfs-local-forbid-client-access-to-.patch
Patch0056: 0056-jazz_led-fix-bad-snprintf.patch
Patch0057: 0057-slirp-smb-Replace-constant-strings-.patch
Patch0058: 0058-altera_timer-fix-incorrect-memset.patch
Patch0059: 0059-Hacks-for-building-on-gcc-7-Fedora-.patch
# Please do not add QEMU patches manually here.
# Run update_git.sh to regenerate this queue.
@ -886,6 +890,10 @@ This package provides a service file for starting and stopping KSM.
%patch0053 -p1
%patch0054 -p1
%patch0055 -p1
%patch0056 -p1
%patch0057 -p1
%patch0058 -p1
%patch0059 -p1
pushd roms/ipxe
%patch1100 -p1

View File

@ -1,3 +1,13 @@
-------------------------------------------------------------------
Mon May 22 23:52:12 UTC 2017 - brogers@suse.com
- Fixes for gcc7 compatability (bsc#1040228) (in behalf of Liang Yan)
0056-jazz_led-fix-bad-snprintf.patch
0057-slirp-smb-Replace-constant-strings-.patch
0058-altera_timer-fix-incorrect-memset.patch
0059-Hacks-for-building-on-gcc-7-Fedora-.patch
- Patch queue updated from git://github.com/openSUSE/qemu.git opensuse-2.9
-------------------------------------------------------------------
Mon May 22 19:06:22 UTC 2017 - brogers@suse.com

View File

@ -185,6 +185,10 @@ Patch0052: 0052-audio-release-capture-buffers.patch
Patch0053: 0053-scsi-avoid-an-off-by-one-error-in-m.patch
Patch0054: 0054-vmw_pvscsi-check-message-ring-page-.patch
Patch0055: 0055-9pfs-local-forbid-client-access-to-.patch
Patch0056: 0056-jazz_led-fix-bad-snprintf.patch
Patch0057: 0057-slirp-smb-Replace-constant-strings-.patch
Patch0058: 0058-altera_timer-fix-incorrect-memset.patch
Patch0059: 0059-Hacks-for-building-on-gcc-7-Fedora-.patch
# Please do not add QEMU patches manually here.
# Run update_git.sh to regenerate this queue.
@ -886,6 +890,10 @@ This package provides a service file for starting and stopping KSM.
%patch0053 -p1
%patch0054 -p1
%patch0055 -p1
%patch0056 -p1
%patch0057 -p1
%patch0058 -p1
%patch0059 -p1
pushd roms/ipxe
%patch1100 -p1