Clang compiler warnings/type safety

This commit is contained in:
Shahram Najm 2018-06-05 14:33:27 +01:00
parent 5c576df574
commit 4f5a5f9a41
9 changed files with 14 additions and 18 deletions

View File

@ -1687,7 +1687,7 @@ int any_f_new_from_scanned_file(int* fid,int* msgid,int* gid)
/* fortran convention of 1 based index*/ /* fortran convention of 1 based index*/
const int n=*msgid-1; 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) { if (msg && f) {
GRIB_MUTEX_INIT_ONCE(&once,&init); 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*/ /* fortran convention of 1 based index*/
const int n=*msgid-1; 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) if (msg && msg->data)
h=grib_handle_new_from_message_copy (c,msg->data,msg->size); h=grib_handle_new_from_message_copy (c,msg->data,msg->size);

View File

@ -52,9 +52,7 @@ struct accessor_class_hash { char *name; grib_accessor_class **cclass;};
#endif #endif
#endif #endif
static unsigned int static unsigned int
grib_accessor_classes_get_id (str, len) grib_accessor_classes_get_id (const char *str, unsigned int len)
register const char *str;
register unsigned int len;
{ {
static const unsigned short asso_values[] = static const unsigned short asso_values[] =
{ {

View File

@ -146,7 +146,7 @@ static int destroy(grib_dumper* d)
static char* lval_to_string(grib_context* c, long v) 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"); if (v == GRIB_MISSING_LONG) sprintf(sval,"CODES_MISSING_LONG");
else sprintf(sval,"%ld",v); else sprintf(sval,"%ld",v);
return sval; return sval;

View File

@ -146,7 +146,7 @@ static int destroy(grib_dumper* d)
static char* lval_to_string(grib_context* c, long v) 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"); if (v == GRIB_MISSING_LONG) sprintf(sval,"CODES_MISSING_LONG");
else sprintf(sval,"%ld",v); else sprintf(sval,"%ld",v);
return sval; return sval;

View File

@ -146,7 +146,7 @@ static int destroy(grib_dumper* d)
static char* lval_to_string(grib_context* c, long v) 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"); if (v == GRIB_MISSING_LONG) sprintf(sval,"CODES_MISSING_LONG");
else sprintf(sval,"%ld",v); else sprintf(sval,"%ld",v);
return sval; return sval;

View File

@ -51,9 +51,7 @@ struct grib_keys_hash { char* name; int id;};
#endif #endif
#endif #endif
static unsigned int static unsigned int
hash_keys (str, len) hash_keys (const char *str, unsigned int len)
register const char *str;
register unsigned int len;
{ {
static const unsigned short asso_values[] = static const unsigned short asso_values[] =
{ {

View File

@ -409,7 +409,7 @@ static grib_accessor* _grib_find_accessor(grib_handle* h, const char* name)
char* p = NULL; char* p = NULL;
DebugAssert(name); DebugAssert(name);
p = strchr(name, '.'); p = strchr((char*)name, '.');
if ( p ) { if ( p ) {
int i=0,len=0; int i=0,len=0;
char name_space[MAX_NAMESPACE_LEN]; 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*/ /*returns accessor name and attribute*/
size_t size=0; size_t size=0;
char* accessor_name=NULL; char* accessor_name=NULL;
char* p = strstr(name, "->"); char* p = strstr((char*)name, "->");
if (!p) { if (!p) {
*attribute_name=0; *attribute_name=0;
return (char*)name; return (char*)name;
@ -502,7 +502,7 @@ grib_accessor* grib_find_accessor_fast(grib_handle* h, const char* name)
char* p = NULL; char* p = NULL;
DebugAssert(name); DebugAssert(name);
p = strchr(name, '.'); p = strchr((char*)name, '.');
if ( p ) { if ( p ) {
int i=0,len=0; int i=0,len=0;
char name_space[MAX_NAMESPACE_LEN]; char name_space[MAX_NAMESPACE_LEN];

View File

@ -663,8 +663,8 @@ static int compare_values(grib_runtime_options* options, grib_handle* handle1, g
double packingError1=0,packingError2=0; double packingError1=0,packingError2=0;
double value_tolerance=0; double value_tolerance=0;
grib_context* c=handle1->context; grib_context* c=handle1->context;
char* first_str = (handles_swapped==0? "1st" : "2nd"); const char* first_str = (handles_swapped==0? "1st" : "2nd");
char* second_str = (handles_swapped==0? "2nd" : "1st"); const char* second_str = (handles_swapped==0? "2nd" : "1st");
type1=type; type1=type;
type2=type; type2=type;

View File

@ -591,8 +591,8 @@ static int compare_values(grib_runtime_options* options,grib_handle* h1,grib_han
double packingError1=0,packingError2=0; double packingError1=0,packingError2=0;
double value_tolerance=0; double value_tolerance=0;
grib_context* c=h1->context; grib_context* c=h1->context;
char* first_str = (handles_swapped==0? "1st" : "2nd"); const char* first_str = (handles_swapped==0? "1st" : "2nd");
char* second_str = (handles_swapped==0? "2nd" : "1st"); const char* second_str = (handles_swapped==0? "2nd" : "1st");
type1=type; type1=type;
type2=type; type2=type;