X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Frrd_last.c;h=90da610ffaef42f041de5c98b5d8530efe6a9dc0;hb=271be77064640b1daa3408885d60b8bead1126ad;hp=0f9ab9b3b7dfd9b9c9068d24badb3a9169129306;hpb=818549a636c390fb4a8390a7e2195a52293cd56b;p=rrdtool.git diff --git a/src/rrd_last.c b/src/rrd_last.c index 0f9ab9b..90da610 100644 --- a/src/rrd_last.c +++ b/src/rrd_last.c @@ -8,34 +8,32 @@ #include "rrd_tool.h" -time_t -rrd_last(int argc, char **argv) +time_t rrd_last( + int argc, + char **argv) { - if(argc < 2){ + if (argc < 2) { rrd_set_error("please specify an rrd"); - return(-1); + return (-1); } - return( rrd_last_r(argv[1]) ); + return (rrd_last_r(argv[1])); } - -time_t -rrd_last_r(const char *filename) + +time_t rrd_last_r( + const char *filename) { - time_t lastup; - rrd_file_t* rrd_file; + time_t lastup = -1; + rrd_file_t *rrd_file; - rrd_t rrd; + rrd_t rrd; rrd_file = rrd_open(filename, &rrd, RRD_READONLY); - if (rrd_file == NULL) - return(-1); - - lastup = rrd.live_head->last_up; + if (rrd_file != NULL) { + lastup = rrd.live_head->last_up; + rrd_close(rrd_file); + } rrd_free(&rrd); - rrd_close(rrd_file); - return(lastup); + return (lastup); } - -