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

Bluetooth: Host: Disable dangling pointer warning in le_adv_recv #48690

Conversation

stephanosio
Copy link
Member

This commit temporarily disables the dangling pointer warning
(-Wdangling-pointer) in the le_adv_recv function in order to allow
this file to build successfully with the GCC 12, which introduced this
warning.

A proper fix will be provided later as part of the GitHub issue
#48459.

Signed-off-by: Stephanos Ioannidis [email protected]

This commit temporarily disables the dangling pointer warning
(`-Wdangling-pointer`) in the `le_adv_recv` function in order to allow
this file to build successfully with the GCC 12, which introduced this
warning.

A proper fix will be provided later as part of the GitHub issue
zephyrproject-rtos#48459.

Signed-off-by: Stephanos Ioannidis <[email protected]>
#pragma GCC diagnostic ignored "-Wpragmas"
#pragma GCC diagnostic ignored "-Wdangling-pointer"
#endif

info->addr = &id_addr;
Copy link
Member

Choose a reason for hiding this comment

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

I may have missed the discussion leading to this particular fix, but why don't we just set the pointer to NULL after the SYS_SLIST_FOR_EACH_CONTAINER_SAFE(&scan_cbs, ...) loop on line 474? (and move the above line to right before that loop, since it seems we're setting the pointer unnecessarily early here).

Copy link
Member

Choose a reason for hiding this comment

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

Update: I read the referenced issue, and still think that the setting to NULL is a better initial fix (i.e. "option a") and then work on the allocation/lifetime as a follow up.

Copy link
Member Author

Choose a reason for hiding this comment

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

I may have missed the discussion leading to this particular fix

Please see #48459 (comment).

This is not intended to be a "fix," but only a temporary workaround to get it building on the upcoming Zephyr SDK 0.15.0 release with GCC 12.

I did not implement the "option a" because I wanted to keep this PR as less intrusive as possible so as to not introduce any regressions (i.e. are we completely sure that info->addr is not referenced by the caller and setting it to NULL would not result in any regressions)?

If you can provide a proper fix (either implementing "option a" or "option b") before the Zephyr SDK 0.15.0 is mainlined (likely in one or two weeks), then this PR can be closed.

Copy link
Member

@jhedberg jhedberg Aug 5, 2022

Choose a reason for hiding this comment

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

I did not implement the "option a" because I wanted to keep this PR as less intrusive as possible so as to not introduce any regressions (i.e. are we completely sure that info->addr is not referenced by the caller and setting it to NULL would not result in any regressions)?

Perceived intrusiveness is a subjective thing. The preprocessor stuff you add in this PR appears more intrusive to me than a one line var = NULL; addition. I don't quite get what you mean by your regression comment: if the calling function tried to access the the pointer it would be accessing invalid memory since the stack frame of the function that set it is no longer valid. Setting the pointer to NULL is therefore a better initial fix IMO.

Copy link
Member Author

Choose a reason for hiding this comment

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

@jhedberg Can you or one of the Bluetooth collaborators send a patch for that in the meantime then? I would prefer not to introduce any behavioural changes to this subsystem myself since I am not familiar enough with it.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

@jhedberg Thanks!

@stephanosio
Copy link
Member Author

#48727 supersedes this.

@stephanosio stephanosio closed this Aug 5, 2022
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