From: Lv Meng Date: Fri, 15 Aug 2014 01:16:33 +0000 (+0800) Subject: Fix compile warnings for CLANG compiler X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7197ece4b83162b2f1fea84c6fda040febe7c89f;p=contrib%2Fbeignet.git Fix compile warnings for CLANG compiler 1.fix data structure redefine warnings. 2.fix 'data' with variable sized type 'union<*>' not at the end of a class warning(in immediate.hpp). 3.fix implicitly conversion warning. 4.fix explicitly assigning a variable type warning. 5.fix comparison of unsigned expression < 0 is always false warning(in cl_api.c). Signed-off-by: Lv Meng Reviewed-by: "Song, Ruiling" --- diff --git a/backend/src/backend/gen_encoder.cpp b/backend/src/backend/gen_encoder.cpp index 33b6413..26e997d 100644 --- a/backend/src/backend/gen_encoder.cpp +++ b/backend/src/backend/gen_encoder.cpp @@ -1062,9 +1062,7 @@ namespace gbe // for all the branching instruction. And need to adjust the distance // for those branch instruction's start point and end point contains // this instruction. - GenNativeInstruction *insn2 = (GenNativeInstruction *)&this->store[insnID+2]; - GBE_ASSERT(insn2->header.opcode == GEN_OPCODE_NOP); - insn2 = insn2; + GBE_ASSERT(((GenNativeInstruction *)&this->store[insnID+2])->header.opcode == GEN_OPCODE_NOP); insn.header.opcode = GEN_OPCODE_ADD; this->setDst(&insn, GenRegister::ip()); this->setSrc0(&insn, GenRegister::ip()); diff --git a/backend/src/backend/gen_reg_allocation.cpp b/backend/src/backend/gen_reg_allocation.cpp index 7d95997..067c9ce 100644 --- 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; + 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 --- a/backend/src/backend/program.h +++ b/backend/src/backend/program.h @@ -210,12 +210,6 @@ typedef gbe_program (gbe_program_new_from_llvm_cb)(uint32_t deviceID, int optLevel); extern gbe_program_new_from_llvm_cb *gbe_program_new_from_llvm; -/*! create s new genprogram for link. */ -typedef gbe_program (gbe_program_new_gen_program_cb)(uint32_t deviceID, - const void *module, - const void *act); -extern gbe_program_new_gen_program_cb *gbe_program_new_gen_program; - /*! link the programs from llvm level. */ typedef void (gbe_program_link_from_llvm_cb)(gbe_program dst_program, gbe_program src_program, diff --git a/backend/src/ir/immediate.hpp b/backend/src/ir/immediate.hpp index 6a5c819..85f14a0 100644 --- a/backend/src/ir/immediate.hpp +++ b/backend/src/ir/immediate.hpp @@ -208,6 +208,9 @@ namespace ir { } private: + ImmType type; //!< Type of the value + uint32_t elemNum; //!< vector imm data type + uint64_t defaultData; union { bool *b; int8_t *s8; @@ -223,23 +226,18 @@ namespace ir { const Immediate *immVec[]; void *p; } data; //!< Value to store - ImmType type; //!< Type of the value - uint32_t elemNum; //!< vector imm data type - uint64_t defaultData; Immediate & operator= (const Immediate &); - Immediate operator+ (const Immediate &) const; - Immediate operator- (const Immediate &) const; - Immediate operator* (const Immediate &) const; - Immediate operator/ (const Immediate &) const; - Immediate operator% (const Immediate &) const; - Immediate operator& (const Immediate &) const; - Immediate operator| (const Immediate &) const; - Immediate operator^ (const Immediate &) const; - Immediate operator<< (const Immediate &) const; - Immediate operator>> (const Immediate &) const; + Immediate operator+ (const Immediate &) const; + Immediate operator- (const Immediate &) const; + Immediate operator* (const Immediate &) const; + Immediate operator/ (const Immediate &) const; + Immediate operator% (const Immediate &) const; + Immediate operator& (const Immediate &) const; + Immediate operator| (const Immediate &) const; + Immediate operator^ (const Immediate &) const; + Immediate operator<< (const Immediate &) const; + Immediate operator>> (const Immediate &) const; static Immediate lshr (const Immediate &left, const Immediate &right); - - void copy(const Immediate &other, int32_t offset, uint32_t num); GBE_CLASS(Immediate); }; diff --git a/src/cl_api.c b/src/cl_api.c index 9f702d2..2370dc0 100644 --- a/src/cl_api.c +++ b/src/cl_api.c @@ -1910,7 +1910,7 @@ clEnqueueFillBuffer(cl_command_queue command_queue, goto error; } - if (offset < 0 || offset + size > buffer->size) { + if (offset + size > buffer->size) { err = CL_INVALID_VALUE; goto error; } @@ -1992,11 +1992,11 @@ clEnqueueCopyBuffer(cl_command_queue command_queue, goto error; } - if (src_offset < 0 || src_offset + cb > src_buffer->size) { + if (src_offset + cb > src_buffer->size) { err = CL_INVALID_VALUE; goto error; } - if (dst_offset < 0 || dst_offset + cb > dst_buffer->size) { + if (dst_offset + cb > dst_buffer->size) { err = CL_INVALID_VALUE; goto error; } diff --git a/src/cl_command_queue.c b/src/cl_command_queue.c index 05be801..52e91ae 100644 --- a/src/cl_command_queue.c +++ b/src/cl_command_queue.c @@ -141,12 +141,12 @@ cl_command_queue_bind_image(cl_command_queue queue, cl_kernel k) cl_gpgpu_bind_image(gpgpu, k->images[i].idx, image->base.bo, image->offset, image->intel_fmt, image->image_type, image->w, image->h, image->depth, - image->row_pitch, image->tiling); + image->row_pitch, (cl_gpgpu_tiling)image->tiling); if (image->image_type == CL_MEM_OBJECT_IMAGE1D_ARRAY) cl_gpgpu_bind_image(gpgpu, k->images[i].idx + 128, image->base.bo, image->offset, image->intel_fmt, image->image_type, image->w, image->h, image->depth, - image->row_pitch, image->tiling); + image->row_pitch, (cl_gpgpu_tiling)image->tiling); } return CL_SUCCESS; } diff --git a/src/cl_context.h b/src/cl_context.h index f8342d3..8c1e63f 100644 --- a/src/cl_context.h +++ b/src/cl_context.h @@ -20,9 +20,9 @@ #ifndef __CL_CONTEXT_H__ #define __CL_CONTEXT_H__ +#include "CL/cl.h" #include "cl_internals.h" #include "cl_driver.h" -#include "CL/cl.h" #include "cl_khr_icd.h" #include diff --git a/src/cl_driver.h b/src/cl_driver.h index 9cdba98..38b4830 100644 --- a/src/cl_driver.h +++ b/src/cl_driver.h @@ -275,7 +275,6 @@ extern cl_buffer_set_tiling_cb *cl_buffer_set_tiling; #include "cl_context.h" #include "cl_mem.h" -typedef struct _cl_context *cl_context; typedef cl_buffer (cl_buffer_alloc_from_texture_cb)(cl_context, unsigned int, int, unsigned int, struct _cl_mem_image *gl_image); diff --git a/src/cl_driver_type.h b/src/cl_driver_type.h index 891a33c..c39d3f1 100644 --- a/src/cl_driver_type.h +++ b/src/cl_driver_type.h @@ -4,6 +4,8 @@ * will allow us to make the use of a software performance simulator easier and * to minimize the code specific for the HW and for the simulator **************************************************************************/ +#ifndef __CL_DRIVER_TYPE_H__ +#define __CL_DRIVER_TYPE_H__ /* Encapsulates command buffer / data buffer / kernels */ typedef struct _cl_buffer *cl_buffer; @@ -21,4 +23,5 @@ typedef struct _cl_gpgpu *cl_gpgpu; typedef struct _cl_gpgpu_event *cl_gpgpu_event; typedef struct _cl_context_prop *cl_context_prop; -typedef struct _cl_sampler *cl_sampler; + +#endif 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; cb = enqueue_cb; enqueue_cb = enqueue_cb->next; diff --git a/src/cl_extensions.h b/src/cl_extensions.h index 52ee0a4..e6cdce8 100644 --- a/src/cl_extensions.h +++ b/src/cl_extensions.h @@ -92,8 +92,5 @@ typedef struct cl_extensions { char ext_str[256]; } cl_extensions_t; -struct _cl_platform_id; -typedef struct _cl_platform_id * cl_platform_id; - extern void cl_intel_platform_extension_init(cl_platform_id intel_platform); diff --git a/src/cl_gt_device.h b/src/cl_gt_device.h index fc8aefd..33ef1f0 100644 --- a/src/cl_gt_device.h +++ b/src/cl_gt_device.h @@ -51,7 +51,6 @@ .max_samplers = 16, .mem_base_addr_align = sizeof(cl_long) * 16 * 8, .min_data_type_align_size = sizeof(cl_long) * 16, -.single_fp_config = 0, /* XXX */ .double_fp_config = 0, .global_mem_cache_type = CL_READ_WRITE_CACHE, .global_mem_size = 1024 * 1024 * 1024, diff --git a/src/cl_platform_id.h b/src/cl_platform_id.h index 2a9c07a..61b8eab 100644 --- a/src/cl_platform_id.h +++ b/src/cl_platform_id.h @@ -20,11 +20,10 @@ #ifndef __CL_PLATFORM_ID_H__ #define __CL_PLATFORM_ID_H__ +#include "CL/cl.h" #include "cl_internals.h" #include "cl_extensions.h" #include "cl_khr_icd.h" -#include "CL/cl.h" - #include "src/OCLConfig.h" struct _cl_platform_id { diff --git a/src/x11/mesa_egl_extension.c b/src/x11/mesa_egl_extension.c index a7fc8cb..4a3e89c 100644 --- a/src/x11/mesa_egl_extension.c +++ b/src/x11/mesa_egl_extension.c @@ -123,7 +123,6 @@ _eglLockDisplay(EGLDisplay dpy) static _EGLContext * _eglLookupContext(EGLContext ctx, EGLDisplay disp) { - disp = disp; return (_EGLContext *) ctx; } diff --git a/utests/utest_helper.cpp b/utests/utest_helper.cpp index 90cd11e..b57b8dc 100644 --- a/utests/utest_helper.cpp +++ b/utests/utest_helper.cpp @@ -537,12 +537,19 @@ 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); + if(2 != ret){ + fclose(fp); + free(bmppath); + return NULL; + } assert(magic[0] == 'B' && magic[1] == 'M'); ret = fread(&hdr, sizeof(hdr), 1, fp); - assert(1 == ret); + if(1 != ret){ + fclose(fp); + free(bmppath); + return NULL; + } assert(hdr.width > 0 && hdr.height > 0 && hdr.nplanes == 1 && hdr.compression == 0);