Skip to content

Commit

Permalink
[GH-667] core: Avoid value truncation on 32bit architectures
Browse files Browse the repository at this point in the history
Replace `labs()` with `llabs()` to avoid truncation on 32bit
architectures. Also do not tolerate value truncation in the CI build.
  • Loading branch information
mlasch committed Jul 6, 2022
1 parent fd7c070 commit a782907
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ size_t utils_intToText(int64_t data,
string[int64_min_strlen] = '\0';
return int64_min_strlen;
}
result = utils_uintToText((uint64_t)labs(data), string + 1, length - 1);
result = utils_uintToText(llabs(data), string + 1, length - 1);
if(result != 0)
{
result += 1;
Expand Down
1 change: 1 addition & 0 deletions wakaama.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ add_compile_options(
-Wshadow
-Wswitch-default
-Wwrite-strings
-Werror=absolute-value
-pedantic
)

Expand Down

0 comments on commit a782907

Please sign in to comment.