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

Improve unpack related APIs and their usage #1023

Merged
merged 2 commits into from
Sep 24, 2024

Conversation

axxel
Copy link
Contributor

@axxel axxel commented Sep 20, 2024

Details, see the two commit messages.

Those functions get passed an offset value into the data buffer. This
offset value needed to be updated on the calling side after the call with
internal knowledge of what exactly the unpack function itself was doing.
Now the offset becomes an in/out parameter and in updated internally. This
substantially reduces the complexity of the calling code.

Furthermore, the return value is now an error indicator and the array
length gets set via a pointer.

This further fixes a few places where there was a bug in the bounds
checking or no bounds checking at all.
The idea is to remove 'manual' offset adjustments:
```
unsigned offset = 0;
unsigned val = dtoh32o(data, offset);
// offset is now 4
```

Also contains some code beautification near the use of dtoh style macros.
@axxel
Copy link
Contributor Author

axxel commented Sep 23, 2024

@msmeissn I have some other changes lined up that depend on / conflict with this PR. Since you merged later PRs already, I assume this one is either too big or otherwise worrisome? Depending on whether you are still considering it or not, I'd either wait or move forward with another PR (removing 7 duplicate ptp-pack.c inclusions in other translation units).

@msmeissn
Copy link
Contributor

I will take some time to go over it today, as its needs careful review

@msmeissn msmeissn merged commit 910f0d9 into gphoto:master Sep 24, 2024
5 checks passed
@msmeissn
Copy link
Contributor

Thanks!

@axxel axxel deleted the improve-unpack-str-and-array-api branch September 24, 2024 16:29
@axxel
Copy link
Contributor Author

axxel commented Sep 24, 2024

Thanks for taking the time to review it properly. :)

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

Successfully merging this pull request may close these issues.

2 participants