[Piglit] [PATCH] cl-api-get-platform-ids: Initialize variable.

Tom Stellard tom at stellard.net
Thu Jul 3 10:47:54 PDT 2014


On Tue, Jul 01, 2014 at 10:38:56PM -0700, Vinson Lee wrote:
> Fix clang sometimes-uninitialized warning.
> 
> get-platform-ids.c:62:5: warning: variable 'platforms' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
>         if(!piglit_cl_check_error(errNo, CL_SUCCESS)) {
>            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> get-platform-ids.c:93:30: note: uninitialized use occurs here
>         errNo = clGetPlatformIDs(0, platforms, NULL);
>                                     ^~~~~~~~~
> get-platform-ids.c:62:2: note: remove the 'if' if its condition is always false
>         if(!piglit_cl_check_error(errNo, CL_SUCCESS)) {
>         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> get-platform-ids.c:56:27: note: initialize the variable 'platforms' to silence this warning
>         cl_platform_id* platforms;
>                                  ^
>                                   = NULL
> 
Reviewed-by: Tom Stellard <thomas.stellard at amd.com>
> Signed-off-by: Vinson Lee <vlee at freedesktop.org>
> ---
>  tests/cl/api/get-platform-ids.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tests/cl/api/get-platform-ids.c b/tests/cl/api/get-platform-ids.c
> index 6cc734a..f94ab0c 100644
> --- a/tests/cl/api/get-platform-ids.c
> +++ b/tests/cl/api/get-platform-ids.c
> @@ -53,7 +53,7 @@ piglit_cl_test(const int argc,
>  	int i;
>  	cl_int errNo;
>  	cl_uint num_platforms;
> -	cl_platform_id* platforms;
> +	cl_platform_id* platforms = NULL;
>  
>  	/*** Normal usage ***/
>  
> -- 
> 1.9.2
> 
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit


More information about the Piglit mailing list