From: Manuel Luis SanmartĂ­n Rozada Date: Thu, 19 Jun 2014 17:14:53 +0000 (+0200) Subject: cmd PUTNOTIF time option: handle double values. X-Git-Tag: collectd-5.5.0~280^2 X-Git-Url: https://git.octo.it/?p=collectd.git;a=commitdiff_plain;h=ada80db25b508f681fd021cd4cd45d8fd29d8f59 cmd PUTNOTIF time option: handle double values. --- diff --git a/src/utils_cmd_putnotif.c b/src/utils_cmd_putnotif.c index 3496ca93..d3cf3834 100644 --- a/src/utils_cmd_putnotif.c +++ b/src/utils_cmd_putnotif.c @@ -49,13 +49,18 @@ static int set_option_severity (notification_t *n, const char *value) static int set_option_time (notification_t *n, const char *value) { - time_t tmp; - - tmp = (time_t) atoi (value); - if (tmp <= 0) + char *endptr = NULL; + double tmp; + + errno = 0; + tmp = strtod (value, &endptr); + if ((errno != 0) /* Overflow */ + || (endptr == value) /* Invalid string */ + || (endptr == NULL) /* This should not happen */ + || (*endptr != 0)) /* Trailing chars */ return (-1); - n->time = TIME_T_TO_CDTIME_T(tmp); + n->time = DOUBLE_TO_CDTIME_T (tmp); return (0); } /* int set_option_time */