Skip to content

L2CAP sm: do not discard alignment information.#252

Merged
andrzej-kaczmarek merged 1 commit intoapache:masterfrom
riot-appstore:fix-pointer-alignment-cast
Dec 4, 2018
Merged

L2CAP sm: do not discard alignment information.#252
andrzej-kaczmarek merged 1 commit intoapache:masterfrom
riot-appstore:fix-pointer-alignment-cast

Conversation

@jcarrano
Copy link
Copy Markdown
Contributor

Description

ble_sm_gen_ediv and ble_sm_gen_master_id_rand took a simple pointer to integers, but were being called with pointers to members of a packed struct. This discarded the alignment information.

Not only did it produce an error with clang's -Wno-address-of-packed-member, but it may also cause an error in a platform with alignment requirements.

The solution was to modify both procedures to take a pointer to the whole structure instead of only the members.

This is my first contribution to this project, so please excuse if there is anything not OK with the commit/pr.

How to test

Compile with clang, with the -Wno-address-of-packed-member. The warning should be gone with this patch.

ble_sm_gen_ediv and ble_sm_gen_master_id_rand took a simple pointer to
integers, but were being called with pointers to members of a packed
struct. This discarded the alignment information.

Not only did it produce an error with clang's -Wno-address-of-packed-member,
but it may also cause an error in a platform with alignment requirements.

The solution was to modify both procedures to take a pointer to the whole
structure instead of only the members.
jcarrano added a commit to jcarrano/RIOT that referenced this pull request Nov 29, 2018
Nimble contains a couple of casts that discard alignment information.
This causes a warning with clang's -Wno-address-of-packed-member.

A previous PR (RIOT-OS#10503) supressed that warning. This commit re-enables
them and provides a patch to fix the offending code.

The fix has been submitted upstream, see
apache/mynewt-nimble#252
Copy link
Copy Markdown
Contributor

@andrzej-kaczmarek andrzej-kaczmarek left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@andrzej-kaczmarek andrzej-kaczmarek merged commit 79301b9 into apache:master Dec 4, 2018
crest42 pushed a commit to crest42/RIOT that referenced this pull request Dec 18, 2018
Nimble contains a couple of casts that discard alignment information.
This causes a warning with clang's -Wno-address-of-packed-member.

A previous PR (RIOT-OS#10503) supressed that warning. This commit re-enables
them and provides a patch to fix the offending code.

The fix has been submitted upstream, see
apache/mynewt-nimble#252
BytesGalore pushed a commit to BytesGalore/RIOT that referenced this pull request Jan 29, 2019
Nimble contains a couple of casts that discard alignment information.
This causes a warning with clang's -Wno-address-of-packed-member.

A previous PR (RIOT-OS#10503) supressed that warning. This commit re-enables
them and provides a patch to fix the offending code.

The fix has been submitted upstream, see
apache/mynewt-nimble#252
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