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

drivers: can: shell: use shell_fprintf_normal instead of shell_fprintf #77165

Conversation

ndrs-pst
Copy link
Contributor

@ndrs-pst ndrs-pst commented Aug 16, 2024

Due to the introduction of shell_xxx_impl wrapper functions in PR #75340 and rename to shell_fprintf_xxx in PR #77192 we can minimize caller overhead by eliminating direct color parameter passing.

Copy link
Member

@henrikbrixandersen henrikbrixandersen left a comment

Choose a reason for hiding this comment

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

It seems wrong to call the _impl function directly. This is just a simple test, the overhead of calling the non-impl function does not matter.

What is the motivation for changing this?

@ndrs-pst
Copy link
Contributor Author

If the condition is to avoid calling _impl functions (due to the naming convention),
one alternative could be to rename the following functions:

  • shell_info_impl to shell_fprintf_info
  • shell_print_impl to shell_fprintf_normal
  • shell_warn_impl to shell_fprintf_warn
  • shell_error_impl to shell_fprintf_error

The short variants shell_info, shell_print, shell_warn, and shell_error
concatenate "\n" internally, which makes them unsuitable for cases where a newline is not desired.
If we were to remove the newline concatenation, it could affect a wide range of functions across the codebase (the "widetree" effect).


The motivation for this change stems from the discussion in PR #74652, which led to PR #75340.
So, it's not specific to can_shell.c initially, but I submitted this PR to gather feedback from other areas as well. 😅

@henrikbrixandersen
Copy link
Member

If the condition is to avoid calling _impl functions (due to the naming convention),
one alternative could be to rename the following functions:

shell_info_impl to shell_fprintf_info
shell_print_impl to shell_fprintf_normal
shell_warn_impl to shell_fprintf_warn
shell_error_impl to shell_fprintf_error

I think that would make for a better naming convention. In Zephyr, *_impl are usually associated with system call implementation functions, which should never be called directly.

@ndrs-pst
Copy link
Contributor Author

I think that would make for a better naming convention. In Zephyr, *_impl are usually associated with system call implementation functions, which should never be called directly.

Thank you for your feedback. I may propose a revision to the naming convention in a separate PR and will update this PR accordingly afterward. WDYT?

@henrikbrixandersen
Copy link
Member

I may propose a revision to the naming convention in a separate PR and will update this PR accordingly afterward. WDYT?

Sounds good. Thanks!

@henrikbrixandersen
Copy link
Member

Please rebase.

…intf`

Due to the introduction of `shell_xxx_impl` wrapper functions in
PR zephyrproject-rtos#75340 and rename to `shell_fprintf_xxx` in PR zephyrproject-rtos#77192 we can minimize
caller overhead by eliminating direct `color` parameter passing.

Signed-off-by: Pisit Sawangvonganan <[email protected]>
@ndrs-pst ndrs-pst force-pushed the pr_drivers_can_shell_use_shell_print_impl branch from eb6c0ce to ef7ed1c Compare September 10, 2024 02:06
@ndrs-pst ndrs-pst changed the title drivers: can: shell: use shell_print_impl instead of shell_fprintf drivers: can: shell: use shell_fprintf_normal instead of shell_fprintf Sep 10, 2024
@ndrs-pst
Copy link
Contributor Author

Addressed it. 👍

@carlescufi carlescufi merged commit ecbcb5b into zephyrproject-rtos:main Sep 10, 2024
25 checks passed
@ndrs-pst ndrs-pst deleted the pr_drivers_can_shell_use_shell_print_impl branch September 10, 2024 10:16
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.

6 participants