From 4f5a5f9a4187ce896562d1bf26ae83a14065475a Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Tue, 5 Jun 2018 14:33:27 +0100 Subject: [PATCH] Clang compiler warnings/type safety --- fortran/grib_fortran.c | 4 ++-- src/grib_accessor_classes_hash.c | 4 +--- src/grib_dumper_class_bufr_encode_C.c | 2 +- src/grib_dumper_class_bufr_encode_fortran.c | 2 +- src/grib_dumper_class_bufr_encode_python.c | 2 +- src/grib_hash_keys.c | 4 +--- src/grib_query.c | 6 +++--- tools/bufr_compare.c | 4 ++-- tools/grib_compare.c | 4 ++-- 9 files changed, 14 insertions(+), 18 deletions(-) diff --git a/fortran/grib_fortran.c b/fortran/grib_fortran.c index d8211343a..3fa83f3b5 100644 --- a/fortran/grib_fortran.c +++ b/fortran/grib_fortran.c @@ -1687,7 +1687,7 @@ int any_f_new_from_scanned_file(int* fid,int* msgid,int* gid) /* fortran convention of 1 based index*/ const int n=*msgid-1; - l_message_info* msg=grib_oarray_get(info_messages,n); + l_message_info* msg=(l_message_info*)grib_oarray_get(info_messages,n); if (msg && f) { GRIB_MUTEX_INIT_ONCE(&once,&init); @@ -1759,7 +1759,7 @@ int any_f_new_from_loaded(int* msgid,int* gid) /* fortran convention of 1 based index*/ const int n=*msgid-1; - l_binary_message* msg=grib_oarray_get(binary_messages,n); + l_binary_message* msg=(l_binary_message*)grib_oarray_get(binary_messages,n); if (msg && msg->data) h=grib_handle_new_from_message_copy (c,msg->data,msg->size); diff --git a/src/grib_accessor_classes_hash.c b/src/grib_accessor_classes_hash.c index 51deed99a..9b275ff8b 100644 --- a/src/grib_accessor_classes_hash.c +++ b/src/grib_accessor_classes_hash.c @@ -52,9 +52,7 @@ struct accessor_class_hash { char *name; grib_accessor_class **cclass;}; #endif #endif static unsigned int -grib_accessor_classes_get_id (str, len) - register const char *str; - register unsigned int len; +grib_accessor_classes_get_id (const char *str, unsigned int len) { static const unsigned short asso_values[] = { diff --git a/src/grib_dumper_class_bufr_encode_C.c b/src/grib_dumper_class_bufr_encode_C.c index 6474a0021..842ce6e3f 100644 --- a/src/grib_dumper_class_bufr_encode_C.c +++ b/src/grib_dumper_class_bufr_encode_C.c @@ -146,7 +146,7 @@ static int destroy(grib_dumper* d) static char* lval_to_string(grib_context* c, long v) { - char* sval=grib_context_malloc_clear(c,sizeof(char)*40); + char* sval=(char*)grib_context_malloc_clear(c,sizeof(char)*40); if (v == GRIB_MISSING_LONG) sprintf(sval,"CODES_MISSING_LONG"); else sprintf(sval,"%ld",v); return sval; diff --git a/src/grib_dumper_class_bufr_encode_fortran.c b/src/grib_dumper_class_bufr_encode_fortran.c index b90619007..9deae85a5 100644 --- a/src/grib_dumper_class_bufr_encode_fortran.c +++ b/src/grib_dumper_class_bufr_encode_fortran.c @@ -146,7 +146,7 @@ static int destroy(grib_dumper* d) static char* lval_to_string(grib_context* c, long v) { - char* sval=grib_context_malloc_clear(c,sizeof(char)*40); + char* sval=(char*)grib_context_malloc_clear(c,sizeof(char)*40); if (v == GRIB_MISSING_LONG) sprintf(sval,"CODES_MISSING_LONG"); else sprintf(sval,"%ld",v); return sval; diff --git a/src/grib_dumper_class_bufr_encode_python.c b/src/grib_dumper_class_bufr_encode_python.c index f13010e3b..c04111aae 100644 --- a/src/grib_dumper_class_bufr_encode_python.c +++ b/src/grib_dumper_class_bufr_encode_python.c @@ -146,7 +146,7 @@ static int destroy(grib_dumper* d) static char* lval_to_string(grib_context* c, long v) { - char* sval=grib_context_malloc_clear(c,sizeof(char)*40); + char* sval=(char*)grib_context_malloc_clear(c,sizeof(char)*40); if (v == GRIB_MISSING_LONG) sprintf(sval,"CODES_MISSING_LONG"); else sprintf(sval,"%ld",v); return sval; diff --git a/src/grib_hash_keys.c b/src/grib_hash_keys.c index feee0e466..3d5db6cf5 100644 --- a/src/grib_hash_keys.c +++ b/src/grib_hash_keys.c @@ -51,9 +51,7 @@ struct grib_keys_hash { char* name; int id;}; #endif #endif static unsigned int -hash_keys (str, len) - register const char *str; - register unsigned int len; +hash_keys (const char *str, unsigned int len) { static const unsigned short asso_values[] = { diff --git a/src/grib_query.c b/src/grib_query.c index 2331f39fb..250c987b2 100644 --- a/src/grib_query.c +++ b/src/grib_query.c @@ -409,7 +409,7 @@ static grib_accessor* _grib_find_accessor(grib_handle* h, const char* name) char* p = NULL; DebugAssert(name); - p = strchr(name, '.'); + p = strchr((char*)name, '.'); if ( p ) { int i=0,len=0; char name_space[MAX_NAMESPACE_LEN]; @@ -439,7 +439,7 @@ char* grib_split_name_attribute(grib_context* c,const char* name,char* attribute /*returns accessor name and attribute*/ size_t size=0; char* accessor_name=NULL; - char* p = strstr(name, "->"); + char* p = strstr((char*)name, "->"); if (!p) { *attribute_name=0; return (char*)name; @@ -502,7 +502,7 @@ grib_accessor* grib_find_accessor_fast(grib_handle* h, const char* name) char* p = NULL; DebugAssert(name); - p = strchr(name, '.'); + p = strchr((char*)name, '.'); if ( p ) { int i=0,len=0; char name_space[MAX_NAMESPACE_LEN]; diff --git a/tools/bufr_compare.c b/tools/bufr_compare.c index b233731cc..19d33dd79 100644 --- a/tools/bufr_compare.c +++ b/tools/bufr_compare.c @@ -663,8 +663,8 @@ static int compare_values(grib_runtime_options* options, grib_handle* handle1, g double packingError1=0,packingError2=0; double value_tolerance=0; grib_context* c=handle1->context; - char* first_str = (handles_swapped==0? "1st" : "2nd"); - char* second_str = (handles_swapped==0? "2nd" : "1st"); + const char* first_str = (handles_swapped==0? "1st" : "2nd"); + const char* second_str = (handles_swapped==0? "2nd" : "1st"); type1=type; type2=type; diff --git a/tools/grib_compare.c b/tools/grib_compare.c index faeeca832..b1a5c3aed 100644 --- a/tools/grib_compare.c +++ b/tools/grib_compare.c @@ -591,8 +591,8 @@ static int compare_values(grib_runtime_options* options,grib_handle* h1,grib_han double packingError1=0,packingError2=0; double value_tolerance=0; grib_context* c=h1->context; - char* first_str = (handles_swapped==0? "1st" : "2nd"); - char* second_str = (handles_swapped==0? "2nd" : "1st"); + const char* first_str = (handles_swapped==0? "1st" : "2nd"); + const char* second_str = (handles_swapped==0? "2nd" : "1st"); type1=type; type2=type;