-
Notifications
You must be signed in to change notification settings - Fork 4
Upgrade to boost 1.89.0 #5
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
base: master
Are you sure you want to change the base?
Conversation
pysco68
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the "SHA1 to hex string" bit could be simpler and less error prone.
Why not reinterpret cast hash to const unsigned char* given it's POD and walk through the LUT byte by byte instead of having the two disinct codepaths.
Also (but I think we can ignore this for the time being) SHA-1 digest bytes are big-endian - boost's digest_type uses the underlying host endianess so this would produce broken hashes there (also the previous code was broken in that regard tbh)
Boost 1.89.0 is required to have a compatible standard library. Older versionis would use std::unary_function which is not supported anymore in C++17. Using the proper internal type name boost::uuids::detail::sha1::digest_type result in 2 different behaviors depending on the Boost version. The type can either be an array of "unsigned int[5]" (older Boost) or "char[20]" (newer Boost) which the serialization code needs to handle. The serialization code is also moved away from using sprintf as modern compilers will emit lots of different warnings or errors.
|
The less error prone thing to do would be not to use the internals of Since the code path with |
pysco68
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| hash_buf[i * 2 + 7] = int_to_hex[(hash[i] ) & 0xF]; | ||
| } | ||
| } else { | ||
| throw std::runtime_error("Unsupported boost::uuids::detail::sha1::digest_type size"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should set ec here not throw, throw is only from the overload without ec, this is following the same pricinple as how boost.asio design APIs
If we could do static_assert it would be better, but it seems not possible in our c++ version.
daminetreg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm opposing the merge of this until it is tested in nxxm-src.
Also I'm against the plan to integrate it with tipi CMakeList generator in cmake-re as this is not going in the actual direction of moving everything to a cmake-re we have that was already done for this library.
Yes it's an header only library, nevertheless it should be consumed with proper package configurations boundaries as in https://github.com/forexample/package-example/.
The plan for this is currently being written and I don't want to hack some upgrade of boost and stop using the CMakeLists here.
So either we switch fully to a newer boost or we don't.
Also regarding the code behaving differently on different boost versions it not necessarily something we want to maintain.
If we would I would not be going for the throw, which could be done with a static_assert as already mentioned on another discussion channel with @Orphis. Or what I would find much more readable checking for boost versions with the prepocessor. But ultimately we just want one codepath, relating to the version we use as basis.
It's less elegant in some ways, but much easier to maintain.
Boost 1.89.0 is required to have a compatible standard library. Older versionis would use std::unary_function which is not supported anymore in C++17.
Using the proper internal type name boost::uuids::detail::sha1::digest_type result in 2 different behaviors depending on the Boost version. The type can either be an array of "unsigned int[5]" (older Boost) or "char[20]" (newer Boost) which the serialization code needs to handle.
The serialization code is also moved away from using sprintf as modern compilers will emit lots of different warnings or errors.