Compiler warnings with GCC 6.1.0

This commit is contained in:
Shahram Najm 2016-05-20 16:08:27 +01:00
parent 96f8858b33
commit bf96009cbf
3 changed files with 217 additions and 217 deletions

View File

@ -144,139 +144,139 @@ static void init_class(grib_accessor_class* c)
static void init(grib_accessor* a,const long l, grib_arguments* c)
{
grib_accessor_g1_increment* self = (grib_accessor_g1_increment*)a;
int n = 0;
self->directionIncrementGiven = grib_arguments_get_name(grib_handle_of_accessor(a),c,n++);
self->directionIncrement = grib_arguments_get_name(grib_handle_of_accessor(a),c,n++);
self->first = grib_arguments_get_name(grib_handle_of_accessor(a),c,n++);
self->last = grib_arguments_get_name(grib_handle_of_accessor(a),c,n++);
self->numberOfPoints = grib_arguments_get_name(grib_handle_of_accessor(a),c,n++);
grib_accessor_g1_increment* self = (grib_accessor_g1_increment*)a;
int n = 0;
self->directionIncrementGiven = grib_arguments_get_name(grib_handle_of_accessor(a),c,n++);
self->directionIncrement = grib_arguments_get_name(grib_handle_of_accessor(a),c,n++);
self->first = grib_arguments_get_name(grib_handle_of_accessor(a),c,n++);
self->last = grib_arguments_get_name(grib_handle_of_accessor(a),c,n++);
self->numberOfPoints = grib_arguments_get_name(grib_handle_of_accessor(a),c,n++);
}
static int unpack_double (grib_accessor* a, double* val, size_t *len)
{
grib_accessor_g1_increment* self = (grib_accessor_g1_increment*)a;
int ret = 0;
grib_accessor_g1_increment* self = (grib_accessor_g1_increment*)a;
int ret = 0;
long directionIncrementGiven=0;
long directionIncrement;
double first = 0;
double last = 0;
long numberOfPoints = 0;
long directionIncrementGiven=0;
long directionIncrement;
double first = 0;
double last = 0;
long numberOfPoints = 0;
if(*len < 1)
ret = GRIB_ARRAY_TOO_SMALL;
if(*len < 1)
ret = GRIB_ARRAY_TOO_SMALL;
if((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->directionIncrementGiven,&directionIncrementGiven))
!= GRIB_SUCCESS)
return ret;
if((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->directionIncrement,&directionIncrement))
!= GRIB_SUCCESS)
return ret;
if((ret = grib_get_double_internal(grib_handle_of_accessor(a), self->first,&first)) != GRIB_SUCCESS)
return ret;
if((ret = grib_get_double_internal(grib_handle_of_accessor(a), self->last,&last)) != GRIB_SUCCESS)
return ret;
if((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->directionIncrementGiven,&directionIncrementGiven))
!= GRIB_SUCCESS)
return ret;
if((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->directionIncrement,&directionIncrement))
!= GRIB_SUCCESS)
return ret;
if((ret = grib_get_double_internal(grib_handle_of_accessor(a), self->first,&first)) != GRIB_SUCCESS)
return ret;
if((ret = grib_get_double_internal(grib_handle_of_accessor(a), self->last,&last)) != GRIB_SUCCESS)
return ret;
if((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfPoints,&numberOfPoints))
!= GRIB_SUCCESS)
return ret;
if (!directionIncrementGiven || directionIncrement == GRIB_MISSING_LONG) {
*val = fabs(last-first)/(double)(numberOfPoints-1);
} else {
*val = (double)directionIncrement/1000.0;
}
if((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfPoints,&numberOfPoints))
!= GRIB_SUCCESS)
return ret;
if (!directionIncrementGiven || directionIncrement == GRIB_MISSING_LONG) {
*val = fabs(last-first)/(double)(numberOfPoints-1);
} else {
*val = (double)directionIncrement/1000.0;
}
#if 0
printf("unpack -- %s=%ld %s=%ld %s=%f %s=%f %s=%ld %s=%f\n",
self->directionIncrementGiven,directionIncrementGiven,
self->directionIncrement,directionIncrement,
self->last,last,
self->first,first,
self->numberOfPoints,numberOfPoints,
a->name,*val);
printf("unpack -- %s=%ld %s=%ld %s=%f %s=%f %s=%ld %s=%f\n",
self->directionIncrementGiven,directionIncrementGiven,
self->directionIncrement,directionIncrement,
self->last,last,
self->first,first,
self->numberOfPoints,numberOfPoints,
a->name,*val);
#endif
if (ret == GRIB_SUCCESS) *len = 1;
return ret;
if (ret == GRIB_SUCCESS) *len = 1;
return ret;
}
static int pack_double(grib_accessor* a, const double* val, size_t *len)
{
grib_accessor_g1_increment* self = (grib_accessor_g1_increment*)a;
int ret = 0;
long codedNumberOfPoints=0;
long directionIncrementGiven=0;
long directionIncrement;
double first = 0;
double last = 0;
long numberOfPoints = 0;
double incrementInMillidegrees;
ret = grib_get_double_internal(grib_handle_of_accessor(a), self->first,&first);
if(ret != GRIB_SUCCESS) {
grib_context_log(a->context, GRIB_LOG_ERROR, "Accessor %s cannont gather value for %s error %d \n", a->name, self->first, ret);
return ret;
}
ret = grib_get_double_internal(grib_handle_of_accessor(a), self->last,&last);
if(ret != GRIB_SUCCESS){
grib_context_log(a->context, GRIB_LOG_ERROR, "Accessor %s cannont gather value for %s error %d \n", a->name, self->last, ret);
return ret;
}
grib_accessor_g1_increment* self = (grib_accessor_g1_increment*)a;
int ret = 0;
long codedNumberOfPoints=0;
if((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->directionIncrementGiven,&directionIncrementGiven))
!= GRIB_SUCCESS){
grib_context_log(a->context, GRIB_LOG_ERROR, "Accessor %s cannont gather value for %s error %d \n", a->name, self->directionIncrementGiven, ret);
return ret;
}
numberOfPoints = 1+rint(fabs((last-first) / *val));
incrementInMillidegrees = *val * 1000;
if ((int)incrementInMillidegrees == incrementInMillidegrees ) {
directionIncrement=(int)incrementInMillidegrees;
} else {
directionIncrement=0xffffff;
directionIncrementGiven=0;
}
long directionIncrementGiven=0;
long directionIncrement;
double first = 0;
double last = 0;
long numberOfPoints = 0;
double incrementInMillidegrees;
ret = grib_set_long_internal(grib_handle_of_accessor(a), self->numberOfPoints,numberOfPoints);
if(ret )
grib_context_log(a->context, GRIB_LOG_ERROR, "Accessor %s cannont pack value for %s error %d \n", a->name, self->numberOfPoints, ret);
ret = grib_get_double_internal(grib_handle_of_accessor(a), self->first,&first);
if(ret != GRIB_SUCCESS) {
grib_context_log(a->context, GRIB_LOG_ERROR, "Accessor %s cannont gather value for %s error %d \n", a->name, self->first, ret);
return ret;
}
ret = grib_get_double_internal(grib_handle_of_accessor(a), self->last,&last);
if(ret != GRIB_SUCCESS){
grib_context_log(a->context, GRIB_LOG_ERROR, "Accessor %s cannont gather value for %s error %d \n", a->name, self->last, ret);
return ret;
}
grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfPoints,&codedNumberOfPoints);
ret = grib_set_long_internal(grib_handle_of_accessor(a), self->directionIncrement,directionIncrement);
if(ret )
grib_context_log(a->context, GRIB_LOG_ERROR, "Accessor %s cannont pack value for %s error %d \n", a->name, self->directionIncrement, ret);
ret = grib_set_long_internal(grib_handle_of_accessor(a), self->directionIncrementGiven,directionIncrementGiven);
if(ret )
grib_context_log(a->context, GRIB_LOG_ERROR, "Accessor %s cannont pack value for %s error %d \n", a->name, self->directionIncrementGiven, ret);
if((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->directionIncrementGiven,&directionIncrementGiven))
!= GRIB_SUCCESS){
grib_context_log(a->context, GRIB_LOG_ERROR, "Accessor %s cannont gather value for %s error %d \n", a->name, self->directionIncrementGiven, ret);
return ret;
}
numberOfPoints = 1+rint(fabs((last-first) / *val));
incrementInMillidegrees = *val * 1000;
if ((int)incrementInMillidegrees == incrementInMillidegrees ) {
directionIncrement=(int)incrementInMillidegrees;
} else {
directionIncrement=0xffffff;
directionIncrementGiven=0;
}
ret = grib_set_long_internal(grib_handle_of_accessor(a), self->numberOfPoints,numberOfPoints);
if(ret )
grib_context_log(a->context, GRIB_LOG_ERROR, "Accessor %s cannont pack value for %s error %d \n", a->name, self->numberOfPoints, ret);
grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfPoints,&codedNumberOfPoints);
ret = grib_set_long_internal(grib_handle_of_accessor(a), self->directionIncrement,directionIncrement);
if(ret )
grib_context_log(a->context, GRIB_LOG_ERROR, "Accessor %s cannont pack value for %s error %d \n", a->name, self->directionIncrement, ret);
ret = grib_set_long_internal(grib_handle_of_accessor(a), self->directionIncrementGiven,directionIncrementGiven);
if(ret )
grib_context_log(a->context, GRIB_LOG_ERROR, "Accessor %s cannont pack value for %s error %d \n", a->name, self->directionIncrementGiven, ret);
#if 0
printf("pack -- %s=%ld %s=%ld %s=%f %s=%f %s=%ld codedNumberOfPoints=%ld %s=%f\n",
self->directionIncrementGiven,directionIncrementGiven,
self->directionIncrement,directionIncrement,
self->last,last,
self->first,first,
self->numberOfPoints,numberOfPoints,
codedNumberOfPoints,
a->name,*val);
printf("pack -- %s=%ld %s=%ld %s=%f %s=%f %s=%ld codedNumberOfPoints=%ld %s=%f\n",
self->directionIncrementGiven,directionIncrementGiven,
self->directionIncrement,directionIncrement,
self->last,last,
self->first,first,
self->numberOfPoints,numberOfPoints,
codedNumberOfPoints,
a->name,*val);
#endif
if (ret == GRIB_SUCCESS) *len = 1;
if (ret == GRIB_SUCCESS) *len = 1;
return ret;
return ret;
}

