summaryrefslogtreecommitdiff
path: root/src/class
diff options
context:
space:
mode:
authorhathach <[email protected]>2025-11-05 15:31:02 +0700
committerhathach <[email protected]>2025-11-05 17:34:27 +0700
commit1f04fe7924e8777c1583323171c0e1cabcb29062 (patch)
treeb619bbd1b1c002132c4b810d651abfe47b19d9bd /src/class
parent8979af34c0e5b97520070bcfdffe5280de9ac24c (diff)
added .clang-format
fix more alerts disable IAR CStat since pvs-studio check is better integrated with clion
Diffstat (limited to 'src/class')
-rw-r--r--src/class/mtp/mtp.h14
-rw-r--r--src/class/mtp/mtp_device.h10
-rw-r--r--src/class/video/video.h10
3 files changed, 18 insertions, 16 deletions
diff --git a/src/class/mtp/mtp.h b/src/class/mtp/mtp.h
index 40b6dd8b0..236cf98e0 100644
--- a/src/class/mtp/mtp.h
+++ b/src/class/mtp/mtp.h
@@ -799,18 +799,18 @@ TU_ATTR_ALWAYS_INLINE static inline uint32_t mtp_container_add_array(mtp_contain
TU_ATTR_ALWAYS_INLINE static inline uint32_t mtp_container_add_string(mtp_container_info_t* p_container, uint16_t* utf16) {
uint8_t count = 0;
- while (utf16[count]) {
+ while (utf16[count] != 0u) {
count++;
}
- const uint32_t added_len = 1u + 2u * count;
+ const uint32_t added_len = 1u + (uint32_t) count * 2u;
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);
*buf++ = count;
p_container->header->len++;
- memcpy(buf, utf16, 2 * count);
- p_container->header->len += 2 * count;
+ memcpy(buf, utf16, 2u * (uint32_t) count);
+ p_container->header->len += 2u * count;
return added_len;
}
@@ -824,7 +824,7 @@ TU_ATTR_ALWAYS_INLINE static inline uint32_t mtp_container_add_cstring(mtp_conta
// empty string (null only): single zero byte
*buf = 0;
p_container->header->len++;
- return 1;
+ return 1u;
} else {
*buf++ = len;
p_container->header->len++;
@@ -875,8 +875,8 @@ 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);
+ size_t nchars = *buf++;
+ memcpy(utf16, buf, 2u * nchars);
return 1u + 2u * nchars;
}
diff --git a/src/class/mtp/mtp_device.h b/src/class/mtp/mtp_device.h
index 397fbbbce..a33f1dc08 100644
--- a/src/class/mtp/mtp_device.h
+++ b/src/class/mtp/mtp_device.h
@@ -53,12 +53,14 @@ typedef struct {
typedef struct {
uint8_t idx;
uint8_t stage; // control stage
- uint32_t session_id;
- const tusb_control_request_t* request;
// buffer for data stage
- uint8_t* buf;
uint16_t bufsize;
+ uint8_t* buf;
+
+ const tusb_control_request_t* request;
+
+ uint32_t session_id;
} tud_mtp_request_cb_data_t;
// Number of supported operations, events, device properties, capture formats, playback formats
@@ -78,7 +80,7 @@ typedef struct {
/* string fields will be added using append function */ \
}
-typedef MTP_DEVICE_INFO_STRUCT(
+typedef MTP_DEVICE_INFO_STRUCT( //-V2586 [MISRA-C-18.7] Flexible array members should not be declared
sizeof(CFG_TUD_MTP_DEVICEINFO_EXTENSIONS), TU_ARGS_NUM(CFG_TUD_MTP_DEVICEINFO_SUPPORTED_OPERATIONS),
TU_ARGS_NUM(CFG_TUD_MTP_DEVICEINFO_SUPPORTED_EVENTS), TU_ARGS_NUM(CFG_TUD_MTP_DEVICEINFO_SUPPORTED_DEVICE_PROPERTIES),
TU_ARGS_NUM(CFG_TUD_MTP_DEVICEINFO_CAPTURE_FORMATS), TU_ARGS_NUM(CFG_TUD_MTP_DEVICEINFO_PLAYBACK_FORMATS)
diff --git a/src/class/video/video.h b/src/class/video/video.h
index f348e187b..5bdf4b840 100644
--- a/src/class/video/video.h
+++ b/src/class/video/video.h
@@ -219,11 +219,11 @@ typedef enum {
uint8_t baInterfaceNr[_nitf]; \
}
-typedef tusb_desc_video_control_header_nitf_t() tusb_desc_video_control_header_t;
-typedef tusb_desc_video_control_header_nitf_t(1) tusb_desc_video_control_header_1itf_t;
-typedef tusb_desc_video_control_header_nitf_t(2) tusb_desc_video_control_header_2itf_t;
-typedef tusb_desc_video_control_header_nitf_t(3) tusb_desc_video_control_header_3itf_t;
-typedef tusb_desc_video_control_header_nitf_t(4) tusb_desc_video_control_header_4itf_t;
+typedef tusb_desc_video_control_header_nitf_t() tusb_desc_video_control_header_t; //-V2586 incorrectly detected as flexible array
+typedef tusb_desc_video_control_header_nitf_t(1) tusb_desc_video_control_header_1itf_t; //-V2586 incorrectly detected as flexible array
+typedef tusb_desc_video_control_header_nitf_t(2) tusb_desc_video_control_header_2itf_t; //-V2586 incorrectly detected as flexible array
+typedef tusb_desc_video_control_header_nitf_t(3) tusb_desc_video_control_header_3itf_t; //-V2586 incorrectly detected as flexible array
+typedef tusb_desc_video_control_header_nitf_t(4) tusb_desc_video_control_header_4itf_t; //-V2586 incorrectly detected as flexible array
typedef struct TU_ATTR_PACKED {
uint8_t bLength;