Skip to contentSkip to conversation

Fix tests with new gcc

GIT PULL Applied Juan Quintela 2 participants 4 messages Sep 6, 2017 – Sep 7, 2017

lore
Share & tools
lore
#0 lore raw

Hi

TNhis has already been reviewed on list.

Please, apply.

The following changes since commit b07d1c2f5607489d4d4a6a65ce36a3e896ac065e:

Revert "kvm: use DIV_ROUND_UP" (2017-09-05 18:55:40 +0100)

are available in the git repository at:

git://github.com/juanquintela/qemu.git tags/tests/20170906

for you to fetch changes up to c18aaeb69072b74cb0a66e6638fcb14837c7cd3a:

tests: Make vmgenid test compile (2017-09-05 22:34:40 +0200)

----------------------------------------------------------------
tests/next for 20170906

----------------------------------------------------------------
Juan Quintela (2):
tests: Use real size for iov tests
tests: Make vmgenid test compile

 include/qemu/iov.h   |  6 ------
 tests/test-iov.c     | 10 +++++-----
 tests/vmgenid-test.c |  4 ++--
 3 files changed, 7 insertions(+), 13 deletions(-)
#1 lore raw

[Qemu-devel] [PULL 1/2] tests: Use real size for iov tests

We were using -1 instead of the real size because the functions check what is bigger, size in bytes or the size of the iov. Recent gcc's barf at this.

--

Remove comments about this feature.
Fix missing -1.

---
 include/qemu/iov.h |  6 ------
 tests/test-iov.c   | 10 +++++-----
 2 files changed, 5 insertions(+), 11 deletions(-)
include/qemu/iov.h +0 -6
index bd9fd55b0a..72d4c559b4 100644
@@ -31,11 +31,6 @@ size_t iov_size(const struct iovec *iov, const unsigned int iov_cnt);
  * Number of bytes actually copied will be returned, which is
  *  min(bytes, iov_size(iov)-offset)
  * `Offset' must point to the inside of iovec.
- * It is okay to use very large value for `bytes' since we're
- * limited by the size of the iovec anyway, provided that the
- * buffer pointed to by buf has enough space.  One possible
- * such "large" value is -1 (sinice size_t is unsigned),
- * so specifying `-1' as `bytes' means 'up to the end of iovec'.
  */
 size_t iov_from_buf_full(const struct iovec *iov, unsigned int iov_cnt,
                          size_t offset, const void *buf, size_t bytes);
@@ -76,7 +71,6 @@ iov_to_buf(const struct iovec *iov, const unsigned int iov_cnt,
  * up to the end of it, will be filled with the specified value.
  * Function return actual number of bytes processed, which is
  * min(size, iov_size(iov) - offset).
- * Again, it is okay to use large value for `bytes' to mean "up to the end".
  */
 size_t iov_memset(const struct iovec *iov, const unsigned int iov_cnt,
                   size_t offset, int fillc, size_t bytes);
tests/test-iov.c +5 -5
index fa3d75aee1..458ca25099 100644
@@ -81,17 +81,17 @@ static void test_to_from_buf_1(void)
           * skip whole vector and process exactly 0 bytes */
 
          /* first set bytes [i..sz) to some "random" value */
-         n = iov_memset(iov, niov, 0, 0xff, -1);
+         n = iov_memset(iov, niov, 0, 0xff, sz);
          g_assert(n == sz);
 
          /* next copy bytes [i..sz) from ibuf to iovec */
-         n = iov_from_buf(iov, niov, i, ibuf + i, -1);
+         n = iov_from_buf(iov, niov, i, ibuf + i, sz - i);
          g_assert(n == sz - i);
 
          /* clear part of obuf */
          memset(obuf + i, 0, sz - i);
          /* and set this part of obuf to values from iovec */
-         n = iov_to_buf(iov, niov, i, obuf + i, -1);
+         n = iov_to_buf(iov, niov, i, obuf + i, sz - i);
          g_assert(n == sz - i);
 
          /* now compare resulting buffers */
@@ -109,7 +109,7 @@ static void test_to_from_buf_1(void)
               * with j in [i..sz]. */
 
              /* clear iovec */
-             n = iov_memset(iov, niov, 0, 0xff, -1);
+             n = iov_memset(iov, niov, 0, 0xff, sz);
              g_assert(n == sz);
 
              /* copy bytes [i..j) from ibuf to iovec */
@@ -225,7 +225,7 @@ static void test_io(void)
        for (i = 0; i <= sz; ++i) {
            for (j = i; j <= sz; ++j) {
                k = i;
-               iov_memset(iov, niov, 0, 0xff, -1);
+               iov_memset(iov, niov, 0, 0xff, sz);
                do {
                    s = g_test_rand_int_range(0, j - k + 1);
                    r = iov_recv(sv[0], iov, niov, k, s);
Signature · 1 line
2.13.5
#2 lore raw

[Qemu-devel] [PULL 2/2] tests: Make vmgenid test compile

In reply to Juan Quintela

Just make sure that nr_tables is size_t not int.
Once there, do the assert in the right place and be sure that we don't have a division by zero.

--

Drop the s/g_new0/g_malloc0/ change.
Avoid division by zero with assert (danp)

---
 tests/vmgenid-test.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tests/vmgenid-test.c +2 -2
index 3d5c1c3615..918c82c82a 100644
@@ -40,7 +40,7 @@ static uint32_t acpi_find_vgia(void)
     AcpiRsdpDescriptor rsdp_table;
     uint32_t rsdt;
     AcpiRsdtDescriptorRev1 rsdt_table;
-    int tables_nr;
+    size_t tables_nr;
     uint32_t *tables;
     AcpiTableHeader ssdt_table;
     VgidTable vgid_table;
@@ -62,9 +62,9 @@ static uint32_t acpi_find_vgia(void)
     ACPI_ASSERT_CMP(rsdt_table.signature, "RSDT");
 
     /* compute the table entries in rsdt */
+    g_assert_cmpint(rsdt_table.length, >, sizeof(AcpiRsdtDescriptorRev1));
     tables_nr = (rsdt_table.length - sizeof(AcpiRsdtDescriptorRev1)) /
                 sizeof(uint32_t);
-    g_assert_cmpint(tables_nr, >, 0);
 
     /* get the addresses of the tables pointed by rsdt */
     tables = g_new0(uint32_t, tables_nr);
Signature · 1 line
2.13.5
#3 lore raw
In reply to Juan Quintela
Quoted 18 lines · Juan Quintela

Hi

TNhis has already been reviewed on list.

Please, apply.

The following changes since commit b07d1c2f5607489d4d4a6a65ce36a3e896ac065e:

Revert "kvm: use DIV_ROUND_UP" (2017-09-05 18:55:40 +0100)

are available in the git repository at:

git://github.com/juanquintela/qemu.git tags/tests/20170906

for you to fetch changes up to c18aaeb69072b74cb0a66e6638fcb14837c7cd3a:

tests: Make vmgenid test compile (2017-09-05 22:34:40 +0200)

Quoted 7 lines

----------------------------------------------------------------
tests/next for 20170906

----------------------------------------------------------------
Juan Quintela (2):
tests: Use real size for iov tests
tests: Make vmgenid test compile

Applied, thanks.

-- PMM