Commit cf466df6 authored by Eric Engestrom's avatar Eric Engestrom

run: simplify filename handling

Compiler wasn't happy about strncpy() depending on the source's length and not
the target's, but this whole thing can be simplified by simply using asprintf()
(which is already used in this file, so no #include necessary).

run.c: In function ‘main._omp_fn.0’:
run.c:964:21: warning: ‘strncpy’ specified bound depends on the length of the source argument [-Wstringop-overflow=]
                     strncpy(out_filename, current_shader_name,
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                             strlen(current_shader_name) + 1);
                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Signed-off-by: Eric Engestrom's avatarEric Engestrom <eric.engestrom@intel.com>
Reviewed-by: Lionel Landwerlin's avatarLionel Landwerlin <lionel.g.landwerlin@intel.com>
parent 8d986c8c
......@@ -959,11 +959,8 @@ main(int argc, char **argv)
continue;
}
char *out_filename = malloc(strlen(current_shader_name) + 5);
strncpy(out_filename, current_shader_name,
strlen(current_shader_name) + 1);
out_filename = strcat(out_filename, ".bin");
char *out_filename = NULL;
asprintf(&out_filename, "%s.bin", current_shader_name);
fp = fopen(out_filename, "wb");
fprintf(stdout,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment