[Beignet] [PATCH 1/2] Fix shift-overflow warning

Giuseppe Bilotta giuseppe.bilotta at gmail.com
Wed Sep 7 12:13:14 UTC 2016


Wrap toMB constant in UINT64_C to avoid the warning:

    src/cl_device_id.c:743:49: warning: result of
     ‘1152921504606846975l << 20’
     requires 81 bits to represent, but ‘long int’ only has 64 bits
     [-Wshift-overflow=]
        #define toMB(size) (size)&((0xfffffffffffffff)<<20)
---
 src/cl_device_id.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/cl_device_id.c b/src/cl_device_id.c
index 19eec5d..6b3b521 100644
--- a/src/cl_device_id.c
+++ b/src/cl_device_id.c
@@ -740,7 +740,7 @@ kbl_gt4_break:
   /* Apply any driver-dependent updates to the device info */
   cl_driver_update_device_info(ret);
 
-  #define toMB(size) (size)&(0xfffffffffffffff<<20)
+  #define toMB(size) (size)&(UINT64_C(0xfffffffffffffff)<<20)
   /* Get the global_mem_size and max_mem_alloc size from
    * driver, system ram and hardware*/
   struct sysinfo info;
-- 
2.8.1.372.g9612035



More information about the Beignet mailing list