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

net: ip: tcp: use zu format specifier for size_t #49825

Closed
cfriedt opened this issue Sep 1, 2022 · 0 comments · Fixed by #49827
Closed

net: ip: tcp: use zu format specifier for size_t #49825

cfriedt opened this issue Sep 1, 2022 · 0 comments · Fixed by #49827
Assignees
Labels
area: Networking bug The issue is a bug, or the PR is fixing a bug

Comments

@cfriedt
Copy link
Member

cfriedt commented Sep 1, 2022

Describe the bug
Incorrect format specifiers cause warnings (escalated to errors in twister), breaking build.

To Reproduce
Steps to reproduce the behavior:

  1. enable logging, debug logging
  2. use twister to build something involving tcp
  3. See error

Expected behavior
Successfull build

Impact
Showstopper for build (of gsoc-2022-thrift project)

Logs and console output

FAILED: zephyr/subsys/net/ip/CMakeFiles/subsys__net__ip.dir/tcp.c.obj 
ccache /Users/cfriedt/zephyr-sdk-0.15.0/aarch64-zephyr-elf/bin/aarch64-zephyr-elf-gcc -DKERNEL -DMBEDTLS_CONFIG_FILE=\"config-tls-generic.h\" -DTC_RUNID=0c07d0be06c2c78439c63428eea8ea72 -D_FORTIFY_SOURCE-
In file included from /Users/cfriedt/Desktop/zephyrproject/zephyr/include/zephyr/logging/log.h:11,
                 from /Users/cfriedt/Desktop/zephyrproject/zephyr/subsys/net/ip/tcp.c:7:
