summaryrefslogtreecommitdiff
path: root/src/class/mtp
diff options
context:
space:
mode:
authorhathach <[email protected]>2025-09-26 10:06:32 +0700
committerhathach <[email protected]>2025-09-26 10:06:32 +0700
commite4f7fcf7ec4239aff6193a8d71cd0e8ce94024dd (patch)
tree4049095bab182700ce49894f068b50d9790dbbaf /src/class/mtp
parent34be38db190c9fb8ca5f6c1db8bab33566e397cb (diff)
fix compile warnings
Diffstat (limited to 'src/class/mtp')
-rw-r--r--src/class/mtp/mtp.h11
-rw-r--r--src/class/mtp/mtp_device.c4
2 files changed, 6 insertions, 9 deletions
diff --git a/src/class/mtp/mtp.h b/src/class/mtp/mtp.h
index 15cf1bfc6..073e6c470 100644
--- a/src/class/mtp/mtp.h
+++ b/src/class/mtp/mtp.h
@@ -675,10 +675,7 @@ TU_VERIFY_STATIC(sizeof(mtp_container_command_t) == 32, "size is not correct");
// PTP/MTP Generic container
typedef struct TU_ATTR_PACKED {
mtp_container_header_t header;
- // union {
- uint32_t data[(CFG_TUD_MTP_EP_BUFSIZE - sizeof(mtp_container_header_t)) / sizeof(uint32_t)];
- // uint8_t data[CFG_TUD_MTP_EP_BUFSIZE - sizeof(mtp_container_header_t)];
- // };
+ uint8_t payload[(CFG_TUD_MTP_EP_BUFSIZE - sizeof(mtp_container_header_t))];
} mtp_generic_container_t;
typedef struct {
@@ -823,7 +820,7 @@ TU_ATTR_ALWAYS_INLINE static inline uint32_t mtp_container_add_string(mtp_contai
while (utf16[count]) {
count++;
}
- const uint32_t added_len = 1 + 2 * count;
+ const uint32_t added_len = 1u + 2u * count;
TU_ASSERT(p_container->header->len + added_len < CFG_TUD_MTP_EP_BUFSIZE, 0);
uint8_t* buf = p_container->payload + p_container->header->len - sizeof(mtp_container_header_t);
@@ -856,7 +853,7 @@ TU_ATTR_ALWAYS_INLINE static inline uint32_t mtp_container_add_cstring(mtp_conta
buf += 2;
p_container->header->len += 2;
}
- return 1 + 2 * len;
+ return 1u + 2u * len;
}
}
@@ -898,7 +895,7 @@ TU_ATTR_ALWAYS_INLINE static inline uint32_t mtp_container_add_auint32(mtp_conta
TU_ATTR_ALWAYS_INLINE static inline uint32_t mtp_container_get_string(uint8_t* buf, uint16_t utf16[]) {
uint8_t nchars = *buf++;
memcpy(utf16, buf, 2 * nchars);
- return 1 + nchars * 2;
+ return 1u + 2u * nchars;
}
#ifdef __cplusplus
diff --git a/src/class/mtp/mtp_device.c b/src/class/mtp/mtp_device.c
index 6438fd2d6..61b1c9613 100644
--- a/src/class/mtp/mtp_device.c
+++ b/src/class/mtp/mtp_device.c
@@ -267,7 +267,7 @@ static bool mtpd_data_xfer(mtp_container_info_t* p_container, uint8_t ep_addr) {
TU_ASSERT(p_mtp->phase == MTP_PHASE_DATA);
}
- const uint16_t xact_len = tu_min32(p_mtp->total_len - p_mtp->xferred_len, CFG_TUD_MTP_EP_BUFSIZE);
+ const uint16_t xact_len = tu_min16((uint16_t) (p_mtp->total_len - p_mtp->xferred_len), CFG_TUD_MTP_EP_BUFSIZE);
if (xact_len) {
// already transferred all bytes in header's length. Application make an unnecessary extra call
TU_ASSERT(usbd_edpt_xfer(p_mtp->rhport, ep_addr, _mtpd_epbuf.buf, xact_len));
@@ -309,7 +309,7 @@ bool mtpd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t
const mtp_container_info_t headered_packet = {
.header = &p_container->header,
- .payload32 = p_container->data,
+ .payload = p_container->payload,
.payload_bytes = CFG_TUD_MTP_EP_BUFSIZE - sizeof(mtp_container_header_t)
};