[Piglit] [PATCH v2] cl: Initialize errNo on invalid image type.

Jan Vesely jv356 at scarletmail.rutgers.edu
Thu Sep 1 09:54:24 UTC 2016


On Thu, 2016-09-01 at 07:10 +0000, Vinson Lee wrote:
> Fixes sometimes-uninitialized warning.
> 
> piglit-util-cl.c:1052:13: warning: variable 'errNo' is used
> uninitialized whenever 'if' condition is false [-Wsometimes-
> uninitialized]
>         } else if (desc->image_type == CL_MEM_OBJECT_IMAGE3D) {
>                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> piglit-util-cl.c:1062:28: note: uninitialized use occurs here
>         if(!piglit_cl_check_error(errNo, CL_SUCCESS)) {
>                                   ^~~~~
> piglit-util-cl.c:1052:9: note: remove the 'if' if its condition is
> always true
>         } else if (desc->image_type == CL_MEM_OBJECT_IMAGE3D) {
>                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> piglit-util-cl.c:1040:14: note: initialize the variable 'errNo' to
> silence this warning
>         cl_int errNo;
>                     ^
>                      = 0
> 
> Fixes: 910cd6c222930 ("cl: add image and sampler utility functions")
> Signed-off-by: Vinson Lee <vlee at freedesktop.org>
> ---
>  tests/util/piglit-util-cl.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/tests/util/piglit-util-cl.c b/tests/util/piglit-util-
> cl.c
> index dba32636f8ad..0211c1ff63b6 100644
> --- a/tests/util/piglit-util-cl.c
> +++ b/tests/util/piglit-util-cl.c
> @@ -1095,6 +1095,7 @@ piglit_cl_create_image(piglit_cl_context
> context, cl_mem_flags flags,
>  		                        desc->image_depth, 0, 0,
>  		                        NULL, &errNo);
>  	} else {
> +		errNo = CL_INVALID_OPERATION;
>  		fprintf(stderr,
>  		        "Invalid image mem object type: %s\n",
>  		        piglit_cl_get_enum_name(desc->image_type));

I think it'd be nicer to just return early instead of printing two
error messages. CL1.2 returns CL_INVALID_IMAGE_DESCRIPTOR if the
descriptor values are not valid, but the enum value is not present in
CL1.1-. Either way:

Acked-by: Jan Vesely <jan.vesely at rutgers.edu>

Jan

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <https://lists.freedesktop.org/archives/piglit/attachments/20160901/da6409c3/attachment.sig>


More information about the Piglit mailing list