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>
This commit is contained in:
anjiahao 2023-07-28 20:26:39 +08:00 committed by Xiang Xiao
parent 55b0d4a110
commit c08feedcfd
2 changed files with 4 additions and 4 deletions

View File

@ -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;
}

View File

@ -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;