View File

@ -148,64 +148,64 @@ static void init_class(grib_accessor_class* c)
static void init(grib_accessor* a,const long l, grib_arguments* c)
{
grib_accessor_latlon_increment* self = (grib_accessor_latlon_increment*)a;
int n = 0;
grib_accessor_latlon_increment* self = (grib_accessor_latlon_increment*)a;
int n = 0;
self->directionIncrementGiven = grib_arguments_get_name(grib_handle_of_accessor(a),c,n++);
self->directionIncrement = grib_arguments_get_name(grib_handle_of_accessor(a),c,n++);
self->scansPositively = grib_arguments_get_name(grib_handle_of_accessor(a),c,n++);
self->first = grib_arguments_get_name(grib_handle_of_accessor(a),c,n++);
self->last = grib_arguments_get_name(grib_handle_of_accessor(a),c,n++);
self->numberOfPoints = grib_arguments_get_name(grib_handle_of_accessor(a),c,n++);
self->angleMultiplier = grib_arguments_get_name(grib_handle_of_accessor(a),c,n++);
self->angleDivisor = grib_arguments_get_name(grib_handle_of_accessor(a),c,n++);
self->isLongitude=grib_arguments_get_long(grib_handle_of_accessor(a), c,n++);
self->directionIncrementGiven = grib_arguments_get_name(grib_handle_of_accessor(a),c,n++);
self->directionIncrement = grib_arguments_get_name(grib_handle_of_accessor(a),c,n++);
self->scansPositively = grib_arguments_get_name(grib_handle_of_accessor(a),c,n++);
self->first = grib_arguments_get_name(grib_handle_of_accessor(a),c,n++);
self->last = grib_arguments_get_name(grib_handle_of_accessor(a),c,n++);
self->numberOfPoints = grib_arguments_get_name(grib_handle_of_accessor(a),c,n++);
self->angleMultiplier = grib_arguments_get_name(grib_handle_of_accessor(a),c,n++);
self->angleDivisor = grib_arguments_get_name(grib_handle_of_accessor(a),c,n++);
self->isLongitude=grib_arguments_get_long(grib_handle_of_accessor(a), c,n++);
}
static int unpack_double (grib_accessor* a, double* val, size_t *len)
{
grib_accessor_latlon_increment* self = (grib_accessor_latlon_increment*)a;
int ret = 0;
grib_accessor_latlon_increment* self = (grib_accessor_latlon_increment*)a;
int ret = 0;
long directionIncrementGiven=0;
long directionIncrement=0;
long angleDivisor=1;
long angleMultiplier=1;
double first = 0;
double last = 0;
long numberOfPoints = 0;
long scansPositively = 0;
long directionIncrementGiven=0;
long directionIncrement=0;
long angleDivisor=1;
long angleMultiplier=1;
double first = 0;
double last = 0;
long numberOfPoints = 0;
long scansPositively = 0;
if(*len < 1) return GRIB_ARRAY_TOO_SMALL;
if(*len < 1) return GRIB_ARRAY_TOO_SMALL;
if((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->directionIncrementGiven,&directionIncrementGiven)) != GRIB_SUCCESS)
return ret;
return ret;
if((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->scansPositively,&scansPositively)) != GRIB_SUCCESS)
return ret;
return ret;
if((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->directionIncrement,&directionIncrement)) != GRIB_SUCCESS)
return ret;
return ret;
if((ret = grib_get_double_internal(grib_handle_of_accessor(a), self->first,&first)) != GRIB_SUCCESS)
return ret;
if((ret = grib_get_double_internal(grib_handle_of_accessor(a), self->first,&first)) != GRIB_SUCCESS)
return ret;
if((ret = grib_get_double_internal(grib_handle_of_accessor(a), self->last,&last)) != GRIB_SUCCESS)
return ret;
if((ret = grib_get_double_internal(grib_handle_of_accessor(a), self->last,&last)) != GRIB_SUCCESS)
return ret;
if((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfPoints,&numberOfPoints)) != GRIB_SUCCESS)
return ret;
return ret;
if((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->angleMultiplier,&angleMultiplier)) != GRIB_SUCCESS)
return ret;
if((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->angleMultiplier,&angleMultiplier)) != GRIB_SUCCESS)
return ret;
if((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->angleDivisor,&angleDivisor)) != GRIB_SUCCESS)
return ret;
return ret;
if (self->isLongitude) {
if (last < first && scansPositively) last+=360;
if (self->isLongitude) {
if (last < first && scansPositively) last+=360;
/*if (last > first && !scansPositively) first-=360;*/
}
}
if (!directionIncrementGiven && numberOfPoints != GRIB_MISSING_LONG)
{
@ -236,16 +236,16 @@ static int unpack_double (grib_accessor* a, double* val, size_t *len)
}
else if (numberOfPoints == GRIB_MISSING_LONG)
{
*val = GRIB_MISSING_DOUBLE;
*val = GRIB_MISSING_DOUBLE;
}
else
{
Assert(angleDivisor!=0);
*val = (double)directionIncrement/angleDivisor*angleMultiplier;
}
Assert(angleDivisor!=0);
*val = (double)directionIncrement/angleDivisor*angleMultiplier;
}
#if 0
printf("unpack -- %s=%ld %s=%ld %s=%f %s=%f %s=%ld %s=%f\n",
printf("unpack -- %s=%ld %s=%ld %s=%f %s=%f %s=%ld %s=%f\n",
self->directionIncrementGiven,directionIncrementGiven,
self->directionIncrement,directionIncrement,
self->last,last,
@ -253,82 +253,82 @@ static int unpack_double (grib_accessor* a, double* val, size_t *len)
self->numberOfPoints,numberOfPoints,
a->name,*val);
#endif
if (ret == GRIB_SUCCESS) *len = 1;
if (ret == GRIB_SUCCESS) *len = 1;
return ret;
return ret;
}
static int pack_double(grib_accessor* a, const double* val, size_t *len)
{
grib_accessor_latlon_increment* self = (grib_accessor_latlon_increment*)a;
int ret = 0;
long codedNumberOfPoints=0;
grib_accessor_latlon_increment* self = (grib_accessor_latlon_increment*)a;
int ret = 0;
long codedNumberOfPoints=0;
long directionIncrementGiven=0;
long directionIncrement=0;
long angleDivisor=1;
long angleMultiplier=1;
double first = 0;
double last = 0;
long numberOfPoints = 0;
/* long numberOfPointsInternal = 0; */
long scansPositively = 0;
double directionIncrementDouble=0;
long directionIncrementGiven=0;
long directionIncrement=0;
long angleDivisor=1;
long angleMultiplier=1;
double first = 0;
double last = 0;
long numberOfPoints = 0;
/* long numberOfPointsInternal = 0; */
long scansPositively = 0;
double directionIncrementDouble=0;
ret = grib_get_double_internal(grib_handle_of_accessor(a), self->first,&first);
if(ret != GRIB_SUCCESS) return ret;
ret = grib_get_double_internal(grib_handle_of_accessor(a), self->last,&last);
if(ret != GRIB_SUCCESS) return ret;
ret = grib_get_double_internal(grib_handle_of_accessor(a), self->first,&first);
if(ret != GRIB_SUCCESS) return ret;
if((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->directionIncrementGiven,&directionIncrementGiven))
!= GRIB_SUCCESS) return ret;
ret = grib_get_double_internal(grib_handle_of_accessor(a), self->last,&last);
if(ret != GRIB_SUCCESS) return ret;
if((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfPoints,&numberOfPoints)) != GRIB_SUCCESS) return ret;
if((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->directionIncrementGiven,&directionIncrementGiven))
!= GRIB_SUCCESS) return ret;
if((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->scansPositively,&scansPositively))
!= GRIB_SUCCESS) return ret;
if((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfPoints,&numberOfPoints)) != GRIB_SUCCESS) return ret;
if((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->angleMultiplier,&angleMultiplier)) != GRIB_SUCCESS) return ret;
if((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->scansPositively,&scansPositively))
!= GRIB_SUCCESS) return ret;
if((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->angleDivisor,&angleDivisor)) != GRIB_SUCCESS) return ret;
if((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->angleMultiplier,&angleMultiplier)) != GRIB_SUCCESS) return ret;
if (self->isLongitude) {
if (last < first && scansPositively) last+=360;
if (last > first && !scansPositively) first-=360;
}
if((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->angleDivisor,&angleDivisor)) != GRIB_SUCCESS) return ret;
if (*val == GRIB_MISSING_DOUBLE) {
directionIncrement=GRIB_MISSING_LONG;
directionIncrementGiven=1;
numberOfPoints=GRIB_MISSING_LONG;
} else {
/* numberOfPointsInternal = 1+rint(fabs((last-first) / *val)); */
directionIncrementDouble = rint (*val * (double)angleDivisor / (double)angleMultiplier);
directionIncrement=(long)directionIncrementDouble;
if (directionIncrement == 0 ) {
directionIncrement=GRIB_MISSING_LONG;
directionIncrementGiven=0;
if (self->isLongitude) {
if (last < first && scansPositively) last+=360;
if (last > first && !scansPositively) first-=360;
}
}
/*ret = grib_set_long_internal(grib_handle_of_accessor(a), self->numberOfPoints,numberOfPoints);
if (*val == GRIB_MISSING_DOUBLE) {
directionIncrement=GRIB_MISSING_LONG;
directionIncrementGiven=1;
numberOfPoints=GRIB_MISSING_LONG;
} else {
/* numberOfPointsInternal = 1+rint(fabs((last-first) / *val)); */
directionIncrementDouble = rint (*val * (double)angleDivisor / (double)angleMultiplier);
directionIncrement=(long)directionIncrementDouble;
if (directionIncrement == 0 ) {
directionIncrement=GRIB_MISSING_LONG;
directionIncrementGiven=0;
}
}
/*ret = grib_set_long_internal(grib_handle_of_accessor(a), self->numberOfPoints,numberOfPoints);
if(ret )
grib_context_log(a->context, GRIB_LOG_ERROR, "Accessor %s cannot pack value for %s error %d \n", a->name, self->numberOfPoints, ret);
*/
*/
grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfPoints,&codedNumberOfPoints);
grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfPoints,&codedNumberOfPoints);
ret = grib_set_long_internal(grib_handle_of_accessor(a), self->directionIncrement,directionIncrement);
if(ret ) return ret;
ret = grib_set_long_internal(grib_handle_of_accessor(a), self->directionIncrement,directionIncrement);
if(ret ) return ret;
ret = grib_set_long_internal(grib_handle_of_accessor(a), self->directionIncrementGiven,directionIncrementGiven);
if(ret )return ret;
ret = grib_set_long_internal(grib_handle_of_accessor(a), self->directionIncrementGiven,directionIncrementGiven);
if(ret )return ret;
#if 0
printf("pack -- %s=%ld %s=%ld \n ------- %s=%f %s=%f \n ------- %s=%ld codedNumberOfPoints=%ld %s=%f\n",
printf("pack -- %s=%ld %s=%ld \n ------- %s=%f %s=%f \n ------- %s=%ld codedNumberOfPoints=%ld %s=%f\n",
self->directionIncrementGiven,directionIncrementGiven,
self->directionIncrement,directionIncrement,
self->last,last,
@ -337,17 +337,17 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len)
codedNumberOfPoints,
a->name,*val);
#endif
if (ret == GRIB_SUCCESS) *len = 1;
if (ret == GRIB_SUCCESS) *len = 1;
return ret;
return ret;
}
static int is_missing(grib_accessor* a){
size_t len=1;
double val=0;
size_t len=1;
double val=0;
unpack_double(a, &val, &len);
unpack_double(a, &val, &len);
return (val == GRIB_MISSING_DOUBLE);
return (val == GRIB_MISSING_DOUBLE);
}

View File

@ -126,17 +126,17 @@ static grib_handle* grib_handle_new_from_file_x(grib_context* c,FILE* f,int mode
if (mode==MODE_BUFR)
return bufr_new_from_file(c,f,err);
if (mode==MODE_METAR)
return metar_new_from_file(c,f,err);
if (mode==MODE_METAR)
return metar_new_from_file(c,f,err);
if (mode==MODE_TAF)
return taf_new_from_file(c,f,err);
if (mode==MODE_TAF)
return taf_new_from_file(c,f,err);
if (mode==MODE_GRIB)
return grib_new_from_file(c,f,headers_only,err);
if (mode==MODE_GRIB)
return grib_new_from_file(c,f,headers_only,err);
Assert(!"grib_handle_new_from_file_x: unknown mode");
return NULL;
return NULL;
}
int grib_tool(int argc, char **argv)