[SSSD] [PATCH] sbus_codegen_tests: Use portable definition of large constants
Lukas Slebodnik
lslebodn at redhat.com
Thu Nov 12 06:32:18 UTC 2015
ehlo,
INT64_C(n) will expand to something appropriate for any n in (at least) a
64-bit range (see §7.18 in general, and particularly §7.18.4.1).
http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1256.pdf
You can see a warnings only on 32 bit architecture.
So the simplest reproducer is to rebuild sssd in 32 bit chroot in mock
mock --root epel-6-i386 --resultdir . --rebuild ./sssd-1.13.90-0.fc23.src.rpm
LS
-------------- next part --------------
>From 293e5b53ab8a500ccba4ee1c62242277db26b200 Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn at redhat.com>
Date: Thu, 12 Nov 2015 05:56:54 +0000
Subject: [PATCH] sbus_codegen_tests: Use portable definition of large
constants
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
There were warnings on 32 bit architecture related to 64bit integer constants.
/home/build/sssd/src/tests/sbus_codegen_tests.c:257:
warning: integer constant is too large for ‘long’ type
/home/build/sssd/src/tests/sbus_codegen_tests.c:259:
warning: integer constant is too large for ‘long’ type
INT${N}_C(value) are defined in the standard c99
---
src/tests/sbus_codegen_tests.c | 25 +++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/src/tests/sbus_codegen_tests.c b/src/tests/sbus_codegen_tests.c
index 53b5d6fcf97d276945ce935af4cd71a5f2d768d0..55d4657385cfc697985b570e4310164558e2d647 100644
--- a/src/tests/sbus_codegen_tests.c
+++ b/src/tests/sbus_codegen_tests.c
@@ -22,6 +22,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <stdint.h>
#include <stdlib.h>
#include <check.h>
#include <talloc.h>
@@ -254,9 +255,9 @@ static int eject_handler(struct sbus_request *req, void *instance_data,
arg_int32++;
ck_assert_uint_eq(arg_uint32, 55555555);
arg_uint32++;
- ck_assert(arg_int64 == -6666666666666666);
+ ck_assert(arg_int64 == INT64_C(-6666666666666666));
arg_int64++;
- ck_assert(arg_uint64 == 7777777777777777);
+ ck_assert(arg_uint64 == UINT64_C(7777777777777777));
arg_uint64++;
ck_assert(arg_double == 1.1);
arg_double++;
@@ -658,8 +659,8 @@ START_TEST(test_marshal_basic_types)
dbus_uint16_t arg_uint16 = 3333;
dbus_int32_t arg_int32 = -44444444;
dbus_uint32_t arg_uint32 = 55555555;
- dbus_int64_t arg_int64 = -6666666666666666;
- dbus_uint64_t arg_uint64 = 7777777777777777;
+ dbus_int64_t arg_int64 = INT64_C(-6666666666666666);
+ dbus_uint64_t arg_uint64 = UINT64_C(7777777777777777);
double arg_double = 1.1;
const char *arg_string = "hello";
const char *arg_object_path = "/original/object/path";
@@ -669,8 +670,8 @@ START_TEST(test_marshal_basic_types)
dbus_uint16_t v_uint16[] = { 1, 2, 3, 4, 5 };
dbus_int32_t v_int32[] = { -1, -23, 34, -56, -90000000, 78 };
dbus_uint32_t v_uint32[] = { 11111111, 22222222, 33333333 };
- dbus_int64_t v_int64[] = { -6666666666666666, 7777777777777777 };
- dbus_uint64_t v_uint64[] = { 7777777777777777, 888888888888888888 };
+ dbus_int64_t v_int64[] = { INT64_C(-6666666666666666), INT64_C(7777777777777777) };
+ dbus_uint64_t v_uint64[] = { UINT64_C(7777777777777777), INT64_C(888888888888888888) };
double v_double[] = { 1.1, 2.2, 3.3 };
char *v_string[] = { "bears", "bears", "bears" };
char *v_object_path[] = { "/original", "/original" };
@@ -767,8 +768,8 @@ START_TEST(test_marshal_basic_types)
ck_assert_uint_eq(arg_uint16, 3334);
ck_assert_int_eq(arg_int32, -44444443);
ck_assert_uint_eq(arg_uint32, 55555556);
- ck_assert(arg_int64 ==-6666666666666665);
- ck_assert(arg_uint64 == 7777777777777778);
+ ck_assert(arg_int64 == INT64_C(-6666666666666665));
+ ck_assert(arg_uint64 == UINT64_C(7777777777777778));
ck_assert(arg_double == 2.1);
ck_assert_str_eq(arg_string, "bears, beets, battlestar galactica");
ck_assert_str_eq(arg_object_path, "/another/object/path");
@@ -802,12 +803,12 @@ START_TEST(test_marshal_basic_types)
ck_assert_uint_eq(arr_uint32[2], 33333334);
ck_assert_int_eq(len_int64, 2);
- ck_assert(arr_int64[0] == -6666666666666665);
- ck_assert(arr_int64[1] == 7777777777777778);
+ ck_assert(arr_int64[0] == INT64_C(-6666666666666665));
+ ck_assert(arr_int64[1] == INT64_C(7777777777777778));
ck_assert_int_eq(len_uint64, 2);
- ck_assert(arr_uint64[0] == 7777777777777778);
- ck_assert(arr_uint64[1] == 888888888888888889);
+ ck_assert(arr_uint64[0] == UINT64_C(7777777777777778));
+ ck_assert(arr_uint64[1] == UINT64_C(888888888888888889));
ck_assert_int_eq(len_double, 3);
ck_assert(arr_double[0] == 2.1);
--
2.5.0
More information about the sssd-devel
mailing list