From 1ca4ed2015432283aa9999580f86a8d49d960e07 Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Mon, 23 Sep 2019 17:24:50 +0300 Subject: [PATCH] clients: fix len-string formatting All these have the printf format string wrong. "%*s" sets the field width but does not limit the string to len bytes. You need to set precision instead to limit to len bytes: "%.*s". Found by grepping, after wondering why my WIP prints printed garbage at the end. Signed-off-by: Pekka Paalanen --- clients/nested-client.c | 4 ++-- clients/simple-dmabuf-egl.c | 4 ++-- clients/simple-egl.c | 4 ++-- clients/subsurfaces.c | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/clients/nested-client.c b/clients/nested-client.c index 70bb4d1b..9ef338bb 100644 --- a/clients/nested-client.c +++ b/clients/nested-client.c @@ -81,7 +81,7 @@ create_shader(const char *source, GLenum shader_type) char log[1000]; GLsizei len; glGetShaderInfoLog(shader, 1000, &len, log); - fprintf(stderr, "Error: compiling %s: %*s\n", + fprintf(stderr, "Error: compiling %s: %.*s\n", shader_type == GL_VERTEX_SHADER ? "vertex" : "fragment", len, log); return 0; @@ -111,7 +111,7 @@ create_program(struct nested_client *client, char log[1000]; GLsizei len; glGetProgramInfoLog(client->program, 1000, &len, log); - fprintf(stderr, "Error: linking:\n%*s\n", len, log); + fprintf(stderr, "Error: linking:\n%.*s\n", len, log); exit(1); } diff --git a/clients/simple-dmabuf-egl.c b/clients/simple-dmabuf-egl.c index 13b00191..35a2d043 100644 --- a/clients/simple-dmabuf-egl.c +++ b/clients/simple-dmabuf-egl.c @@ -546,7 +546,7 @@ create_shader(const char *source, GLenum shader_type) char log[1000]; GLsizei len; glGetShaderInfoLog(shader, 1000, &len, log); - fprintf(stderr, "Error: compiling %s: %*s\n", + fprintf(stderr, "Error: compiling %s: %.*s\n", shader_type == GL_VERTEX_SHADER ? "vertex" : "fragment", len, log); return 0; @@ -570,7 +570,7 @@ create_and_link_program(GLuint vert, GLuint frag) char log[1000]; GLsizei len; glGetProgramInfoLog(program, 1000, &len, log); - fprintf(stderr, "Error: linking:\n%*s\n", len, log); + fprintf(stderr, "Error: linking:\n%.*s\n", len, log); return 0; } diff --git a/clients/simple-egl.c b/clients/simple-egl.c index 2a23166e..cd7408e9 100644 --- a/clients/simple-egl.c +++ b/clients/simple-egl.c @@ -243,7 +243,7 @@ create_shader(struct window *window, const char *source, GLenum shader_type) char log[1000]; GLsizei len; glGetShaderInfoLog(shader, 1000, &len, log); - fprintf(stderr, "Error: compiling %s: %*s\n", + fprintf(stderr, "Error: compiling %s: %.*s\n", shader_type == GL_VERTEX_SHADER ? "vertex" : "fragment", len, log); exit(1); @@ -272,7 +272,7 @@ init_gl(struct window *window) char log[1000]; GLsizei len; glGetProgramInfoLog(program, 1000, &len, log); - fprintf(stderr, "Error: linking:\n%*s\n", len, log); + fprintf(stderr, "Error: linking:\n%.*s\n", len, log); exit(1); } diff --git a/clients/subsurfaces.c b/clients/subsurfaces.c index 0e4e52b0..79f7ade9 100644 --- a/clients/subsurfaces.c +++ b/clients/subsurfaces.c @@ -296,7 +296,7 @@ create_shader(const char *source, GLenum shader_type) char log[1000]; GLsizei len; glGetShaderInfoLog(shader, 1000, &len, log); - fprintf(stderr, "Error: compiling %s: %*s\n", + fprintf(stderr, "Error: compiling %s: %.*s\n", shader_type == GL_VERTEX_SHADER ? "vertex" : "fragment", len, log); exit(1); @@ -325,7 +325,7 @@ triangle_init_gl(struct triangle_gl_state *trigl) char log[1000]; GLsizei len; glGetProgramInfoLog(program, 1000, &len, log); - fprintf(stderr, "Error: linking:\n%*s\n", len, log); + fprintf(stderr, "Error: linking:\n%.*s\n", len, log); exit(1); }