Skip to content

Commit a782907

Browse files
committed
[GH-667] core: Avoid value truncation on 32bit architectures
Replace `labs()` with `llabs()` to avoid truncation on 32bit architectures. Also do not tolerate value truncation in the CI build.
1 parent fd7c070 commit a782907

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

core/utils.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ size_t utils_intToText(int64_t data,
218218
string[int64_min_strlen] = '\0';
219219
return int64_min_strlen;
220220
}
221-
result = utils_uintToText((uint64_t)labs(data), string + 1, length - 1);
221+
result = utils_uintToText(llabs(data), string + 1, length - 1);
222222
if(result != 0)
223223
{
224224
result += 1;

wakaama.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ add_compile_options(
124124
-Wshadow
125125
-Wswitch-default
126126
-Wwrite-strings
127+
-Werror=absolute-value
127128
-pedantic
128129
)
129130

0 commit comments

Comments
 (0)