/Users/cfriedt/Desktop/zephyrproject/zephyr/subsys/net/ip/tcp.c: In function 'tcp_queue_recv_data':
/Users/cfriedt/Desktop/zephyrproject/zephyr/include/zephyr/net/net_core.h:47:35: error: format '%i' expects argument of type 'int', but argument 4 has type 'size_t' {aka 'long unsigned int'} [-Werror=form
   47 | #define NET_DBG(fmt, ...) LOG_DBG("(%s): " fmt,                         \
      |                                   ^~~~~~~~
/Users/cfriedt/Desktop/zephyrproject/zephyr/include/zephyr/logging/log_core.h:248:42: note: in definition of macro 'Z_LOG2'
  248 |                 z_log_printf_arg_checker(__VA_ARGS__); \
      |                                          ^~~~~~~~~~~
/Users/cfriedt/Desktop/zephyrproject/zephyr/include/zephyr/logging/log.h:71:25: note: in expansion of macro 'Z_LOG'
   71 | #define LOG_DBG(...)    Z_LOG(LOG_LEVEL_DBG, __VA_ARGS__)
      |                         ^~~~~
/Users/cfriedt/Desktop/zephyrproject/zephyr/include/zephyr/net/net_core.h:47:27: note: in expansion of macro 'LOG_DBG'
   47 | #define NET_DBG(fmt, ...) LOG_DBG("(%s): " fmt,                         \
      |                           ^~~~~~~
/Users/cfriedt/Desktop/zephyrproject/zephyr/subsys/net/ip/tcp.c:1906:33: note: in expansion of macro 'NET_DBG'
 1906 |                                 NET_DBG("Adding at before queue, end_offset %i, pending_len %i",
      |                                 ^~~~~~~
/Users/cfriedt/Desktop/zephyrproject/zephyr/include/zephyr/net/net_core.h:47:35: error: format '%i' expects argument of type 'int', but argument 5 has type 'size_t' {aka 'long unsigned int'} [-Werror=form
   47 | #define NET_DBG(fmt, ...) LOG_DBG("(%s): " fmt,                         \
      |                                   ^~~~~~~~
/Users/cfriedt/Desktop/zephyrproject/zephyr/include/zephyr/logging/log_core.h:248:42: note: in definition of macro 'Z_LOG2'
  248 |                 z_log_printf_arg_checker(__VA_ARGS__); \
      |                                          ^~~~~~~~~~~
/Users/cfriedt/Desktop/zephyrproject/zephyr/include/zephyr/logging/log.h:71:25: note: in expansion of macro 'Z_LOG'
   71 | #define LOG_DBG(...)    Z_LOG(LOG_LEVEL_DBG, __VA_ARGS__)
      |                         ^~~~~
/Users/cfriedt/Desktop/zephyrproject/zephyr/include/zephyr/net/net_core.h:47:27: note: in expansion of macro 'LOG_DBG'
   47 | #define NET_DBG(fmt, ...) LOG_DBG("(%s): " fmt,                         \
      |                           ^~~~~~~
/Users/cfriedt/Desktop/zephyrproject/zephyr/subsys/net/ip/tcp.c:1937:41: note: in expansion of macro 'NET_DBG'
 1937 |                                         NET_DBG("Adding at end of queue, start %i, end %i, len %i",
      |                                         ^~~~~~~
cc1: all warnings being treated as errors
ccache /Users/cfriedt/zephyr-sdk-0.15.0/aarch64-zephyr-elf/bin/aarch64-zephyr-elf-gcc -DKERNEL -DMBEDTLS_CONFIG_FILE=\"config-tls-generic.h\" -DTC_RUNID=40bf9f388de434f779657b8dbb125fc8 -D_FORTIFY_SOURCE/
In file included from /Users/cfriedt/Desktop/zephyrproject/zephyr/include/zephyr/logging/log.h:11,
                 from /Users/cfriedt/Desktop/zephyrproject/zephyr/subsys/net/ip/tcp.c:7:
/Users/cfriedt/Desktop/zephyrproject/zephyr/subsys/net/ip/tcp.c: In function 'tcp_queue_recv_data':
/Users/cfriedt/Desktop/zephyrproject/zephyr/include/zephyr/net/net_core.h:47:35: error: format '%i' expects argument of type 'int', but argument 5 has type 'size_t' {aka 'long unsigned int'} [-Werror=form
   47 | #define NET_DBG(fmt, ...) LOG_DBG("(%s): " fmt,                         \
      |                                   ^~~~~~~~
/Users/cfriedt/Desktop/zephyrproject/zephyr/include/zephyr/logging/log_core.h:248:42: note: in definition of macro 'Z_LOG2'
  248 |                 z_log_printf_arg_checker(__VA_ARGS__); \
      |                                          ^~~~~~~~~~~
/Users/cfriedt/Desktop/zephyrproject/zephyr/include/zephyr/logging/log.h:71:25: note: in expansion of macro 'Z_LOG'
   71 | #define LOG_DBG(...)    Z_LOG(LOG_LEVEL_DBG, __VA_ARGS__)
      |                         ^~~~~
/Users/cfriedt/Desktop/zephyrproject/zephyr/include/zephyr/net/net_core.h:47:27: note: in expansion of macro 'LOG_DBG'
   47 | #define NET_DBG(fmt, ...) LOG_DBG("(%s): " fmt,                         \
      |                           ^~~~~~~
/Users/cfriedt/Desktop/zephyrproject/zephyr/subsys/net/ip/tcp.c:1937:41: note: in expansion of macro 'NET_DBG'
 1937 |                                         NET_DBG("Adding at end of queue, start %i, end %i, len %i",
      |                                         ^~~~~~~
cc1: all warnings being treated as errors
ninja: build stopped: subcommand failed.

Environment (please complete the following information):

  • OS: macOS
  • Toolchain: Zephyr SDK 0.15.0
  • Commit: 356960b

Additional context
https://github.com/zephyrproject-rtos/gsoc-2022-thrift

@cfriedt cfriedt added bug The issue is a bug, or the PR is fixing a bug area: Networking labels Sep 1, 2022
@cfriedt cfriedt self-assigned this Sep 1, 2022
cfriedt added a commit to cfriedt/zephyr that referenced this issue Sep 1, 2022
The `%i` format specifier is for `int` and is equivalent to
`%d` for printf formatting.

However, for `size_t`, the correct format specifier is `%zu`.

Fixes zephyrproject-rtos#49825

Signed-off-by: Christopher Friedt <cfriedt@fb.com>
@cfriedt cfriedt closed this as completed in c59178b Sep 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Networking bug The issue is a bug, or the PR is fixing a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant