diff options
author | Luo Xionghu <xionghu.luo@intel.com> | 2015-11-11 15:35:27 +0800 |
---|---|---|
committer | Yang Rong <rong.r.yang@intel.com> | 2015-11-11 16:12:23 +0800 |
commit | 06084572d1c25bded5f01cb280ae6e2a68db1374 (patch) | |
tree | 18214a6bbb0dd5becd2fda0de1a69a009853c054 | |
parent | eee077466da631e072871178b2d5fb9e9fc54f46 (diff) |
runtime: extension size not enough.
define a MACRO to hold the value.
v2: use same MACRO in cl_extensions.h; add header file protection for
cl_extension.h.
Signed-off-by: Luo Xionghu <xionghu.luo@intel.com>
Reviewed-by: "Yang, Rong R" <rong.r.yang@intel.com>
-rw-r--r-- | src/cl_device_id.h | 5 | ||||
-rw-r--r-- | src/cl_extensions.c | 2 | ||||
-rw-r--r-- | src/cl_extensions.h | 6 |
3 files changed, 10 insertions, 3 deletions
diff --git a/src/cl_device_id.h b/src/cl_device_id.h index 4a923efa..e9717352 100644 --- a/src/cl_device_id.h +++ b/src/cl_device_id.h @@ -20,6 +20,9 @@ #ifndef __CL_DEVICE_ID_H__ #define __CL_DEVICE_ID_H__ +#define EXTENSTION_LENGTH 512 + +#include "cl_khr_icd.h" /* Store complete information about the device */ struct _cl_device_id { DEFINE_ICD(dispatch) @@ -95,7 +98,7 @@ struct _cl_device_id { const char *version; const char *profile; const char *opencl_c_version; - const char extensions[256]; + const char extensions[EXTENSTION_LENGTH]; const char *driver_version; const char *spir_versions; const char *built_in_kernels; diff --git a/src/cl_extensions.c b/src/cl_extensions.c index ba910c12..b35ea30a 100644 --- a/src/cl_extensions.c +++ b/src/cl_extensions.c @@ -142,7 +142,7 @@ cl_intel_platform_enable_extension(cl_device_id device, uint32_t ext) memcpy((char*)device->extensions, ext_str, strlen(ext_str)); device->extensions_sz = strlen(ext_str) + 1; } else { - assert(device->extensions_sz + 1 + strlen(ext_str) < 256); + assert(device->extensions_sz + 1 + strlen(ext_str) < EXTENSTION_LENGTH); *(char*)(device->extensions + device->extensions_sz - 1) = ' '; memcpy((char*)device->extensions + device->extensions_sz, ext_str, strlen(ext_str)); device->extensions_sz = device->extensions_sz + strlen(ext_str) + 1; diff --git a/src/cl_extensions.h b/src/cl_extensions.h index f744fa3a..cfb4c713 100644 --- a/src/cl_extensions.h +++ b/src/cl_extensions.h @@ -1,3 +1,5 @@ +#ifndef __CL_EXTENSIONS_H__ +#define __CL_EXTENSIONS_H__ /* The following approved Khronos extension * names must be returned by all device that * support OpenCL C 1.2. */ @@ -95,9 +97,10 @@ typedef union { #undef DECL_EXT } extension_union; +#include "cl_device_id.h" typedef struct cl_extensions { extension_union extensions[cl_khr_extension_id_max]; - char ext_str[256]; + char ext_str[EXTENSTION_LENGTH]; } cl_extensions_t; extern void @@ -106,3 +109,4 @@ extern void cl_intel_platform_enable_extension(cl_device_id device, uint32_t name); extern void cl_intel_platform_get_default_extension(cl_device_id device); +#endif /* __CL_EXTENSIONS_H__ */ |