From 43c28c4456e4ad111eaf255bcbed09a8ff2680e4 Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Fri, 31 Dec 2021 21:52:10 +0800 Subject: [PATCH] net/usrsock: Fix the compile warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In file included from usrsock/usrsock_bind.c:32: usrsock/usrsock_bind.c: In function ‘usrsock_bind’: usrsock/usrsock_bind.c:183:13: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘ssize_t’ {aka ‘long int’} [-Wformat=] 183 | nwarn("usrsock_setup_request_callback failed: %d\n", ret); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~ | | | ssize_t {aka long int} usrsock/usrsock_bind.c:183:54: note: format string is defined here 183 | nwarn("usrsock_setup_request_callback failed: %d\n", ret); | ~^ | | | int | %ld CC: usrsock/usrsock_connect.c CC: usrsock/usrsock_dev.c In file included from usrsock/usrsock_dev.c:37: usrsock/usrsock_dev.c: In function ‘usrsockdev_handle_event’: usrsock/usrsock_dev.c:488:19: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘size_t’ {aka ‘long unsigned int’} [-Wformat=] 488 | nwarn("message too short, %d < %d.\n", len, sizeof(*hdr)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~ | | | size_t {aka long unsigned int} usrsock/usrsock_dev.c:488:40: note: format string is defined here 488 | nwarn("message too short, %d < %d.\n", len, sizeof(*hdr)); | ~^ | | | int | %ld In file included from usrsock/usrsock_dev.c:37: usrsock/usrsock_dev.c:488:19: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘long unsigned int’ [-Wformat=] 488 | nwarn("message too short, %d < %d.\n", len, sizeof(*hdr)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~ | | | long unsigned int usrsock/usrsock_dev.c:488:45: note: format string is defined here 488 | nwarn("message too short, %d < %d.\n", len, sizeof(*hdr)); | ~^ | | | int | %ld In file included from usrsock/usrsock_dev.c:37: usrsock/usrsock_dev.c: In function ‘usrsockdev_handle_datareq_response’: usrsock/usrsock_dev.c:657:13: warning: format ‘%d’ expects argument of type ‘int’, but argument 5 has type ‘size_t’ {aka ‘long unsigned int’} [-Wformat=] 657 | nwarn("%dth buffer not large enough (need: %d, have: %d).\n", | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ...... 660 | conn->resp.datain.iov[iovpos].iov_len); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | size_t {aka long unsigned int} usrsock/usrsock_dev.c:657:61: note: format string is defined here 657 | nwarn("%dth buffer not large enough (need: %d, have: %d).\n", | ~^ | | | int | %ld In file included from usrsock/usrsock_dev.c:37: usrsock/usrsock_dev.c:678:17: warning: format ‘%d’ expects argument of type ‘int’, but argument 5 has type ‘size_t’ {aka ‘long unsigned int’} [-Wformat=] 678 | nwarn("%dth buffer not large enough " | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ...... 682 | conn->resp.datain.iov[iovpos].iov_len); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | size_t {aka long unsigned int} usrsock/usrsock_dev.c:679:45: note: format string is defined here 679 | "(need: %" PRId32 ", have: %d).\n", | ~^ | | | int | %ld In file included from usrsock/usrsock_dev.c:37: usrsock/usrsock_dev.c: In function ‘usrsockdev_handle_req_response’: usrsock/usrsock_dev.c:745:13: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘size_t’ {aka ‘long unsigned int’} [-Wformat=] 745 | nwarn("message too short, %d < %d.\n", len, hdrlen); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~ | | | size_t {aka long unsigned int} usrsock/usrsock_dev.c:745:34: note: format string is defined here 745 | nwarn("message too short, %d < %d.\n", len, hdrlen); | ~^ | | | int | %ld In file included from usrsock/usrsock_dev.c:37: usrsock/usrsock_dev.c: In function ‘usrsockdev_write’: usrsock/usrsock_dev.c:858:17: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘size_t’ {aka ‘long unsigned int’} [-Wformat=] 858 | nwarn("message too short, %d < %d.\n", len, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~ | | | size_t {aka long unsigned int} usrsock/usrsock_dev.c:858:38: note: format string is defined here 858 | nwarn("message too short, %d < %d.\n", len, | ~^ | | | int | %ld In file included from usrsock/usrsock_dev.c:37: usrsock/usrsock_dev.c:858:17: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘long unsigned int’ [-Wformat=] 858 | nwarn("message too short, %d < %d.\n", len, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 859 | sizeof(struct usrsock_message_common_s)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long unsigned int usrsock/usrsock_dev.c:858:43: note: format string is defined here 858 | nwarn("message too short, %d < %d.\n", len, | ~^ | | | int | %ld CC: usrsock/usrsock_getpeername.c In file included from usrsock/usrsock_getpeername.c:32: usrsock/usrsock_getpeername.c: In function ‘usrsock_getpeername’: usrsock/usrsock_getpeername.c:190:13: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘ssize_t’ {aka ‘long int’} [-Wformat=] 190 | nwarn("usrsock_setup_request_callback failed: %d\n", ret); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~ | | | ssize_t {aka long int} usrsock/usrsock_getpeername.c:190:54: note: format string is defined here 190 | nwarn("usrsock_setup_request_callback failed: %d\n", ret); | ~^ | | | int | %ld CC: usrsock/usrsock_event.c CC: usrsock/usrsock_getsockname.c In file included from usrsock/usrsock_getsockname.c:32: usrsock/usrsock_getsockname.c: In function ‘usrsock_getsockname’: usrsock/usrsock_getsockname.c:190:13: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘ssize_t’ {aka ‘long int’} [-Wformat=] 190 | nwarn("usrsock_setup_request_callback failed: %d\n", ret); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~ | | | ssize_t {aka long int} usrsock/usrsock_getsockname.c:190:54: note: format string is defined here 190 | nwarn("usrsock_setup_request_callback failed: %d\n", ret); | ~^ | | | int | %ld CC: usrsock/usrsock_getsockopt.c CC: usrsock/usrsock_poll.c CC: usrsock/usrsock_recvmsg.c In file included from usrsock/usrsock_recvmsg.c:32: usrsock/usrsock_recvmsg.c: In function ‘usrsock_recvmsg’: usrsock/usrsock_recvmsg.c:321:21: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘ssize_t’ {aka ‘long int’} [-Wformat=] 321 | nwarn("usrsock_setup_request_callback failed: %d\n", ret); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~ | | | ssize_t {aka long int} usrsock/usrsock_recvmsg.c:321:62: note: format string is defined here 321 | nwarn("usrsock_setup_request_callback failed: %d\n", ret); | ~^ | | | int | %ld In file included from usrsock/usrsock_recvmsg.c:32: usrsock/usrsock_recvmsg.c:343:24: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘ssize_t’ {aka ‘long int’} [-Wformat=] 343 | nerr("net_timedwait errno: %d\n", ret); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~ | | | ssize_t {aka long int} usrsock/usrsock_recvmsg.c:343:47: note: format string is defined here 343 | nerr("net_timedwait errno: %d\n", ret); | ~^ | | | int | %ld In file included from usrsock/usrsock_recvmsg.c:32: usrsock/usrsock_recvmsg.c:384:17: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘ssize_t’ {aka ‘long int’} [-Wformat=] 384 | nwarn("usrsock_setup_request_callback failed: %d\n", ret); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~ | | | ssize_t {aka long int} usrsock/usrsock_recvmsg.c:384:58: note: format string is defined here 384 | nwarn("usrsock_setup_request_callback failed: %d\n", ret); | ~^ | | | int | %ld CC: usrsock/usrsock_sendmsg.c In file included from usrsock/usrsock_sendmsg.c:32: usrsock/usrsock_sendmsg.c: In function ‘usrsock_sendmsg’: usrsock/usrsock_sendmsg.c:302:21: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘ssize_t’ {aka ‘long int’} [-Wformat=] 302 | nwarn("usrsock_setup_request_callback failed: %d\n", ret); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~ | | | ssize_t {aka long int} usrsock/usrsock_sendmsg.c:302:62: note: format string is defined here 302 | nwarn("usrsock_setup_request_callback failed: %d\n", ret); | ~^ | | | int | %ld In file included from usrsock/usrsock_sendmsg.c:32: usrsock/usrsock_sendmsg.c:324:24: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘ssize_t’ {aka ‘long int’} [-Wformat=] 324 | nerr("net_timedwait errno: %d\n", ret); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~ | | | ssize_t {aka long int} usrsock/usrsock_sendmsg.c:324:47: note: format string is defined here 324 | nerr("net_timedwait errno: %d\n", ret); | ~^ | | | int | %ld In file included from usrsock/usrsock_sendmsg.c:32: usrsock/usrsock_sendmsg.c:364:17: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘ssize_t’ {aka ‘long int’} [-Wformat=] 364 | nwarn("usrsock_setup_request_callback failed: %d\n", ret); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~ | | | ssize_t {aka long int} usrsock/usrsock_sendmsg.c:364:58: note: format string is defined here 364 | nwarn("usrsock_setup_request_callback failed: %d\n", ret); | ~^ | | | int | %ld Signed-off-by: Xiang Xiao --- net/usrsock/usrsock_bind.c | 2 +- net/usrsock/usrsock_dev.c | 10 +++++----- net/usrsock/usrsock_getpeername.c | 2 +- net/usrsock/usrsock_getsockname.c | 2 +- net/usrsock/usrsock_getsockopt.c | 2 +- net/usrsock/usrsock_recvmsg.c | 6 +++--- net/usrsock/usrsock_sendmsg.c | 6 +++--- net/usrsock/usrsock_setsockopt.c | 2 +- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/net/usrsock/usrsock_bind.c b/net/usrsock/usrsock_bind.c index f6b2869384..6a15930b5d 100644 --- a/net/usrsock/usrsock_bind.c +++ b/net/usrsock/usrsock_bind.c @@ -154,7 +154,7 @@ int usrsock_bind(FAR struct socket *psock, { }; - ssize_t ret; + int ret; DEBUGASSERT(conn); diff --git a/net/usrsock/usrsock_dev.c b/net/usrsock/usrsock_dev.c index ad050ee32a..443386decf 100644 --- a/net/usrsock/usrsock_dev.c +++ b/net/usrsock/usrsock_dev.c @@ -485,7 +485,7 @@ static ssize_t usrsockdev_handle_event(FAR struct usrsockdev_s *dev, if (len < sizeof(*hdr)) { - nwarn("message too short, %d < %d.\n", len, sizeof(*hdr)); + nwarn("message too short, %zu < %zu.\n", len, sizeof(*hdr)); return -EINVAL; } @@ -654,7 +654,7 @@ usrsockdev_handle_datareq_response(FAR struct usrsockdev_s *dev, if (conn->resp.datain.iov[iovpos].iov_len < datahdr->valuelen) { - nwarn("%dth buffer not large enough (need: %d, have: %d).\n", + nwarn("%dth buffer not large enough (need: %d, have: %zu).\n", iovpos, datahdr->valuelen, conn->resp.datain.iov[iovpos].iov_len); @@ -676,7 +676,7 @@ usrsockdev_handle_datareq_response(FAR struct usrsockdev_s *dev, if (conn->resp.datain.iov[iovpos].iov_len < hdr->result) { nwarn("%dth buffer not large enough " - "(need: %" PRId32 ", have: %d).\n", + "(need: %" PRId32 ", have: %zu).\n", iovpos, hdr->result, conn->resp.datain.iov[iovpos].iov_len); @@ -742,7 +742,7 @@ static ssize_t usrsockdev_handle_req_response(FAR struct usrsockdev_s *dev, if (len < hdrlen) { - nwarn("message too short, %d < %d.\n", len, hdrlen); + nwarn("message too short, %zu < %u.\n", len, hdrlen); return -EINVAL; } @@ -855,7 +855,7 @@ static ssize_t usrsockdev_write(FAR struct file *filep, if (len < sizeof(struct usrsock_message_common_s)) { - nwarn("message too short, %d < %d.\n", len, + nwarn("message too short, %zu < %zu.\n", len, sizeof(struct usrsock_message_common_s)); ret = -EINVAL; diff --git a/net/usrsock/usrsock_getpeername.c b/net/usrsock/usrsock_getpeername.c index 7cc01bd171..3fafe929cd 100644 --- a/net/usrsock/usrsock_getpeername.c +++ b/net/usrsock/usrsock_getpeername.c @@ -162,8 +162,8 @@ int usrsock_getpeername(FAR struct socket *psock, }; struct iovec inbufs[1]; - ssize_t ret; socklen_t outaddrlen = 0; + int ret; net_lock(); diff --git a/net/usrsock/usrsock_getsockname.c b/net/usrsock/usrsock_getsockname.c index 1f61d7ba94..10f3f65f99 100644 --- a/net/usrsock/usrsock_getsockname.c +++ b/net/usrsock/usrsock_getsockname.c @@ -162,8 +162,8 @@ int usrsock_getsockname(FAR struct socket *psock, }; struct iovec inbufs[1]; - ssize_t ret; socklen_t outaddrlen = 0; + int ret; net_lock(); diff --git a/net/usrsock/usrsock_getsockopt.c b/net/usrsock/usrsock_getsockopt.c index 5126ca8011..3e23efeccf 100644 --- a/net/usrsock/usrsock_getsockopt.c +++ b/net/usrsock/usrsock_getsockopt.c @@ -178,7 +178,7 @@ int usrsock_getsockopt(FAR struct usrsock_conn_s *conn, }; struct iovec inbufs[1]; - ssize_t ret; + int ret; net_lock(); diff --git a/net/usrsock/usrsock_recvmsg.c b/net/usrsock/usrsock_recvmsg.c index d865742807..980e349330 100644 --- a/net/usrsock/usrsock_recvmsg.c +++ b/net/usrsock/usrsock_recvmsg.c @@ -318,7 +318,7 @@ ssize_t usrsock_recvmsg(FAR struct socket *psock, FAR struct msghdr *msg, USRSOCK_EVENT_REMOTE_CLOSED); if (ret < 0) { - nwarn("usrsock_setup_request_callback failed: %d\n", ret); + nwarn("usrsock_setup_request_callback failed: %zd\n", ret); goto errout_unlock; } @@ -340,7 +340,7 @@ ssize_t usrsock_recvmsg(FAR struct socket *psock, FAR struct msghdr *msg, } else { - nerr("net_timedwait errno: %d\n", ret); + nerr("net_timedwait errno: %zd\n", ret); DEBUGASSERT(false); } } @@ -381,7 +381,7 @@ ssize_t usrsock_recvmsg(FAR struct socket *psock, FAR struct msghdr *msg, USRSOCK_EVENT_ABORT | USRSOCK_EVENT_REQ_COMPLETE); if (ret < 0) { - nwarn("usrsock_setup_request_callback failed: %d\n", ret); + nwarn("usrsock_setup_request_callback failed: %zd\n", ret); goto errout_unlock; } diff --git a/net/usrsock/usrsock_sendmsg.c b/net/usrsock/usrsock_sendmsg.c index 8d9245a160..332817e38a 100644 --- a/net/usrsock/usrsock_sendmsg.c +++ b/net/usrsock/usrsock_sendmsg.c @@ -299,7 +299,7 @@ ssize_t usrsock_sendmsg(FAR struct socket *psock, USRSOCK_EVENT_REMOTE_CLOSED); if (ret < 0) { - nwarn("usrsock_setup_request_callback failed: %d\n", ret); + nwarn("usrsock_setup_request_callback failed: %zd\n", ret); goto errout_unlock; } @@ -321,7 +321,7 @@ ssize_t usrsock_sendmsg(FAR struct socket *psock, } else { - nerr("net_timedwait errno: %d\n", ret); + nerr("net_timedwait errno: %zd\n", ret); DEBUGASSERT(false); } } @@ -361,7 +361,7 @@ ssize_t usrsock_sendmsg(FAR struct socket *psock, USRSOCK_EVENT_REQ_COMPLETE); if (ret < 0) { - nwarn("usrsock_setup_request_callback failed: %d\n", ret); + nwarn("usrsock_setup_request_callback failed: %zd\n", ret); goto errout_unlock; } diff --git a/net/usrsock/usrsock_setsockopt.c b/net/usrsock/usrsock_setsockopt.c index dad69633ba..38788c5e7c 100644 --- a/net/usrsock/usrsock_setsockopt.c +++ b/net/usrsock/usrsock_setsockopt.c @@ -166,7 +166,7 @@ int usrsock_setsockopt(FAR struct usrsock_conn_s *conn, { }; - ssize_t ret; + int ret; DEBUGASSERT(conn);