From 13bb2640b7ef16e1adc2e19e5843224c0616d746 Mon Sep 17 00:00:00 2001 From: Samuel Date: Fri, 17 Apr 2020 05:26:30 +0530 Subject: [PATCH] [CRT]Compilation warnings fixed for 32bit and 64bit compilation (#5349) --- apps/bundle_deploy/demo_static.c | 6 +++--- src/runtime/crt/crt_backend_api.c | 2 +- src/runtime/crt/graph_runtime.c | 4 ++-- src/runtime/crt/load_json.c | 1 + src/runtime/crt/ndarray.c | 8 ++++---- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/apps/bundle_deploy/demo_static.c b/apps/bundle_deploy/demo_static.c index ed003738b0e6..37285351c0b8 100644 --- a/apps/bundle_deploy/demo_static.c +++ b/apps/bundle_deploy/demo_static.c @@ -41,12 +41,12 @@ int main(int argc, char **argv) { struct timeval t0, t1, t2, t3, t4, t5; gettimeofday(&t0, 0); - auto *handle = tvm_runtime_create(json_data, params_data, params_size); + void *handle = tvm_runtime_create(json_data, params_data, params_size); gettimeofday(&t1, 0); float input_storage[1 * 3 * 224 * 224]; FILE * fp = fopen(argv[1], "rb"); - fread(input_storage, 3 * 224 * 224, 4, fp); + (void)fread(input_storage, 3 * 224 * 224, 4, fp); fclose(fp); DLTensor input; @@ -85,7 +85,7 @@ int main(int argc, char **argv) { float max_iter = -FLT_MAX; int32_t max_index = -1; - for (auto i = 0; i < OUTPUT_LEN; ++i) { + for (int i = 0; i < OUTPUT_LEN; ++i) { if (output_storage[i] > max_iter) { max_iter = output_storage[i]; max_index = i; diff --git a/src/runtime/crt/crt_backend_api.c b/src/runtime/crt/crt_backend_api.c index 52cefafe3980..a56c15bdf01e 100644 --- a/src/runtime/crt/crt_backend_api.c +++ b/src/runtime/crt/crt_backend_api.c @@ -48,7 +48,7 @@ int TVMBackendParallelLaunch(FTVMParallelLambda flambda, void* cdata, int num_ta int TVMBackendRegisterSystemLibSymbol(const char* name, void* ptr) { g_fexecs = vrealloc(g_fexecs, sizeof(TVMPackedFunc) * (g_fexecs_count + 1)); - snprintf(g_fexecs[g_fexecs_count].name, sizeof(g_fexecs[g_fexecs_count].name), name); + snprintf(g_fexecs[g_fexecs_count].name, sizeof(g_fexecs[g_fexecs_count].name), "%s", name); g_fexecs[g_fexecs_count].fexec = ptr; g_fexecs_count++; return 0; diff --git a/src/runtime/crt/graph_runtime.c b/src/runtime/crt/graph_runtime.c index b5ed3b70281b..a4c07f48ddf0 100644 --- a/src/runtime/crt/graph_runtime.c +++ b/src/runtime/crt/graph_runtime.c @@ -696,13 +696,13 @@ void TVMGraphRuntime_SetupStorage(TVMGraphRuntime * runtime) { runtime->data_entry_count = runtime->node_row_ptr[runtime->node_row_ptr_count - 1]; runtime->data_entry = vmalloc(sizeof(TVMNDArray) * runtime->data_entry_count); for (idx = 0; idx < runtime->data_entry_count; ++idx) { - size_t storage_id = attrs->storage_id[idx]; + uint32_t storage_id = attrs->storage_id[idx]; CHECK(storage_id < runtime->storage_pool_count); runtime->data_entry[idx] = TVMNDArray_CreateView(&(runtime->storage_pool[storage_id]), attrs->shape+idx*TVM_CRT_MAX_NDIM, attrs->ndim[idx], vtype[idx]); CHECK_NE(runtime->data_entry[idx].dl_tensor.data, 0, - "fail to create for node with idx=%d, storage_id=%lu\n", idx, storage_id); + "fail to create for node with idx=%d, storage_id=%u\n", idx, storage_id); } // Release memory diff --git a/src/runtime/crt/load_json.c b/src/runtime/crt/load_json.c index cf9492b8e2fa..226569ddba8a 100644 --- a/src/runtime/crt/load_json.c +++ b/src/runtime/crt/load_json.c @@ -182,6 +182,7 @@ int JSONReader_ReadString(JSONReader * reader, char * out_str) { } if (ch == EOF || ch == '\r' || ch == '\n') { fprintf(stderr, "Error at line X, Expect \'\"\' but reach end of line\n"); + status = -1; } } snprintf(out_str, sizeof(output), "%s", output); diff --git a/src/runtime/crt/ndarray.c b/src/runtime/crt/ndarray.c index ed623fbf3de8..b0562181534e 100644 --- a/src/runtime/crt/ndarray.c +++ b/src/runtime/crt/ndarray.c @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -92,8 +92,8 @@ int TVMNDArray_Load(TVMNDArray * ret, const char ** strm) { int64_t data_byte_size; data_byte_size = ((int64_t*)*strm)[0]; *strm += sizeof(data_byte_size); // NOLINT(*) if (!(data_byte_size == num_elems * elem_bytes)) { - fprintf(stderr, "invalid DLTensor file format: data_byte_size=%ld, " - "while num_elems*elem_bytes=%ld\n", + fprintf(stderr, "invalid DLTensor file format: data_byte_size=%jd, " + "while num_elems*elem_bytes=%jd\n", data_byte_size, (num_elems * elem_bytes)); status = -1; }