Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

warning: absolute value function 'labs' given an argument of type 'int64_t' #667

Closed
parmi93 opened this issue Jun 29, 2022 · 2 comments · Fixed by #668
Closed

warning: absolute value function 'labs' given an argument of type 'int64_t' #667

parmi93 opened this issue Jun 29, 2022 · 2 comments · Fixed by #668

Comments

@parmi93
Copy link
Contributor

parmi93 commented Jun 29, 2022

I am trying to compile the library for an embedded system based on an ARM Cortex A7.
I have not been able to compile the project yet due to several errors that I have to fix to complete the port.

In particular, I noticed this warning:
image

The labs and llabs functions are defined as follows:
long labs (long);
long long llabs (long long);

Where the long type has a size of 4 bytes.

Any suggestions?

@mlasch
Copy link
Contributor

mlasch commented Jul 3, 2022

Hello @parmi93, thanks for reporting. Indeed the utils_intToText has an int64_t input and provides it to labs(long) which truncates the value on a 32bit machine.
This should have been caught by the unit tests. However the test never reaches this line with a value which actually gets truncated. I'll prepare a fix for that.

mlasch added a commit to husqvarnagroup/wakaama that referenced this issue Jul 3, 2022
…32bit truncation

The test was not covering the whole function, thus missing an imporant
section where truncation of the input value can happen on a 32bit
architecture.
mlasch added a commit to husqvarnagroup/wakaama that referenced this issue Jul 3, 2022
…ctures

Replace `labs()` with `llabs()` to avoid truncation on 32bit
architectures. Also do not tolerate value truncation in CI build.
mlasch added a commit to husqvarnagroup/wakaama that referenced this issue Jul 3, 2022
…ctures

Replace `labs()` with `llabs()` to avoid truncation on 32bit
architectures. Also do not tolerate value truncation in the CI build.
mlasch added a commit to husqvarnagroup/wakaama that referenced this issue Jul 5, 2022
…32bit truncation

The test was not covering the whole function, thus missing an imporant
section where truncation of the input value can happen on a 32bit
architecture.
mlasch added a commit to husqvarnagroup/wakaama that referenced this issue Jul 5, 2022
…ctures

Replace `labs()` with `llabs()` to avoid truncation on 32bit
architectures. Also do not tolerate value truncation in the CI build.
mlasch added a commit that referenced this issue Jul 6, 2022
The test was not covering the whole function, thus missing an imporant
section where truncation of the input value can happen on a 32bit
architecture.
mlasch added a commit that referenced this issue Jul 6, 2022
Replace `labs()` with `llabs()` to avoid truncation on 32bit
architectures. Also do not tolerate value truncation in the CI build.
@parmi93
Copy link
Contributor Author

parmi93 commented Jul 12, 2022

Thanks you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants