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

Mixed usage of signed/unsigned integer by the logging subsystem #34772

Closed
gmarull opened this issue May 3, 2021 · 2 comments
Closed

Mixed usage of signed/unsigned integer by the logging subsystem #34772

gmarull opened this issue May 3, 2021 · 2 comments
Assignees
Labels
area: Logging bug The issue is a bug, or the PR is fixing a bug priority: high High impact/importance bug

Comments

@gmarull
Copy link
Member

gmarull commented May 3, 2021

Describe the bug

If -Wextra is enabled on an application using the logging subsystem a few compilers warnings related to signed/unsigned comparisons are reported

To Reproduce
Steps to reproduce the behavior:

  1. Take any application that makes uses of the logging subsystem, e.g. LOG_ERR(...).
  2. Enable -Wextra, target_compile_options(app PRIVATE -Wextra)
  3. Observe reported warnings

Expected behavior
I expect that logging subsystem makes consistent usage of signed/unsigned integers

Impact
-Wextra may be useful in applications that want to enforce stricter rules (e.g. MISRA)

Logs and console output

zephyr/include/logging/log_msg2.h:297:39: warning: operand of ?: changes signedness from 'int' to 'unsigned int' due to unsignedness of other operand [-Wsign-compare]
  297 |   CBPRINTF_STATIC_PACKAGE(_msg->data, _plen, _plen, \
zephyr/include/sys/cbprintf_internal.h:230:19: warning: comparison of integer expressions of different signedness: 'int' and 'size_t' {aka 'unsigned int'} [-Wsign-compare]
  230 |  if (_buf && _idx < _max) { \
zephyr/include/sys/cbprintf_internal.h:320:22: warning: comparison of integer expressions of different signedness: 'int' and 'size_t' {aka 'unsigned int'} [-Wsign-compare]
  320 |  _outlen = (_pkg_len > _pmax) ? -ENOSPC : _pkg_len; \

Environment (please complete the following information):

  • OS: Linux
  • Toolchain Zephyr SDK 0.12.4
  • Commit SHA or Version used 5d29096

Additional context
Add any other context about the problem here.

@gmarull gmarull added bug The issue is a bug, or the PR is fixing a bug area: Logging labels May 3, 2021
@galak galak added the priority: high High impact/importance bug label May 4, 2021
@nordic-krch
Copy link
Contributor

I don't see it on master anymore. Fixed by #34697. @gmarull can you confirm?

@gmarull
Copy link
Member Author

gmarull commented May 6, 2021

@nordic-krch seems fixed after a west update, thanks

@gmarull gmarull closed this as completed May 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Logging bug The issue is a bug, or the PR is fixing a bug priority: high High impact/importance bug
Projects
None yet
Development

No branches or pull requests

3 participants