avoid GCC -O2 warning stringop-truncation

Signed-off-by: Nuno Gonçalves <nunojpg@gmail.com>
This commit is contained in:
Nuno Gonçalves
2024-01-16 22:25:38 +00:00
parent 909c7f00be
commit c38bd96aaf
2 changed files with 8 additions and 6 deletions

View File

@@ -216,11 +216,12 @@ static esp_err_t esp_rmaker_scenes_parse_info_and_flags(jparse_ctx_t *jctx, char
*info = NULL;
}
if (strlen(_info) > 0) {
int len = strlen(_info);
if (len > 0) {
/* +1 for NULL termination */
*info = (char *)MEM_CALLOC_EXTRAM(1, strlen(_info) + 1);
*info = (char *)MEM_CALLOC_EXTRAM(1, len + 1);
if (*info) {
strncpy(*info, _info, strlen(_info));
memcpy(*info, _info, len + 1);
}
}
}

View File

@@ -628,11 +628,12 @@ static esp_err_t esp_rmaker_schedule_parse_info_and_flags(jparse_ctx_t *jctx, ch
*info = NULL;
}
if (strlen(_info) > 0) {
int len = strlen(_info);
if (len > 0) {
/* +1 for NULL termination */
*info = (char *)MEM_CALLOC_EXTRAM(1, strlen(_info) + 1);
*info = (char *)MEM_CALLOC_EXTRAM(1, len + 1);
if (*info) {
strncpy(*info, _info, strlen(_info));
memcpy(*info, _info, len + 1);
}
}
}