[PATCH] Fix "possibly uninitialized" warnings in glx.

Rémi Cardona remi at gentoo.org
Fri Oct 2 14:09:49 PDT 2009


Le 02/10/2009 22:42, Jamey Sharp a écrit :
> In both functions, "answer" was uninitialized if "compsize" was 0, but in
> that case __GLX_SEND_VOID_ARRAY(compsize) results in a call to
> WriteToClient for 0 bytes, which returns immediately without examining the
> "answer" argument. So initializing to a null pointer is as good as
> anything else.
>
> Signed-off-by: Jamey Sharp<jamey at minilop.net>
> ---
>   glx/indirect_texture_compression.c |    4 ++--
>   1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/glx/indirect_texture_compression.c b/glx/indirect_texture_compression.c
> index 25c6eb3..aca4b3e 100644
> --- a/glx/indirect_texture_compression.c
> +++ b/glx/indirect_texture_compression.c
> @@ -52,7 +52,7 @@ int __glXDisp_GetCompressedTexImageARB(struct __GLXclientStateRec *cl, GLbyte *p
>   	const GLenum target = *(GLenum *)(pc + 0);
>   	const GLint  level  = *(GLint  *)(pc + 4);
>   	GLint compsize = 0;
> -	char *answer, answerBuffer[200];
> +	char *answer = 0, answerBuffer[200];
>
>   	CALL_GetTexLevelParameteriv(GET_DISPATCH(), (target, level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE,&compsize));
>
> @@ -92,7 +92,7 @@ int __glXDispSwap_GetCompressedTexImageARB(struct __GLXclientStateRec *cl, GLbyt
>   	const GLenum target = (GLenum) bswap_32( *(int *)(pc + 0) );
>   	const GLint  level =  (GLint ) bswap_32( *(int *)(pc + 4) );
>   	GLint compsize = 0;
> -	char *answer, answerBuffer[200];
> +	char *answer = 0, answerBuffer[200];

Why not NULL instead of 0?

Rémi


More information about the xorg-devel mailing list