-
Notifications
You must be signed in to change notification settings - Fork 283
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Fix warnings in BinarySerializer #963
base: master
Are you sure you want to change the base?
Conversation
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
@@ -34,7 +43,7 @@ class BinarySerializer { | |||
} | |||
|
|||
static size_t serializeBuffer( | |||
const char* buffer, | |||
char* buffer, |
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.
Just curious why remove const here? Are we modifying the buffer?
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.
Yes, the function serializes kcos into buffer. It should never have been const.
2dedd07
to
e5f0948
Compare
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
@@ -11,6 +10,16 @@ using namespace std; | |||
|
|||
namespace swss { | |||
|
|||
template <class T> static inline T read_unaligned(const char *buffer) { |
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.
do we need to check the case that T R/W has enough space for buffer memcpy?
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.
By the time these functions are called, the de/serializer has already checked the buffer's capacity.
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
This PR adjusts BinarySerializer in these ways:
A short discussion on this was held here previously: #921 (comment)
On x86/ARM, unaligned reads/writes are acceptable with general purpose registers, but they may crash on x86 if the optimizer decides to use a SIMD register.