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

Extract values in HIDParse correctly when compiled in 64-bit (LP64) mode #1024

Merged
merged 2 commits into from May 24, 2021

Conversation

nbriggs
Copy link
Contributor

@nbriggs nbriggs commented Apr 23, 2021

Reworks the conversion of bytes in little-endian order to host order to
operate independently of the sizeof(long) and the byte-order of the host system.
The extracted value is stored as uint32_t as the code already performs casts
to signed/unsigned of varying sizes as appropriate to the context of use.

Closes issue #1015

Reworks the conversion of bytes in little-endian order to host order to
operate independently of the sizeof(long) and the byte-order of the host system.
The extracted value is stored as uint32_t as the code already performs casts
to signed/unsigned of varying sizes as appropriate to the context of use.
@nbriggs
Copy link
Contributor Author

nbriggs commented Apr 23, 2021

See withdrawn/closed PR #1016 for additional discussion.

@jimklimov
Copy link
Member

Thanks, so in this incarnation, does the byte-stream-to-number conversion work reasonably for all host types and word lengths involved?

@nbriggs
Copy link
Contributor Author

nbriggs commented Apr 23, 2021

Yes, the new conversion of a little-endian number in the byte stream is independent of word size (32/64 bit) and endian-ness. It doesn't address the bug I raised in issue #1023 which will need some more thought.

@jimklimov
Copy link
Member

Just in case - is it also producing numbers as expected for shorter integers (8, 16 bits), in particular with no garbage in uninitialized memory of bytes not touched? Seems all should be OK, but better double-checked than sorry :)

@nbriggs
Copy link
Contributor Author

nbriggs commented Apr 23, 2021

Yes, there is no possibility of there being uninitialized bytes in the result as the entire result (pParser->Value) is zeroed before anything is accumulated into it, and the only values subsequently accumulated are the 0, 1, 2, or 4 bytes as specified by the length of the item.

This code is used to parse the report descriptors but not the values that the UPS reports back as its state changes (that's GetValue)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
USB-HID encoding/LogMin/LogMax Issues and solutions (PRs) specifically about incorrect values in bitstream
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants