Skip to content
Snippets Groups Projects
Commit 0ee02471 authored by Dominik Loidolt's avatar Dominik Loidolt
Browse files

fix a endianess bug in the cmp_ent_get_end_timestamp() function

parent bdef4288
No related branches found
No related tags found
1 merge request!12increase code coverage, general code refactoring
...@@ -39,7 +39,11 @@ ...@@ -39,7 +39,11 @@
#include <stdint.h> #include <stdint.h>
#ifndef GCC_VERSION
#define GCC_VERSION (__GNUC__ * 10000 \
+ __GNUC_MINOR__ * 100 \
+ __GNUC_PATCHLEVEL__)
#endif
#ifdef __BIG_ENDIAN #ifdef __BIG_ENDIAN
#undef __BIG_ENDIAN #undef __BIG_ENDIAN
......
...@@ -1083,7 +1083,7 @@ uint64_t cmp_ent_get_end_timestamp(struct cmp_entity *ent) ...@@ -1083,7 +1083,7 @@ uint64_t cmp_ent_get_end_timestamp(struct cmp_entity *ent)
return 0; return 0;
#ifdef __LITTLE_ENDIAN #ifdef __LITTLE_ENDIAN
return be64_to_cpu(ent->end_timestamp << 16); return be64_to_cpu(ent->end_timestamp) >> 16;
#else #else
return ent->end_timestamp; return ent->end_timestamp;
#endif /* __LITTLE_ENDIAN */ #endif /* __LITTLE_ENDIAN */
......
...@@ -51,7 +51,7 @@ void test_cmp_cal_size_of_data(void) ...@@ -51,7 +51,7 @@ void test_cmp_cal_size_of_data(void)
void test_cmp_set_max_used_bits(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(&set_max_used_bits);
cmp_set_max_used_bits(NULL); cmp_set_max_used_bits(NULL);
} }
...@@ -328,7 +328,7 @@ void test_ent_end_timestamp(void) ...@@ -328,7 +328,7 @@ void test_ent_end_timestamp(void)
TEST_ASSERT_FALSE(error); TEST_ASSERT_FALSE(error);
end_timestamp_read = cmp_ent_get_end_timestamp(&ent); 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 */ /* check the right position in the header */
TEST_ASSERT_EQUAL_HEX(0x12, entity_p[16]); TEST_ASSERT_EQUAL_HEX(0x12, entity_p[16]);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment