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 <pekka.paalanen@collabora.com>
dev
Pekka Paalanen 5 years ago
parent e62f276a21
commit 1ca4ed2015
  1. 4
      clients/nested-client.c
  2. 4
      clients/simple-dmabuf-egl.c
  3. 4
      clients/simple-egl.c
  4. 4
      clients/subsurfaces.c

@ -81,7 +81,7 @@ create_shader(const char *source, GLenum shader_type)
char log[1000]; char log[1000];
GLsizei len; GLsizei len;
glGetShaderInfoLog(shader, 1000, &len, log); 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", shader_type == GL_VERTEX_SHADER ? "vertex" : "fragment",
len, log); len, log);
return 0; return 0;
@ -111,7 +111,7 @@ create_program(struct nested_client *client,
char log[1000]; char log[1000];
GLsizei len; GLsizei len;
glGetProgramInfoLog(client->program, 1000, &len, log); 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); exit(1);
} }

@ -546,7 +546,7 @@ create_shader(const char *source, GLenum shader_type)
char log[1000]; char log[1000];
GLsizei len; GLsizei len;
glGetShaderInfoLog(shader, 1000, &len, log); 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", shader_type == GL_VERTEX_SHADER ? "vertex" : "fragment",
len, log); len, log);
return 0; return 0;
@ -570,7 +570,7 @@ create_and_link_program(GLuint vert, GLuint frag)
char log[1000]; char log[1000];
GLsizei len; GLsizei len;
glGetProgramInfoLog(program, 1000, &len, log); 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; return 0;
} }

@ -243,7 +243,7 @@ create_shader(struct window *window, const char *source, GLenum shader_type)
char log[1000]; char log[1000];
GLsizei len; GLsizei len;
glGetShaderInfoLog(shader, 1000, &len, log); 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", shader_type == GL_VERTEX_SHADER ? "vertex" : "fragment",
len, log); len, log);
exit(1); exit(1);
@ -272,7 +272,7 @@ init_gl(struct window *window)
char log[1000]; char log[1000];
GLsizei len; GLsizei len;
glGetProgramInfoLog(program, 1000, &len, log); 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); exit(1);
} }

@ -296,7 +296,7 @@ create_shader(const char *source, GLenum shader_type)
char log[1000]; char log[1000];
GLsizei len; GLsizei len;
glGetShaderInfoLog(shader, 1000, &len, log); 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", shader_type == GL_VERTEX_SHADER ? "vertex" : "fragment",
len, log); len, log);
exit(1); exit(1);
@ -325,7 +325,7 @@ triangle_init_gl(struct triangle_gl_state *trigl)
char log[1000]; char log[1000];
GLsizei len; GLsizei len;
glGetProgramInfoLog(program, 1000, &len, log); 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); exit(1);
} }

Loading…
Cancel
Save