Some newer toolchains defines asprintf with a must_check attribute, leading to warnings when compiling kwbimage. Let's handle OOM gracefully to get rid of the warnings. Signed-off-by: Ahmad Fatoum <ahmad@xxxxxx> --- scripts/kwbimage.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/scripts/kwbimage.c b/scripts/kwbimage.c index f9d052752d79..370c54c983b5 100644 --- a/scripts/kwbimage.c +++ b/scripts/kwbimage.c @@ -1006,6 +1006,7 @@ static int image_create_config_parse_oneline(char *line, char *configpath) { char *keyword, *saveptr; + int ret; keyword = strtok_r(line, " ", &saveptr); if (!strcmp(keyword, "VERSION")) { @@ -1056,10 +1057,16 @@ static int image_create_config_parse_oneline(char *line, int argi = 0; el->type = IMAGE_CFG_BINARY; - if (*value == '/') + if (*value == '/') { el->binary.file = strdup(value); - else - asprintf(&el->binary.file, "%s/%s", configpath, value); + } else { + ret = asprintf(&el->binary.file, "%s/%s", configpath, value); + if (ret < 0) { + fprintf(stderr, "Cannot allocate memory\n"); + return -1; + } + } + while (1) { value = strtok_r(NULL, " ", &saveptr); if (!value) -- 2.38.4