* Daniel P. Berrange (berra...@redhat.com) wrote: > On Fri, Apr 07, 2017 at 03:38:47PM +0100, Dr. David Alan Gilbert wrote: > > 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. > > > > 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;
tbh I don't know what the right fix for this is; the gcc discussion confused me as to why it thinks it can be a valid case. > > 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 */ > Unless I've missed a patch somwhere, I think the problems that these two > chunks are fixing are still needed for current git master, to stop warnings > in the unit tests. > The second one of those I can post a patch for; the trick is to change the g_assert_cmpint to a g_assert and then gcc realises the bad case can't happen. I'll post that in a few mins. Dave > > Regards, > Daniel > -- > |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| > |: https://libvirt.org -o- https://fstop138.berrange.com :| > |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :| -- Dr. David Alan Gilbert / dgilb...@redhat.com / Manchester, UK