From 54bef649ea14d293128545f24c9db2594197a327 Mon Sep 17 00:00:00 2001 From: gaohedong Date: Mon, 7 Jul 2025 22:41:19 +0800 Subject: [PATCH] net/ptpd: fix compile warning issue In some scenarios, dynamic memory allocation is not allowed, so it is modified to a static allocation method. Signed-off-by: gaohedong --- netutils/ptpd/ptpd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/netutils/ptpd/ptpd.c b/netutils/ptpd/ptpd.c index 3193ee33e..f85619093 100644 --- a/netutils/ptpd/ptpd.c +++ b/netutils/ptpd/ptpd.c @@ -758,11 +758,13 @@ static int ptp_sendmsg(FAR struct ptp_state_s *state, FAR const void *buf, 0x01, 0x80, 0xc2, 0x00, 0x00, 0x0e }; - char raw[sizeof(struct ether_header) + buflen]; + char raw[sizeof(struct ether_header) + sizeof(struct ptp_announce_s)]; FAR struct ether_header *header; struct msghdr msg; struct iovec iov; + DEBUGASSERT(sizeof(struct ptp_announce_s) >= buflen); + header = (FAR struct ether_header *)&raw; memcpy(header->ether_dhost, ptp_multicast_mac, ETHER_ADDR_LEN); netlib_getmacaddr(state->config->interface, header->ether_shost);