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

[meta] Enable strict cast-align warning #738

Merged
merged 1 commit into from
Dec 13, 2020
Merged

Conversation

kcudnik
Copy link
Collaborator

@kcudnik kcudnik commented Dec 11, 2020

Required on ARM architecture where strict alignment is required.
Also fixes cast to std::size_t which size is 4 bytes

Signed-off-by: kcudnik [email protected]

Required on ARM architecture where strict alignment is required.
Also fixes cast to std::size_t which size is 4 bytes

Signed-off-by: kcudnik <[email protected]>
const uint32_t* ip6 = (const uint32_t*)re.destination.addr.ip6;
// cast is not good enough for arm (cast align)
uint32_t ip6[4];
memcpy(ip6, re.destination.addr.ip6, sizeof(ip6));
Copy link
Contributor

Choose a reason for hiding this comment

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

addr [](start = 35, length = 4)

I see sai_ip_addr_t is already 4 bytes aligned because ip4 is uint32_t. So the memcpy is preventable.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

somehow on arm architecture it still gives this warning, also i checked assembly on O2, and memcpy is optimized, and it's not there, just direct ip access

@kcudnik kcudnik merged commit f4a673f into sonic-net:master Dec 13, 2020
@kcudnik kcudnik deleted the armhash branch December 13, 2020 11:14
kktheballer pushed a commit to kktheballer/sonic-sairedis that referenced this pull request Mar 10, 2021
Required on ARM architecture where strict alignment is required.
Also fixes cast to std::size_t which size is 4 bytes

Signed-off-by: kcudnik <[email protected]>
@kcudnik kcudnik mentioned this pull request Aug 13, 2021
pettershao-ragilenetworks pushed a commit to pettershao-ragilenetworks/sonic-sairedis that referenced this pull request Nov 18, 2022
Required on ARM architecture where strict alignment is required.
Also fixes cast to std::size_t which size is 4 bytes

Signed-off-by: kcudnik <[email protected]>
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.

3 participants