int errorCode = function(gribHandle, key, __VA_ARGS__);\
int errorCode = (int)function(gribHandle, key, __VA_ARGS__);\
if(errorCode)\
{\
fprintf(stderr, "%s:%d: Error in function `%s`: `%s` returned error code %d for key \"%s\"", __FILE__, __LINE__, __func__, #function, errorCode, key);\
...
...
@@ -211,13 +211,13 @@ static int addSecondsToDate(struct tm* me, long long amount)
//It is irrelevant here whether days are zero or one based, the correction would have be undone again so that it is effectless.
longlongseconds=((me->tm_mday*24ll+me->tm_hour)*60+me->tm_min)*60+me->tm_sec;//The portion of the date that uses fixed increments.
seconds+=amount;
me->tm_mday=seconds/24/60/60;
seconds-=me->tm_mday*24*60*60;
me->tm_hour=seconds/60/60;
seconds-=me->tm_hour*60*60;
me->tm_min=seconds/60;
seconds-=me->tm_min*60;
me->tm_sec=seconds;
me->tm_mday=(int)(seconds/24/60/60);
seconds-=(longlong)me->tm_mday*24*60*60;
me->tm_hour=(int)(seconds/60/60);
seconds-=(longlong)me->tm_hour*60*60;
me->tm_min=(int)(seconds/60);
seconds-=(longlong)(me->tm_min*60);
me->tm_sec=(int)seconds;
returnnormalizeDays(me);
}
...
...
@@ -225,9 +225,9 @@ static void addMonthsToDate(struct tm* me, long long amount)
{
longlongmonths=me->tm_year*12ll+me->tm_mon;
months+=amount;
me->tm_year=months/12;
months-=me->tm_year*12;
me->tm_mon=months;
me->tm_year=(int)(months/12);
months-=(longlong)me->tm_year*12;
me->tm_mon=(int)months;
}
//unit is a value according to code table 4.4 of the GRIB2 specification, returns non-zero on error
currentPosition=memchr(currentPosition,'G',size-(currentPosition-data)-3);//-3 to ensure that we don't overrun the buffer during the strncmp() call.
currentPosition=memchr(currentPosition,'G',size-(size_t)(currentPosition-data)-3);//-3 to ensure that we don't overrun the buffer during the strncmp() call.