cl: Initialize errNo on invalid image type.

Submitted by Vinson Lee on Aug. 8, 2016, 11:07 p.m.

Details

Message ID 1470697660-11641-1-git-send-email-vlee@freedesktop.org
State New
Headers show
Series "cl: Initialize errNo on invalid image type." ( rev: 2 ) in Piglit

Not browsing as part of any series.

Commit Message

Vinson Lee Aug. 8, 2016, 11:07 p.m.
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@freedesktop.org>
---
 tests/util/piglit-util-cl.c | 1 +
 1 file changed, 1 insertion(+)

Patch hide | download patch | download mbox

diff --git a/tests/util/piglit-util-cl.c b/tests/util/piglit-util-cl.c
index 7e7d9850be5c..b5b7fce550f6 100644
--- a/tests/util/piglit-util-cl.c
+++ b/tests/util/piglit-util-cl.c
@@ -1055,6 +1055,7 @@  piglit_cl_create_image(piglit_cl_context context, cl_mem_flags flags,
 		                        desc->image_depth, 0, 0,
 		                        NULL, &errNo);
 	} else {
+		errNo = CL_INVALID_MEM_OBJECT;
 		fprintf(stderr,
 		        "Invalid image mem object type: %s\n",
 		        piglit_cl_get_enum_name(desc->image_type));