From fd3b912d4e0d4cfe8f6a07a4238f5cd5c3d317f2 Mon Sep 17 00:00:00 2001 From: liuyucai Date: Fri, 18 Apr 2025 14:15:06 +0800 Subject: [PATCH 1/2] =?UTF-8?q?include=20=EF=BC=9Artdef.h=20:=20[=20Refine?= =?UTF-8?q?=20the=20annotation=20of=20RT=5FALIGN=20and=20RT=5FALIGN=5FDOWN?= =?UTF-8?q?=20]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This macro is vulnerable to non-2-byte alignments, but I assume that the macro definition was designed with an explicit use case of 2-byte alignments in mind. Therefore, I only modify the comment to remind the user. Solution: RT_ALIGN(size, align) ((size) + (align) - 1) / (align) * (align) RT_ALIGN_DOWN(size, align) (size) / (align) * (align) Here's what deepseek recommends more. Signed-off-by: Yucai Liu <1486344514@qq.com> --- include/rtdef.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/rtdef.h b/include/rtdef.h index 99ce5992d49..401a47be27c 100644 --- a/include/rtdef.h +++ b/include/rtdef.h @@ -251,6 +251,7 @@ typedef int (*init_fn_t)(void); * @def RT_ALIGN(size, align) * Return the most contiguous size aligned at specified width. RT_ALIGN(13, 4) * would return 16. + * @note align Must be an integer power of 2 or the result will be incorrect */ #define RT_ALIGN(size, align) (((size) + (align) - 1) & ~((align) - 1)) @@ -260,6 +261,7 @@ typedef int (*init_fn_t)(void); * @def RT_ALIGN_DOWN(size, align) * Return the down number of aligned at specified width. RT_ALIGN_DOWN(13, 4) * would return 12. + * @note align Must be an integer power of 2 or the result will be incorrect */ #define RT_ALIGN_DOWN(size, align) ((size) & ~((align) - 1)) From e84728afdad10dc800466e33bec9f0fe3a5be6ae Mon Sep 17 00:00:00 2001 From: liuyucai Date: Mon, 28 Apr 2025 14:56:31 +0800 Subject: [PATCH 2/2] :drivers\wlan\dev_wlan_mgnt.h: [ Fixing comments errors of RT_WLAN_EVT_SCAN_DONE and RT_WLAN_EVT_SCAN_REPORT ] These two comments are backwards Solution: Switch the original order Signed-off-by: Yucai Liu <1486344514@qq.com> --- components/drivers/wlan/dev_wlan_mgnt.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/drivers/wlan/dev_wlan_mgnt.h b/components/drivers/wlan/dev_wlan_mgnt.h index dc5b17e9946..bcba91c7bcd 100644 --- a/components/drivers/wlan/dev_wlan_mgnt.h +++ b/components/drivers/wlan/dev_wlan_mgnt.h @@ -60,8 +60,8 @@ extern "C" { typedef enum { RT_WLAN_EVT_READY = 0, /* connect and prot is ok, You can send data*/ - RT_WLAN_EVT_SCAN_DONE, /* Scan a info */ - RT_WLAN_EVT_SCAN_REPORT, /* Scan end */ + RT_WLAN_EVT_SCAN_DONE, /* Scan end */ + RT_WLAN_EVT_SCAN_REPORT, /* Scan a info */ RT_WLAN_EVT_STA_CONNECTED, /* connect success */ RT_WLAN_EVT_STA_CONNECTED_FAIL, /* connection failed */ RT_WLAN_EVT_STA_DISCONNECTED, /* disconnect */