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

Remove 'long' overloads for Xdr::read and Xdr::write functions #952

Merged

Conversation

peterhillman
Copy link
Contributor

Changing Int64 to uint64_t caused a build failure on some macOS targets.

Apparently on macOS, uint64_t is a long long unsigned int, rather than a long unsigned int, but the uint64_t overloads were #ifdef'd out, since ULONG_MAX is still 2^64-1. Providing Xdr::read and Xdr::write types for 'long' seems dangerous, due to such inconsistencies. One architecture/compiler may treat a type as a long and write 8 bytes, another may treat it is an int and read only 4 bytes, causing an incorrect stream pointer. It seems safer to remove all references to long from Xdr::read and Xdr::write, and simply provide uint64_t and int64_t overloads to read and write. Only types with well defined sizes should be read to or written from streams.

The only references to long values being used with Xdr were in IDManifest, which was a bug of exactly this nature, and in testXdr

Signed-off-by: Peter Hillman <peterh@wetafx.co.nz>
Signed-off-by: Peter Hillman <peterh@wetafx.co.nz>
Signed-off-by: Peter Hillman <peterh@wetafx.co.nz>
Signed-off-by: Peter Hillman <peterh@wetafx.co.nz>
Copy link
Member

@cary-ilm cary-ilm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks much cleaner to me.

@cary-ilm cary-ilm merged commit 8276579 into AcademySoftwareFoundation:master Mar 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants