From: Tobias Oetiker Date: Mon, 19 Nov 2012 08:09:15 +0000 (+0100) Subject: properly fix handling of time_t size in rrd_restore X-Git-Tag: 1.4.8~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=774e1aec924a48a6299033adc173387e104827bc;p=thirdparty%2Frrdtool-1.x.git properly fix handling of time_t size in rrd_restore --- diff --git a/configure.ac b/configure.ac index a1b6c582..7d81fe07 100644 --- a/configure.ac +++ b/configure.ac @@ -478,23 +478,10 @@ AC_LINK_IFELSE( ) ] ) +AC_LANG_POP(C) dnl is time_t 32 of 64 bit ? -AC_DEFINE([TIME_T_IS_32BIT], [], [time_t is 32bit]) -AC_DEFINE([TIME_T_IS_64BIT], [], [time_t is 64bit]) -AC_MSG_CHECKING([the type of time_t]) AC_CHECK_SIZEOF([time_t]) -if test "x$ac_cv_sizeof_time_t" = "x4"; then - AC_MSG_RESULT([time_t is 32 bit]) - AC_DEFINE([TIME_T_IS_32BIT]) -elif test "x$ac_cv_sizeof_time_t" = "x8"; then - AC_MSG_RESULT([time_t is 64 bit]) - AC_DEFINE([TIME_T_IS_64BIT]) -else - AC_MSG_ERROR([can not figure type of time_t]) -fi - -AC_LANG_POP(C) CONFIGURE_PART(Find 3rd-Party Libraries) diff --git a/src/rrd_restore.c b/src/rrd_restore.c index 61174e3e..c7decec0 100644 --- a/src/rrd_restore.c +++ b/src/rrd_restore.c @@ -227,18 +227,12 @@ static int get_xml_time_t( time_t temp; if ((text = get_xml_text(reader)) != NULL){ errno = 0; -#ifdef TIME_T_IS_32BIT +#if SIZEOF_TIME_T == 4 temp = strtol((char *)text,NULL, 0); -#else -#ifdef TIME_T_IS_64BIT +#elif SIZEOF_TIME_T == 8 temp = strtoll((char *)text,NULL, 0); #else - if (sizeof(time_t) == 4){ - temp = strtol((char *)text,NULL, 0); - } else { - temp = strtoll((char *)text,NULL, 0); - } -#endif +#error "Don't know how to deal with TIME_T other than 4 or 8 bytes" #endif if (errno>0){ rrd_set_error("ling %d: get_xml_time_t from '%s' %s",