]> granicus.if.org Git - vnstat/commitdiff
fix cppcheck unreadVariable findings
authorTeemu Toivola <git@humdi.net>
Mon, 16 Sep 2019 17:24:59 +0000 (20:24 +0300)
committerTeemu Toivola <git@humdi.net>
Mon, 16 Sep 2019 17:24:59 +0000 (20:24 +0300)
src/dbshow.c
src/image.c

index 84ede0acb6e6d9305e1d1a06a20fef1621f07c2b..62e2aa5efdf6d3270e558785539257710eb17c61 100644 (file)
@@ -336,7 +336,6 @@ void showlist(const interfaceinfo *interface, const char *listname, const char *
        }
 
        daybuff[0] = '\0';
-       e_rx = e_tx = e_secs = 0;
 
        if (!db_getdata_range(&datalist, &datainfo, interface->name, listname, (uint32_t)limit, databegin, dataend)) {
                printf("Error: Failed to fetch %s data.\n", titlename);
@@ -452,6 +451,7 @@ void showlist(const interfaceinfo *interface, const char *listname, const char *
                printf(" | %s", getvalue(datalist_i->tx, 11, RT_Normal));
                printf(" | %s", getvalue(datalist_i->rx + datalist_i->tx, 11, RT_Normal));
                if (cfg.ostyle == 3) {
+                       e_secs = 0;
                        if (datalist_i->next == NULL && issametimeslot(listtype, datalist_i->timestamp, interface->updated)) {
                                d = localtime(&interface->updated);
                                if (listtype == LT_Day) {
index 3b665ea131fb65c2f0725043fa3c3acec419fd19..f2f13740328e14440ab854fcb88e1d7fe93d704a 100644 (file)
@@ -485,7 +485,7 @@ void drawlist(IMAGECONTENT *ic, const char *listname)
        int textx, texty, offsetx = 0, offsety = 0;
        int width, height, headermod, i = 1, rowcount = 0;
        int32_t limit;
-       uint64_t e_rx, e_tx, e_secs = 86400, div, mult;
+       uint64_t e_rx, e_tx, e_secs, div, mult;
        char buffer[512], datebuff[16], daybuff[16];
        char stampformat[64], titlename[16], colname[8];
        struct tm *d;
@@ -538,7 +538,6 @@ void drawlist(IMAGECONTENT *ic, const char *listname)
        }
 
        daybuff[0] = '\0';
-       e_rx = e_tx = 0;
 
        if (!db_getdata_range(&datalist, &datainfo, ic->interface.name, listname, (uint32_t)limit, ic->databegin, ic->dataend)) {
                printf("Error: Failed to fetch %s data.\n", "day");
@@ -700,6 +699,7 @@ void drawlist(IMAGECONTENT *ic, const char *listname)
                strncat(buffer, getvalue(datalist_i->rx + datalist_i->tx, 10, RT_Normal), 32);
                if (cfg.ostyle > 2) {
                        strcat(buffer, "  ");
+                       e_secs = 0;
                        if (datalist_i->next == NULL && issametimeslot(listtype, datalist_i->timestamp, ic->interface.updated)) {
                                d = localtime(&ic->interface.updated);
                                if (listtype == LT_Day) {