Skip to content

Commit

Permalink
Merge branch 'bugfix/stringop_truncation_warnings' into 'master'
Browse files Browse the repository at this point in the history
Avoid GCC -O2 warning stringop-truncation

See merge request app-frameworks/esp-rainmaker!474
  • Loading branch information
shahpiyushv committed Sep 9, 2024
2 parents ef22ee8 + c38bd96 commit 19c78e0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions components/esp_rainmaker/src/core/esp_rmaker_scenes.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions components/esp_rainmaker/src/core/esp_rmaker_schedule.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down

0 comments on commit 19c78e0

Please sign in to comment.