Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
drivers: uart: samd0: add missing .configure API functionality #23234
drivers: uart: samd0: add missing .configure API functionality #23234
Changes from all commits
0bb40e4
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
jw - Is it worth considering a way to accomplish this task without using
memcpy()
? I ask because I am curious about it from a secure coding perspective atm. Can this use of memcpy introduce a vulnerability? Please see uart_nrfx_uart.c and uart_ns16550.c for example implementations.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.
In choosing the
memcpy()
I was aiming for making absolutely sure that the implementation passes relevant tests which currently usememcmp()
to establish whether the set and retrievedstruct uart_config
's match. Doing things the way uart_nrfx_uart.c or uart_ns16550.c do it can potentially introduce a corner case where the test won't pass because of potential content of padding in the struct which won't be carried across withoutmemcpy()
.I guess the proper thing to do would be to edit the tests to use comparison of individual struct member variables instead of
memcmp()
, but I wanted to avoid doing changes not related to the work I'm doing.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.
Ah that makes sense, thanks for clarifying! I am learning more with your help.
I wonder if you might want to add the cast to void in anticipation of the MISRA-C coding guidelines currently in discussion, namely regarding memcpy -->
(void) memcpy()
(see #18344). Adding @ceolin in case he wants to share thoughts hereThere 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.
As long as the copy size is static (i.e.
sizeof(dev_data->config_cache)
), that is highly unlikely.As for the
out_cfg
pointer checking, that is a whole another issue.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.
Enforcement of MISRA-C, especially arguably ridiculous ones like
(void)func()
is a no-go for now IIRC.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.
Hi @jenmwms, regarding MISRA, it is not sepcific to
memcpy
. The rule says that we should check all return values from non-void functions. It happens, that memcpy() return is quite useless, so we just explicitly ignore it casting to void.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.
@stephanosio
Do you mean the checking in function or in the test. In short, is there any other changes I should make to this PR?
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.
@KubaFYI As far as my comments are concerned, no changes necessary in this PR.
I was simply alluding that we can go very far with advanced security checks and functional safety rules; but, given that the current Zephyr codebase is really not ready for compliance, I see no reason to enforce them in this particular PR.