Skip to content
Snippets Groups Projects
Commit 827927e1 authored by Thomas Jahns's avatar Thomas Jahns :cartwheel:
Browse files

Tell gcc about the value range.

* Otherwise, gcc assumes large numerical values of the time stamp
  components might lead to truncation of unitstr_.
parent b66bd535
No related branches found
No related tags found
2 merge requests!91Add alternative code path for huge buffers.,!89Miscellaneous fixes and CDI-PIO improvements
......@@ -4,6 +4,7 @@
#ifdef HAVE_LIBNETCDF
#include <assert.h>
#include <stdio.h>
#include <string.h>
......@@ -88,8 +89,11 @@ cdfGetTimeUnits(taxis_t *taxis)
timeunit = TUNIT_HOUR;
char *unitstr_ = ptaxisAllocUnits(taxis, CDF_MAX_TIME_UNIT_STR);
snprintf(unitstr_, CDF_MAX_TIME_UNIT_STR, "%s since %d-%d-%d %02d:%02d:%02d", tunitNamePtr(timeunit), year, month, day,
hour, minute, second);
assert(month >= 1 && month <= 12 && day > 0 && day <=31 &&
hour >= 0 && hour <= 24 && minute >= 0 && minute < 60
&& second >= 0 && second <= 60);
snprintf(unitstr_, CDF_MAX_TIME_UNIT_STR, "%s since %d-%d-%d %02d:%02d:%02d", tunitNamePtr(timeunit), year, month&31, day&63,
hour&63, minute&63, second&63);
unitstr = unitstr_;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment