Explicit casts to shut g++ warnings and errors

This commit is contained in:
Ciro Santilli committed 2017-09-16 12:58:36 +01:00
1 parent bbb0d2a704
commit 6cbb5f421e
2 files changed
+8 -8

No files matched your search

+4 -4
View File
@@ -37,7 +37,7 @@ char* common_read_file(const char *path, long *length_out) {
fseek(f, 0, SEEK_END);
length = ftell(f);
fseek(f, 0, SEEK_SET);
buffer = malloc(length);
buffer = (char *)malloc(length);
if (fread(buffer, 1, length, f) < (size_t)length) {
return NULL;
}
@@ -52,7 +52,7 @@ char* common_read_file_null(const char *path) {
char *f;
long length;
f = common_read_file(path, &length);
f = realloc(f, length + 1);
f = (char *)realloc(f, length + 1);
f[length] = '\0';
return f;
}
@@ -68,7 +68,7 @@ void common_build_program(
ret = clBuildProgram(*program, 1, &(common->device), options, NULL, NULL);
if (CL_SUCCESS != ret) {
clGetProgramBuildInfo(*program, common->device, CL_PROGRAM_BUILD_LOG, 0, NULL, &err_len);
err = malloc(err_len);
err = (char *)malloc(err_len);
clGetProgramBuildInfo(*program, common->device, CL_PROGRAM_BUILD_LOG, err_len, err, NULL);
fprintf(stderr, "error: clBuildProgram:\n%s\n", err);
free(err);
@@ -195,7 +195,7 @@ void common_create_kernel_or_use_cache(
} else {
common_init_file(common, source_path);
clGetProgramInfo(common->program, CL_PROGRAM_BINARY_SIZES, sizeof(size_t), &binary_size, NULL);
binary = malloc(binary_size);
binary = (char *)malloc(binary_size);
clGetProgramInfo(common->program, CL_PROGRAM_BINARIES, binary_size, &binary, NULL);
f = fopen(bin_path, "w");
fwrite(binary, binary_size, 1, f);
+4 -4
View File
@@ -94,7 +94,7 @@ int main(int argc, char **argv) {
if (argc > a) {
source_path = argv[a];
} else {
source_path = "vec_io.cl";
source_path = (char *)"vec_io.cl";
}
a++;
if (argc > a) {
@@ -106,13 +106,13 @@ int main(int argc, char **argv) {
/* Initialize data. */
n = 0;
nmax = n + 1;
io = malloc(nmax * sizeof(*io));
io = (cl_float *)malloc(nmax * sizeof(*io));
while(fscanf(input_vector_file, "%f", &f) != EOF) {
io[n] = f;
n++;
if (n == nmax) {
nmax *= 2;
io = realloc(io, nmax * sizeof(*io));
io = (cl_float *)realloc(io, nmax * sizeof(*io));
}
}
io_sizeof = n * sizeof(*io);
@@ -121,7 +121,7 @@ int main(int argc, char **argv) {
}
/* Create kernel. */
common_create_kernel_or_use_cache(&common, use_cache, source_path, __FILE__ ".bin.tmp");
common_create_kernel_or_use_cache(&common, use_cache, source_path, (char *)(__FILE__ ".bin.tmp"));
buffer = clCreateBuffer(common.context, CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR, io_sizeof, io, NULL);
clSetKernelArg(common.kernel, 0, sizeof(buffer), &buffer);
clEnqueueNDRangeKernel(common.command_queue, common.kernel, 1, NULL, &global_work_size, &local_work_size, 0, NULL, NULL);