From nobody Mon Feb 9 02:14:41 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1487880053618579.8148401360042; Thu, 23 Feb 2017 12:00:53 -0800 (PST) Received: from localhost ([::1]:60711 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgzZL-0008Ue-Ek for importer@patchew.org; Thu, 23 Feb 2017 15:00:51 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39730) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgzSs-0001xi-Ce for qemu-devel@nongnu.org; Thu, 23 Feb 2017 14:54:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cgzSo-0000mE-99 for qemu-devel@nongnu.org; Thu, 23 Feb 2017 14:54:10 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38442) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cgzSn-0000lS-Ve for qemu-devel@nongnu.org; Thu, 23 Feb 2017 14:54:06 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8D194C04B93A for ; Thu, 23 Feb 2017 19:54:05 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-55.ams2.redhat.com [10.36.116.55]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1NJs48C029913 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Thu, 23 Feb 2017 14:54:05 -0500 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 8A56F1138657; Thu, 23 Feb 2017 20:54:02 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Thu, 23 Feb 2017 20:53:42 +0100 Message-Id: <1487879642-16139-5-git-send-email-armbru@redhat.com> In-Reply-To: <1487879642-16139-1-git-send-email-armbru@redhat.com> References: <1487879642-16139-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 23 Feb 2017 19:54:05 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 04/24] test-cutils: Clean up qemu_strtoul() result checks X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Use unsigned comparisons to check the result of qemu_strtoul() and strtoull(). Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Message-Id: <1487708048-2131-5-git-send-email-armbru@redhat.com> --- tests/test-cutils.c | 60 ++++++++++++++++++++++++++-----------------------= ---- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/tests/test-cutils.c b/tests/test-cutils.c index 71681dc..749aaa9 100644 --- a/tests/test-cutils.c +++ b/tests/test-cutils.c @@ -523,7 +523,7 @@ static void test_qemu_strtoul_correct(void) err =3D qemu_strtoul(str, &endptr, 0, &res); =20 g_assert_cmpint(err, =3D=3D, 0); - g_assert_cmpint(res, =3D=3D, 12345); + g_assert_cmpuint(res, =3D=3D, 12345); g_assert(endptr =3D=3D str + 5); } =20 @@ -593,7 +593,7 @@ static void test_qemu_strtoul_trailing(void) err =3D qemu_strtoul(str, &endptr, 0, &res); =20 g_assert_cmpint(err, =3D=3D, 0); - g_assert_cmpint(res, =3D=3D, 123); + g_assert_cmpuint(res, =3D=3D, 123); g_assert(endptr =3D=3D str + 3); } =20 @@ -608,7 +608,7 @@ static void test_qemu_strtoul_octal(void) err =3D qemu_strtoul(str, &endptr, 8, &res); =20 g_assert_cmpint(err, =3D=3D, 0); - g_assert_cmpint(res, =3D=3D, 0123); + g_assert_cmpuint(res, =3D=3D, 0123); g_assert(endptr =3D=3D str + strlen(str)); =20 res =3D 999; @@ -616,7 +616,7 @@ static void test_qemu_strtoul_octal(void) err =3D qemu_strtoul(str, &endptr, 0, &res); =20 g_assert_cmpint(err, =3D=3D, 0); - g_assert_cmpint(res, =3D=3D, 0123); + g_assert_cmpuint(res, =3D=3D, 0123); g_assert(endptr =3D=3D str + strlen(str)); } =20 @@ -631,7 +631,7 @@ static void test_qemu_strtoul_decimal(void) err =3D qemu_strtoul(str, &endptr, 10, &res); =20 g_assert_cmpint(err, =3D=3D, 0); - g_assert_cmpint(res, =3D=3D, 123); + g_assert_cmpuint(res, =3D=3D, 123); g_assert(endptr =3D=3D str + strlen(str)); =20 str =3D "123"; @@ -640,7 +640,7 @@ static void test_qemu_strtoul_decimal(void) err =3D qemu_strtoul(str, &endptr, 0, &res); =20 g_assert_cmpint(err, =3D=3D, 0); - g_assert_cmpint(res, =3D=3D, 123); + g_assert_cmpuint(res, =3D=3D, 123); g_assert(endptr =3D=3D str + strlen(str)); } =20 @@ -655,7 +655,7 @@ static void test_qemu_strtoul_hex(void) err =3D qemu_strtoul(str, &endptr, 16, &res); =20 g_assert_cmpint(err, =3D=3D, 0); - g_assert_cmpint(res, =3D=3D, 0x123); + g_assert_cmphex(res, =3D=3D, 0x123); g_assert(endptr =3D=3D str + strlen(str)); =20 str =3D "0x123"; @@ -664,7 +664,7 @@ static void test_qemu_strtoul_hex(void) err =3D qemu_strtoul(str, &endptr, 0, &res); =20 g_assert_cmpint(err, =3D=3D, 0); - g_assert_cmpint(res, =3D=3D, 0x123); + g_assert_cmphex(res, =3D=3D, 0x123); g_assert(endptr =3D=3D str + strlen(str)); } =20 @@ -679,7 +679,7 @@ static void test_qemu_strtoul_max(void) err =3D qemu_strtoul(str, &endptr, 0, &res); =20 g_assert_cmpint(err, =3D=3D, 0); - g_assert_cmpint(res, =3D=3D, ULONG_MAX); + g_assert_cmphex(res, =3D=3D, ULONG_MAX); g_assert(endptr =3D=3D str + strlen(str)); g_free(str); } @@ -695,7 +695,7 @@ static void test_qemu_strtoul_overflow(void) err =3D qemu_strtoul(str, &endptr, 0, &res); =20 g_assert_cmpint(err, =3D=3D, -ERANGE); - g_assert_cmpint(res, =3D=3D, ULONG_MAX); + g_assert_cmphex(res, =3D=3D, ULONG_MAX); g_assert(endptr =3D=3D str + strlen(str)); } =20 @@ -710,7 +710,7 @@ static void test_qemu_strtoul_underflow(void) err =3D qemu_strtoul(str, &endptr, 0, &res); =20 g_assert_cmpint(err, =3D=3D, -ERANGE); - g_assert_cmpint(res, =3D=3D, -1ul); + g_assert_cmpuint(res, =3D=3D, -1ul); g_assert(endptr =3D=3D str + strlen(str)); } =20 @@ -725,7 +725,7 @@ static void test_qemu_strtoul_negative(void) err =3D qemu_strtoul(str, &endptr, 0, &res); =20 g_assert_cmpint(err, =3D=3D, 0); - g_assert_cmpint(res, =3D=3D, -321ul); + g_assert_cmpuint(res, =3D=3D, -321ul); g_assert(endptr =3D=3D str + strlen(str)); } =20 @@ -738,7 +738,7 @@ static void test_qemu_strtoul_full_correct(void) err =3D qemu_strtoul(str, NULL, 0, &res); =20 g_assert_cmpint(err, =3D=3D, 0); - g_assert_cmpint(res, =3D=3D, 123); + g_assert_cmpuint(res, =3D=3D, 123); } =20 static void test_qemu_strtoul_full_null(void) @@ -769,7 +769,7 @@ static void test_qemu_strtoul_full_negative(void) =20 err =3D qemu_strtoul(str, NULL, 0, &res); g_assert_cmpint(err, =3D=3D, 0); - g_assert_cmpint(res, =3D=3D, -321ul); + g_assert_cmpuint(res, =3D=3D, -321ul); } =20 static void test_qemu_strtoul_full_trailing(void) @@ -792,7 +792,7 @@ static void test_qemu_strtoul_full_max(void) err =3D qemu_strtoul(str, NULL, 0, &res); =20 g_assert_cmpint(err, =3D=3D, 0); - g_assert_cmpint(res, =3D=3D, ULONG_MAX); + g_assert_cmphex(res, =3D=3D, ULONG_MAX); g_free(str); } =20 @@ -1094,7 +1094,7 @@ static void test_qemu_strtoull_correct(void) err =3D qemu_strtoull(str, &endptr, 0, &res); =20 g_assert_cmpint(err, =3D=3D, 0); - g_assert_cmpint(res, =3D=3D, 12345); + g_assert_cmpuint(res, =3D=3D, 12345); g_assert(endptr =3D=3D str + 5); } =20 @@ -1164,7 +1164,7 @@ static void test_qemu_strtoull_trailing(void) err =3D qemu_strtoull(str, &endptr, 0, &res); =20 g_assert_cmpint(err, =3D=3D, 0); - g_assert_cmpint(res, =3D=3D, 123); + g_assert_cmpuint(res, =3D=3D, 123); g_assert(endptr =3D=3D str + 3); } =20 @@ -1179,7 +1179,7 @@ static void test_qemu_strtoull_octal(void) err =3D qemu_strtoull(str, &endptr, 8, &res); =20 g_assert_cmpint(err, =3D=3D, 0); - g_assert_cmpint(res, =3D=3D, 0123); + g_assert_cmpuint(res, =3D=3D, 0123); g_assert(endptr =3D=3D str + strlen(str)); =20 endptr =3D &f; @@ -1187,7 +1187,7 @@ static void test_qemu_strtoull_octal(void) err =3D qemu_strtoull(str, &endptr, 0, &res); =20 g_assert_cmpint(err, =3D=3D, 0); - g_assert_cmpint(res, =3D=3D, 0123); + g_assert_cmpuint(res, =3D=3D, 0123); g_assert(endptr =3D=3D str + strlen(str)); } =20 @@ -1202,7 +1202,7 @@ static void test_qemu_strtoull_decimal(void) err =3D qemu_strtoull(str, &endptr, 10, &res); =20 g_assert_cmpint(err, =3D=3D, 0); - g_assert_cmpint(res, =3D=3D, 123); + g_assert_cmpuint(res, =3D=3D, 123); g_assert(endptr =3D=3D str + strlen(str)); =20 str =3D "123"; @@ -1211,7 +1211,7 @@ static void test_qemu_strtoull_decimal(void) err =3D qemu_strtoull(str, &endptr, 0, &res); =20 g_assert_cmpint(err, =3D=3D, 0); - g_assert_cmpint(res, =3D=3D, 123); + g_assert_cmpuint(res, =3D=3D, 123); g_assert(endptr =3D=3D str + strlen(str)); } =20 @@ -1226,7 +1226,7 @@ static void test_qemu_strtoull_hex(void) err =3D qemu_strtoull(str, &endptr, 16, &res); =20 g_assert_cmpint(err, =3D=3D, 0); - g_assert_cmpint(res, =3D=3D, 0x123); + g_assert_cmphex(res, =3D=3D, 0x123); g_assert(endptr =3D=3D str + strlen(str)); =20 str =3D "0x123"; @@ -1235,7 +1235,7 @@ static void test_qemu_strtoull_hex(void) err =3D qemu_strtoull(str, &endptr, 0, &res); =20 g_assert_cmpint(err, =3D=3D, 0); - g_assert_cmpint(res, =3D=3D, 0x123); + g_assert_cmphex(res, =3D=3D, 0x123); g_assert(endptr =3D=3D str + strlen(str)); } =20 @@ -1250,7 +1250,7 @@ static void test_qemu_strtoull_max(void) err =3D qemu_strtoull(str, &endptr, 0, &res); =20 g_assert_cmpint(err, =3D=3D, 0); - g_assert_cmpint(res, =3D=3D, ULLONG_MAX); + g_assert_cmphex(res, =3D=3D, ULLONG_MAX); g_assert(endptr =3D=3D str + strlen(str)); g_free(str); } @@ -1266,7 +1266,7 @@ static void test_qemu_strtoull_overflow(void) err =3D qemu_strtoull(str, &endptr, 0, &res); =20 g_assert_cmpint(err, =3D=3D, -ERANGE); - g_assert_cmpint(res, =3D=3D, ULLONG_MAX); + g_assert_cmphex(res, =3D=3D, ULLONG_MAX); g_assert(endptr =3D=3D str + strlen(str)); } =20 @@ -1281,7 +1281,7 @@ static void test_qemu_strtoull_underflow(void) err =3D qemu_strtoull(str, &endptr, 0, &res); =20 g_assert_cmpint(err, =3D=3D, -ERANGE); - g_assert_cmpint(res, =3D=3D, -1); + g_assert_cmphex(res, =3D=3D, -1ull); g_assert(endptr =3D=3D str + strlen(str)); } =20 @@ -1296,7 +1296,7 @@ static void test_qemu_strtoull_negative(void) err =3D qemu_strtoull(str, &endptr, 0, &res); =20 g_assert_cmpint(err, =3D=3D, 0); - g_assert_cmpint(res, =3D=3D, -321); + g_assert_cmpuint(res, =3D=3D, -321ull); g_assert(endptr =3D=3D str + strlen(str)); } =20 @@ -1309,7 +1309,7 @@ static void test_qemu_strtoull_full_correct(void) err =3D qemu_strtoull(str, NULL, 0, &res); =20 g_assert_cmpint(err, =3D=3D, 0); - g_assert_cmpint(res, =3D=3D, 18446744073709551614LLU); + g_assert_cmpuint(res, =3D=3D, 18446744073709551614ull); } =20 static void test_qemu_strtoull_full_null(void) @@ -1342,7 +1342,7 @@ static void test_qemu_strtoull_full_negative(void) err =3D qemu_strtoull(str, NULL, 0, &res); =20 g_assert_cmpint(err, =3D=3D, 0); - g_assert_cmpint(res, =3D=3D, 18446744073709551295LLU); + g_assert_cmpuint(res, =3D=3D, -321ull); } =20 static void test_qemu_strtoull_full_trailing(void) @@ -1365,7 +1365,7 @@ static void test_qemu_strtoull_full_max(void) err =3D qemu_strtoull(str, NULL, 0, &res); =20 g_assert_cmpint(err, =3D=3D, 0); - g_assert_cmpint(res, =3D=3D, ULLONG_MAX); + g_assert_cmphex(res, =3D=3D, ULLONG_MAX); g_free(str); } =20 --=20 2.7.4