Maybe set out_filename = NULL (might not be initialized on Linux by default, according to manpage).
Either way :

Reviewed-by: Lionel Landwerlin <[email protected]>

On 10/08/18 13:21, Eric Engestrom wrote:
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 <[email protected]>
---
  run.c | 7 ++-----
  1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/run.c b/run.c
index 200c0f4d6ffb1a2be467..43f1bf5bdd5f160e86fd 100644
--- a/run.c
+++ b/run.c
@@ -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;
+                    asprintf(&out_filename, "%s.bin", current_shader_name);
fp = fopen(out_filename, "wb");
                      fprintf(stdout,


_______________________________________________
mesa-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to