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 <anjiahao@xiaomi.com>
diff --git a/system/ymodem/rb_main.c b/system/ymodem/rb_main.c
index 41878ea..1beb8c2 100644
--- a/system/ymodem/rb_main.c
+++ b/system/ymodem/rb_main.c
@@ -171,7 +171,7 @@
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 @@
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 ca7e30e..1f8cf6f 100644
--- a/system/ymodem/ymodem.c
+++ b/system/ymodem/ymodem.c
@@ -231,7 +231,7 @@
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 @@
}
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;