[Beignet] [PATCH] [PATCH_V2]Fix compile warnings for CLANG compiler

Song, Ruiling ruiling.song at intel.com
Mon Aug 11 19:50:49 PDT 2014


1. Fix data structure redefine warnings.
2. 'data' with variable sized type 'union<*>' not at the end of a class warning.
3. Implicitly conversion warning.
4. Explicitly assigning a variable type warning.

It is always better to make text in good format.

--- a/backend/src/backend/gen_reg_allocation.cpp
+++ b/backend/src/backend/gen_reg_allocation.cpp
@@ -846,7 +846,7 @@ namespace gbe
       // from the RA map.
       bool success = expireReg(interval.reg);
       GBE_ASSERT(success);
-      success = success;
+      success = ~success;

A better fix here is return the error status to high level function, like:
-     GBE_ASSERT(success);
-     success = success;
+     if ( !success ) return success;


       RA.erase(interval.reg);
     }
     spilledRegs.insert(std::make_pair(interval.reg, spillTag)); diff --git a/backend/src/backend/program.h b/backend/src/backend/program.h index 39ff402..254df92 100644


diff --git a/src/cl_event.c b/src/cl_event.c index 99e60eb..c3c6dde 100644
--- a/src/cl_event.c
+++ b/src/cl_event.c
@@ -472,9 +472,8 @@ void cl_event_set_status(cl_event event, cl_int status)
     /* All user events complete, now wait enqueue events */
     ret = cl_event_wait_events(enqueue_cb->num_events, enqueue_cb->wait_list,
         enqueue_cb->event->queue);
-    ret = ret;
     assert(ret != CL_ENQUEUE_EXECUTE_DEFER);
-
+    ret = ~ret;

You may check with Yang Rong to see whether there is a better fix here.

     cb = enqueue_cb;
     enqueue_cb = enqueue_cb->next;
 
diff --git a/src/cl_extensions.h b/src/cl_extensions.h index 52ee0a4..e6cdce8 100644
struct _cl_platform_id {
diff --git a/utests/utest_helper.cpp b/utests/utest_helper.cpp index 90cd11e..64d97c2 100644
--- a/utests/utest_helper.cpp
+++ b/utests/utest_helper.cpp
@@ -537,12 +537,12 @@ int *cl_read_bmp(const char *filename, int *width, int *height)
   char magic[2];
   int ret;
   ret = fread(&magic[0], 1, 2, fp);
-  ret = ret;
   assert(2 == ret);
   assert(magic[0] == 'B' && magic[1] == 'M');
 
   ret = fread(&hdr, sizeof(hdr), 1, fp);
   assert(1 == ret);
+  ret = ~ret;

To remove the "ret = ret".
Below is a better fix:
if (2 == ret) {
	fclose(fp);
	free(bmppath);
	return NULL;
}
And at the same time, assert (2 == ret) could also be removed. You can use same kind of fix for the "assert (1 == ret);"

   assert(hdr.width > 0 && hdr.height > 0 && hdr.nplanes == 1 && hdr.compression == 0);
 
--
1.8.3.2

_______________________________________________
Beignet mailing list
Beignet at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/beignet


More information about the Beignet mailing list