net/usrsock: Fix the compile warning

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 <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2021-12-31 21:52:10 +08:00 committed by Xiang Xiao
parent 4e595a3fde
commit 43c28c4456
8 changed files with 16 additions and 16 deletions

View File

@ -154,7 +154,7 @@ int usrsock_bind(FAR struct socket *psock,
{
};
ssize_t ret;
int ret;
DEBUGASSERT(conn);

View File

@ -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;

View File

@ -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();

View File

@ -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();

View File

@ -178,7 +178,7 @@ int usrsock_getsockopt(FAR struct usrsock_conn_s *conn,
};
struct iovec inbufs[1];
ssize_t ret;
int ret;
net_lock();

View File

@ -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;
}

View File

@ -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;
}

View File

@ -166,7 +166,7 @@ int usrsock_setsockopt(FAR struct usrsock_conn_s *conn,
{
};
ssize_t ret;
int ret;
DEBUGASSERT(conn);