Skip to content

Commit

Permalink
tests: fix array sorting on big endian 64 bit
Browse files Browse the repository at this point in the history
The array elements are unsigned long, i.e. 64 bit on such arches. When casting
them to int only the lower half would be compared, which doesn't matter on
32 bit arches or little endian, but fails on 64 bit BE as s390 or sparc.
  • Loading branch information
DerDakon committed Jan 25, 2024
1 parent 70762e1 commit 3f04694
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tests/unittest_prioq.c
Expand Up @@ -101,7 +101,7 @@ START_TEST(test_prioq_insert_high_priority_to_low)
END_TEST

static int compare(const void *a, const void *b) {
return (*(int*)a - *(int*)b);
return (*(unsigned long*)a - *(unsigned long*)b);
}

START_TEST(test_prioq_insert_all_same_priority)
Expand Down

0 comments on commit 3f04694

Please sign in to comment.