-
Notifications
You must be signed in to change notification settings - Fork 33
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
veikk_set_veikk_screen_size: Deserialization reads uninitialized values #24
Comments
The casting done in 73be60c was done mostly out of convenience and a (naive?) thought that gcc's behavior should be consistent across most devices. However, I will revert it to the more type-safe casting once I get time to work on this again. By the way, @cebtenzzre, did this cause any actual problems for you? Are you building your kernel with clang? Asking out of curiosity. If you have any advice about the safety of this cast, please let me know. AFAIK, |
Sorry, I was originally confused between the two definitions of I'm more familiar with C++, where type punning like this is undefined behavior and variable names can't be the same as struct names. And I actually haven't used this driver yet, I just threw a static analyzer at it to see if it was of sufficient quality to consider using. |
"This code isn't as bad as it looked to me at first" -- haha, I guess that's a good thing to hear. I agree about fixing the UB though, and the poor choice of variable name. Will fix later. |
Issue Description
The following deserialization code (in
veikk_set_veikk_screen_size
) upsets clang-tidy.veikk-linux-driver/veikk_modparms.c
Lines 51 to 57 in 7ccdfb1
This is what clang-tidy says about it:
height
is a garbage value becausess
(u32
, 4 bytes) is reinterpreted as astruct veikk_screen_size
(16 bytes). Onlyx
is actually initialized by line 55.height
is a "garbage value" because of the way two 16-bit integers are unpacked from a 32-bit integer using type punning. This probably works, but there are ways to do this that aren't considered unspecified behavior - such as shifting and masking.In revision 81c7207,
veikk_set_veikk_screen_size
usedveikk_ss_to_rect
, which didn't have this problem.Versions
This is a regression introduced by commit 73be60c.
The text was updated successfully, but these errors were encountered: