From c08feedcfdc14076b89f039ddc6d15f6067d773d Mon Sep 17 00:00:00 2001 From: anjiahao Date: Fri, 28 Jul 2023 20:26:39 +0800 Subject: [PATCH] ymodem:fix compile warnings rb_main.c:219:42: warning: 'snprintf' output may be truncated before the last format character [-Wformat-truncation=] 219 | snprintf(temp, PATH_MAX, "%s/%s", priv->foldname, Signed-off-by: anjiahao --- system/ymodem/rb_main.c | 4 ++-- system/ymodem/ymodem.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/system/ymodem/rb_main.c b/system/ymodem/rb_main.c index 41878eae1..1beb8c2a2 100644 --- a/system/ymodem/rb_main.c +++ b/system/ymodem/rb_main.c @@ -171,7 +171,7 @@ static int handler(FAR struct ymodem_ctx_s *ctx) if (ctx->packet_type == YMODEM_FILENAME_PACKET) { - char temp[PATH_MAX]; + char temp[PATH_MAX + 1]; FAR char *filename; if (priv->fd > 0) @@ -216,7 +216,7 @@ static int handler(FAR struct ymodem_ctx_s *ctx) if (priv->foldname != NULL) { - snprintf(temp, PATH_MAX, "%s/%s", priv->foldname, + snprintf(temp, sizeof(temp), "%s/%s", priv->foldname, filename); filename = temp; } diff --git a/system/ymodem/ymodem.c b/system/ymodem/ymodem.c index ca7e30ec9..1f8cf6ff6 100644 --- a/system/ymodem/ymodem.c +++ b/system/ymodem/ymodem.c @@ -231,7 +231,7 @@ recv_packet: if ((total_seq & 0xff) - 1 == ctx->header[1]) { ymodem_debug("recv_file: Received the previous packet that has" - "been received, continue %lu %u\n", total_seq, + "been received, continue %" PRIu32 " %u\n", total_seq, ctx->header[1]); ctx->header[0] = ACK; @@ -239,7 +239,7 @@ recv_packet: } else if ((total_seq & 0xff) != ctx->header[1]) { - ymodem_debug("recv_file: total seq error:%lu %u\n", total_seq, + ymodem_debug("recv_file: total seq error:%" PRIu32 " %u\n", total_seq, ctx->header[1]); ctx->header[0] = CRC; goto recv_packet;