Skip to content

Commit 67c8ce8

Browse files
JiafeiPanJonyZhang7
authored andcommitted
usb: fix build warning for printing format
Use zu% format for size_t type. Use d% format for int type. Use u% format for uint32_t type. Signed-off-by: Jiafei Pan <Jiafei.Pan@nxp.com> Signed-off-by: Jony Zhang <jony.zhang@nxp.com>
1 parent 8ea7b11 commit 67c8ce8

File tree

10 files changed

+17
-18
lines changed

10 files changed

+17
-18
lines changed

samples/subsys/usb/legacy/audio_headphones_microphone/src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ static void data_received(const struct device *dev,
2929
return;
3030
}
3131

32-
LOG_DBG("Received %d data, buffer %p", size, buffer);
32+
LOG_DBG("Received %zu data, buffer %p", size, buffer);
3333

3434
/* Check if OUT device buffer can be used for IN device */
3535
if (size == usb_audio_get_in_frame_size(mic_dev)) {

samples/subsys/usb/legacy/audio_headset/src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ static void data_received(const struct device *dev,
2727
return;
2828
}
2929

30-
LOG_DBG("Received %d data, buffer %p", size, buffer);
30+
LOG_DBG("Received %zu data, buffer %p", size, buffer);
3131

3232
/* Check if the device OUT buffer can be used for input */
3333
if (size == usb_audio_get_in_frame_size(dev)) {

samples/subsys/usb/mass/src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ static void setup_disk(void)
174174
printk("End of files\n");
175175
break;
176176
}
177-
printk(" %c %u %s\n",
177+
printk(" %c %zu %s\n",
178178
(ent.type == FS_DIR_ENTRY_FILE) ? 'F' : 'D',
179179
ent.size,
180180
ent.name);

subsys/tracing/ctf/tracing_ctf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ void sys_trace_socket_connect_exit(int sock, int ret);
543543
void sys_trace_socket_listen_enter(int sock, int backlog);
544544
void sys_trace_socket_listen_exit(int sock, int ret);
545545
void sys_trace_socket_accept_enter(int sock);
546-
void sys_trace_socket_accept_exit(int sock, const struct sockaddr *addr, const uint32_t *addrlen,
546+
void sys_trace_socket_accept_exit(int sock, const struct sockaddr *addr, const size_t *addrlen,
547547
int ret);
548548
void sys_trace_socket_sendto_enter(int sock, int len, int flags, const struct sockaddr *dest_addr,
549549
uint32_t addrlen);

subsys/usb/device/class/audio/audio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -902,7 +902,7 @@ int usb_audio_send(const struct device *dev, struct net_buf *buffer,
902902
}
903903

904904
if (len > buffer->size) {
905-
LOG_ERR("Cannot send %d bytes, to much data", len);
905+
LOG_ERR("Cannot send %zu bytes, to much data", len);
906906
return -EINVAL;
907907
}
908908

subsys/usb/device/class/netusb/function_rndis.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,7 @@ static int rndis_send(struct net_pkt *pkt)
931931
size_t len = net_pkt_get_len(pkt);
932932
int ret;
933933

934-
LOG_DBG("send pkt %p len %u", pkt, len);
934+
LOG_DBG("send pkt %p len %zu", pkt, len);
935935

936936
if (rndis.media_status == RNDIS_OBJECT_ID_MEDIA_DISCONNECTED) {
937937
LOG_DBG("Media disconnected, drop pkt %p", pkt);

subsys/usb/device_next/class/loopback.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,12 @@ static int lb_request_handler(struct usbd_class_data *const c_data,
174174

175175
net_buf_unref(buf);
176176
if (err == -ECONNABORTED) {
177-
LOG_INF("Transfer ep 0x%02x, len %u cancelled", ep, len);
177+
LOG_INF("Transfer ep 0x%02x, len %zu cancelled", ep, len);
178178
} else if (err != 0) {
179-
LOG_ERR("Transfer ep 0x%02x, len %u failed", ep, len);
179+
LOG_ERR("Transfer ep 0x%02x, len %zu failed", ep, len);
180180
ret = err;
181181
} else {
182-
LOG_DBG("Transfer ep 0x%02x, len %u finished", ep, len);
182+
LOG_DBG("Transfer ep 0x%02x, len %zu finished", ep, len);
183183
}
184184

185185
if (!atomic_test_bit(&data->state, LB_FUNCTION_BULK_MANUAL)) {

subsys/usb/device_next/class/usbd_msc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,9 +440,9 @@ static void msc_process_write(struct msc_bot_ctx *ctx,
440440
tmp = scsi_write_data(lun, buf, len);
441441
__ASSERT(tmp <= len, "Processed more data than requested");
442442
if (tmp == 0) {
443-
LOG_WRN("SCSI handler didn't process %d bytes", len);
443+
LOG_WRN("SCSI handler didn't process %zu bytes", len);
444444
} else {
445-
LOG_DBG("SCSI processed %d out of %d bytes", tmp, len);
445+
LOG_DBG("SCSI processed %zu out of %zu bytes", tmp, len);
446446
}
447447

448448
ctx->csw.dCSWDataResidue -= tmp;

subsys/usb/device_next/class/usbd_uvc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,7 @@ static int uvc_get_vc_ctrl(const struct device *dev, struct net_buf *const buf,
981981
}
982982

983983
if (size < map->size) {
984-
LOG_WRN("Buffer too small (%u bytes) or unexpected size requested (%u bytes)",
984+
LOG_WRN("Buffer too small (%zu bytes) or unexpected size requested (%u bytes)",
985985
net_buf_tailroom(buf), setup->wLength);
986986
return -ENOTSUP;
987987
}
@@ -1985,7 +1985,7 @@ static int uvc_reset_transfer(const struct device *dev)
19851985
struct net_buf *buf;
19861986
int ret;
19871987

1988-
LOG_DBG("Stream restarted, terminating the transfer after %u bytes", data->vbuf_offset);
1988+
LOG_DBG("Stream restarted, terminating the transfer after %zu bytes", data->vbuf_offset);
19891989

19901990
buf = net_buf_alloc_len(&uvc_buf_pool, 0, K_NO_WAIT);
19911991
if (buf == NULL) {
@@ -2047,7 +2047,7 @@ static int uvc_flush_vbuf(const struct device *dev, struct video_buffer *const v
20472047
bi = (struct uvc_buf_info *)udc_get_buf_info(buf);
20482048
bi->udc.ep = uvc_get_bulk_in(dev);
20492049

2050-
LOG_DBG("Video buffer %p, offset %u/%u, size %u",
2050+
LOG_DBG("Video buffer %p, offset %zu/%u, size %d",
20512051
vbuf, data->vbuf_offset, vbuf->bytesused, buf->len);
20522052

20532053
/* End-of-Transfer condition */

subsys/usb/device_next/usbd_ch9.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ static void string_ascii7_to_utf16le(struct usbd_desc_node *const dn,
590590
ascii7_str = (uint8_t *)dn->ptr;
591591
}
592592

593-
LOG_DBG("wLength %u, bLength %u, tailroom %u",
593+
LOG_DBG("wLength %u, bLength %u, tailroom %zu",
594594
wLength, head.bLength, net_buf_tailroom(buf));
595595

596596
len = MIN(net_buf_tailroom(buf), MIN(head.bLength, wLength));
@@ -771,8 +771,7 @@ static int sreq_get_desc_bos(struct usbd_context *const uds_ctx,
771771

772772
desc_fill_bos_root(uds_ctx, &bos);
773773
len = MIN(net_buf_tailroom(buf), MIN(setup->wLength, bos.wTotalLength));
774-
775-
LOG_DBG("wLength %u, bLength %u, wTotalLength %u, tailroom %u",
774+
LOG_DBG("wLength %u, bLength %u, wTotalLength %u, tailroom %zu",
776775
setup->wLength, bos.bLength, bos.wTotalLength, net_buf_tailroom(buf));
777776

778777
net_buf_add_mem(buf, &bos, MIN(len, bos.bLength));
@@ -784,7 +783,7 @@ static int sreq_get_desc_bos(struct usbd_context *const uds_ctx,
784783

785784
SYS_DLIST_FOR_EACH_CONTAINER(&uds_ctx->descriptors, desc_nd, node) {
786785
if (desc_nd->bDescriptorType == USB_DESC_BOS) {
787-
LOG_DBG("bLength %u, len %u, tailroom %u",
786+
LOG_DBG("bLength %u, len %zu, tailroom %zu",
788787
desc_nd->bLength, len, net_buf_tailroom(buf));
789788
net_buf_add_mem(buf, desc_nd->ptr, MIN(len, desc_nd->bLength));
790789

0 commit comments

Comments
 (0)