From: Sebastian Harl Date: Tue, 30 Oct 2012 06:24:02 +0000 (+0100) Subject: RRTimeslice: Don't encode invalid (0) intervals in the output function. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;ds=sidebyside;h=71a3564dffe1e1122d99e0f212f7a4a3f4991186;p=postrr.git RRTimeslice: Don't encode invalid (0) intervals in the output function. --- diff --git a/src/rrtimeslice.c b/src/rrtimeslice.c index 325d736..4f151d2 100644 --- a/src/rrtimeslice.c +++ b/src/rrtimeslice.c @@ -330,8 +330,6 @@ rrtimeslice_out(PG_FUNCTION_ARGS) { rrtimeslice_t *tslice; - Interval interval; - struct pg_tm tm; fsec_t fsec = 0; int tz = 0; @@ -364,6 +362,8 @@ rrtimeslice_out(PG_FUNCTION_ARGS) EncodeDateTime(&tm, fsec, &tz, &tz_str, DateStyle, buf_ts); if (! rrtimeslice_get_spec(tslice->tsid, &len, &num)) { + Interval interval; + memset(&interval, 0, sizeof(interval)); interval.time = len * USECS_PER_SEC; fsec = 0; @@ -372,14 +372,14 @@ rrtimeslice_out(PG_FUNCTION_ARGS) ereport(ERROR, ( errmsg("could not convert interval to tm") )); + + EncodeInterval(&tm, fsec, IntervalStyle, buf_l); } else { strncpy(buf_l, "ERR", sizeof(buf_l)); buf_l[sizeof(buf_l) - 1] = '\0'; } - EncodeInterval(&tm, fsec, IntervalStyle, buf_l); - snprintf(ts_str, sizeof(ts_str), "%s -%s (#%i)", buf_ts, buf_l, tslice->seq);