diff --git a/include/byteorder.h b/include/byteorder.h index 42fa9b850bc7faed218e92790ee04d176265b97f..ff2557852780f3a3000e88c0b9aa241c163db41c 100644 --- a/include/byteorder.h +++ b/include/byteorder.h @@ -39,7 +39,11 @@ #include <stdint.h> - +#ifndef GCC_VERSION +#define GCC_VERSION (__GNUC__ * 10000 \ + + __GNUC_MINOR__ * 100 \ + + __GNUC_PATCHLEVEL__) +#endif #ifdef __BIG_ENDIAN #undef __BIG_ENDIAN @@ -72,7 +76,7 @@ (((uint32_t)(x) & (uint32_t)0x00ff0000UL) >> 8) | \ (((uint32_t)(x) & (uint32_t)0xff000000UL) >> 24))) -#define ___constant_swab64(x) ((uint64_t)( \ +#define ___constant_swab64(x) ((uint64_t)( \ (((uint64_t)(x) & (uint64_t)0x00000000000000ffULL) << 56) | \ (((uint64_t)(x) & (uint64_t)0x000000000000ff00ULL) << 40) | \ (((uint64_t)(x) & (uint64_t)0x0000000000ff0000ULL) << 24) | \ diff --git a/lib/cmp_entity.c b/lib/cmp_entity.c index 40900bc3fb228b07daa8ce58d1142c1a7e644d0d..a2a6637789fdfa980a5166ac83b30e299b4171ae 100644 --- a/lib/cmp_entity.c +++ b/lib/cmp_entity.c @@ -1083,7 +1083,7 @@ uint64_t cmp_ent_get_end_timestamp(struct cmp_entity *ent) return 0; #ifdef __LITTLE_ENDIAN - return be64_to_cpu(ent->end_timestamp << 16); + return be64_to_cpu(ent->end_timestamp) >> 16; #else return ent->end_timestamp; #endif /* __LITTLE_ENDIAN */ diff --git a/test/cmp_data_types/test_cmp_data_types.c b/test/cmp_data_types/test_cmp_data_types.c index 0e5252cd5f869e4bf0cabaf573311e2e53f731fb..4d6d43191061a22e62186bf26f305903bc62822f 100644 --- a/test/cmp_data_types/test_cmp_data_types.c +++ b/test/cmp_data_types/test_cmp_data_types.c @@ -51,7 +51,7 @@ void test_cmp_cal_size_of_data(void) void test_cmp_set_max_used_bits(void) { - struct cmp_max_used_bits set_max_used_bits; + struct cmp_max_used_bits set_max_used_bits = {0}; cmp_set_max_used_bits(&set_max_used_bits); cmp_set_max_used_bits(NULL); } diff --git a/test/cmp_entity/test_cmp_entity.c b/test/cmp_entity/test_cmp_entity.c index db4f658d9da78ad894295d5b3cfb98becae43983..2122b83ec71fe671c173775302d777edb4cb9f6a 100644 --- a/test/cmp_entity/test_cmp_entity.c +++ b/test/cmp_entity/test_cmp_entity.c @@ -328,7 +328,7 @@ void test_ent_end_timestamp(void) TEST_ASSERT_FALSE(error); end_timestamp_read = cmp_ent_get_end_timestamp(&ent); - TEST_ASSERT_EQUAL_UINT64(end_timestamp, end_timestamp_read); + TEST_ASSERT_EQUAL_HEX64(end_timestamp, end_timestamp_read); /* check the right position in the header */ TEST_ASSERT_EQUAL_HEX(0x12, entity_p[16]);