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

Many compilation warnings when compiling under lp64 data model with -Wconversion option #1462

Open
GFWisshit opened this issue May 8, 2024 · 1 comment

Comments

@GFWisshit
Copy link

Hi guys.
osal/src/os/shared/inc\os-shared-idmap.h:257:38: warning: implicit conversion loses integer precision: 'unsigned long' to 'osal_objtype_t' (aka 'unsigned int') [-Wshorten-64-to-32]
return (OS_ObjectIdToInteger(id) >> OS_OBJECT_TYPE_SHIFT);

image
image
The return value type of OS_ObjectIdToInteger is unsigned long and the return type of OS_ObjectIdToType_Impl is uint32_t, which causes an implicit conversion and causes the compiler to complain.Will this warning be fixed?

@jphickey
Copy link
Contributor

jphickey commented May 8, 2024

Certainly there is a preference for making the code compile cleanly without warnings, but in my experience most/all of the "conversion" warnings are just a nuisance. My recommendation would be to simply turn off the conversion warning (-Wno-conversion) for the reason that it just creates a lot of false-positive noise.

This one looks like it could be worked around with a cast. But there is no actual problem as all the values being used are within the range of "unsigned int" (unsigned long was only used here for consistency with the %lx printf conversion specifier). So while the compiler does see a loss of precision, its not actually an issue at all.

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

No branches or pull requests

2 participants