Add asserts in debug mode for offsets

This commit is contained in:
Shahram Najm 2018-07-25 09:48:59 +01:00
parent 27cba79788
commit ea8602e0d0
3 changed files with 5 additions and 2 deletions

View File

@ -199,6 +199,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t *len)
NS=(MS+1)*(MS+2);
if ( bpv != 0 ) {
DebugAssert( offsetAfterData > offsetBeforeData );
*val =((offsetAfterData-offsetBeforeData)*8-unusedBits+NS*(bpv-32))/bpv;
} else {
if((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfValues,&numberOfValues)) != GRIB_SUCCESS)

View File

@ -176,6 +176,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t *len)
return ret;
if ( bpv != 0 ) {
DebugAssert( offsetAfterData > offsetBeforeData );
*val=((offsetAfterData-offsetBeforeData)*8-unusedBits)/bpv;
} else {
if((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfValues,&numberOfValues)) != GRIB_SUCCESS)

View File

@ -177,8 +177,9 @@ static int unpack_long(grib_accessor* a, long* val, size_t *len)
return ret;
if ( bpv != 0 ) {
grib_context_log(a->context,GRIB_LOG_DEBUG,"grib_accessor_number_of_coded_values: offsetAfterData=%ld offsetBeforeData=%ld unusedBits=%ld bpv=%ld\n",
offsetAfterData,offsetBeforeData,unusedBits,bpv);
grib_context_log(a->context,GRIB_LOG_DEBUG,"grib_accessor_number_of_coded_values: offsetAfterData=%ld offsetBeforeData=%ld unusedBits=%ld bpv=%ld\n",
offsetAfterData,offsetBeforeData,unusedBits,bpv);
DebugAssert( offsetAfterData > offsetBeforeData );
*val=((offsetAfterData-offsetBeforeData)*8-unusedBits)/bpv;
} else {
if((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfValues,&numberOfValues)) != GRIB_SUCCESS)