This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 58bd950e6dcb8d8bec6eb27c70a05d52551b2cb6 Author: liwenxiang1 <[email protected]> AuthorDate: Thu Jun 19 21:53:24 2025 +0800 drivers/timers/arch_rtc: copy struct tm with memcpy() up_rtc_getdatetime() and up_rtc_getdatetime_with_subseconds() copied the struct tm part of struct rtc_time through a cast pointer, which GCC reports when strict aliasing is enabled: arch_rtc.c:180:19: [-Wstrict-aliasing] 180 | *tp = *((FAR struct tm *)&rtctime); Copy it with memcpy() instead. Signed-off-by: liwenxiang1 <[email protected]> --- drivers/timers/arch_rtc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/timers/arch_rtc.c b/drivers/timers/arch_rtc.c index 46f7a1ec479..08dd31102af 100644 --- a/drivers/timers/arch_rtc.c +++ b/drivers/timers/arch_rtc.c @@ -26,6 +26,8 @@ #include <nuttx/config.h> +#include <string.h> + #include <nuttx/arch.h> #include <nuttx/timers/arch_rtc.h> @@ -177,7 +179,7 @@ int weak_function up_rtc_getdatetime(FAR struct tm *tp) ret = g_rtc_lower->ops->rdtime(g_rtc_lower, &rtctime); if (ret == 0) { - *tp = *((FAR struct tm *)&rtctime); + memcpy(tp, &rtctime, sizeof(struct tm)); } } @@ -222,7 +224,7 @@ int weak_function up_rtc_getdatetime_with_subseconds(FAR struct tm *tp, ret = g_rtc_lower->ops->rdtime(g_rtc_lower, &rtctime); if (ret == 0) { - *tp = *((FAR struct tm *)&rtctime); + memcpy(tp, &rtctime, sizeof(struct tm)); *nsec = rtctime.tm_nsec; } }
