[Spice-devel] [cacard v3] tests: Fix 'simpletlv' on i686 arches

Christophe Fergeau cfergeau at redhat.com
Tue Aug 14 13:01:36 UTC 2018


The simpletlv_* functions return lengths as an int, but the test is
casting it to a size_t before comparing it against -1. This is not
giving the expected result on i686, causing the test to fail. The
variables used in the test do not need to be size_t, and can be changed
to int to match the return value and avoid the failure.

Signed-off-by: Christophe Fergeau <cfergeau at redhat.com>
---
 tests/simpletlv.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/simpletlv.c b/tests/simpletlv.c
index cd0cd69..9ddc5b9 100644
--- a/tests/simpletlv.c
+++ b/tests/simpletlv.c
@@ -48,7 +48,7 @@ static void test_length_simple(void)
 
 static void test_length_nested(void)
 {
-    size_t length = 0;
+    int length = 0;
     unsigned char simple_value[] = "\x12\x14";
     static struct simpletlv_member simple[1] = {
       {0x25, 2, {/*.value = simple_value*/}, SIMPLETLV_TYPE_LEAF}
@@ -102,7 +102,7 @@ static void test_length_skipped(void)
 static void test_encode_simple(void)
 {
     unsigned char *result = NULL;
-    size_t result_len = 0;
+    int result_len = 0;
     unsigned char simple_value[] = "\x10\x11";
     unsigned char simple_encoded[] = "\x25\x02\x10\x11";
     unsigned char long_value[256] = "Long data value";
@@ -168,7 +168,7 @@ static void test_encode_simple(void)
 static void test_encode_nested(void)
 {
     unsigned char *result = NULL;
-    size_t result_len = 0;
+    int result_len = 0;
     unsigned char simple_value[] = "\x12\x14";
     unsigned char encoded[] = "\x72\x04\x25\x02\x12\x14";
     static struct simpletlv_member simple[1] = {
-- 
2.17.1



More information about the Spice-devel mailing list