src/vnstat.h:7:33: warning: identifier ‘delete’ conflicts with C++ keyword [-Wc++-compat]
src/ifinfo.c:61:13: warning: request for implicit conversion from ‘void *’ to ‘char *’ not permitted in C++ [-Wc++-compat]
src/dbxml.c:110:16: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
src/dbjson.c:134:16: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
src/common.c:270:6: warning: function might be candidate for attribute ‘noreturn’ [-Wsuggest-attribute=noreturn]
src/misc.c:309:32: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
src/ibw.c:34:5: warning: request for implicit conversion from ‘void *’ to ‘ibwnode * {aka struct ibwnode *}’ not permitted in C++ [-Wc++-compat]
src/image.c:68:17: warning: passing argument 1 of ‘colorinitcheck’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
src/dbcache.c:26:4: warning: request for implicit conversion from ‘void *’ to ‘datanode * {aka struct datanode *}’ not permitted in C++ [-Wc++-compat]
src/ifinfo.c:358:4: warning: unsuffixed float constant [-Wunsuffixed-float-constants]
src/common.c:173:14: warning: nested extern declaration of ‘timezone’ [-Wnested-externs]
src/common.c:173:14: warning: redundant redeclaration of ‘timezone’ [-Wredundant-decls]
{
struct tm d;
#if defined(_SVID_SOURCE) || defined(_XOPEN_SOURCE) || defined(__linux__)
- extern long timezone;
+ /* extern long timezone; */
#else
int timezone = 0;
#endif
return 1;
}
+__attribute__((noreturn))
void panicexit(const char *sourcefile, const int sourceline)
{
snprintf(errorstring, 512, "Unexpected error (%s), exiting. (%s:%d)\n", strerror(errno), sourcefile, sourceline);
uint64_t mbkbtokb(uint64_t mb, uint64_t kb);
char *strncpy_nt(char *dest, const char *src, size_t n);
int isnumeric(const char *s);
-void panicexit(const char *sourcefile, const int sourceline);
+void panicexit(const char *sourcefile, const int sourceline) __attribute__((noreturn));
char *getversion(void);
/* global variables */
}
/* add new node if not in list */
- n = malloc(sizeof(datanode));
+ n = (datanode *) malloc(sizeof(datanode));
if (n == NULL) {
return 0;
}
/* add new node if not in list */
- n = malloc(sizeof(datanode));
+ n = (datanode *) malloc(sizeof(datanode));
if (n == NULL) {
return 0;
void jsondate(time_t *date, int type)
{
struct tm *d;
- char *type1 = "\"date\":{\"year\":%d,\"month\":%d,\"day\":%d}";
- char *type2 = "\"date\":{\"year\":%d,\"month\":%d,\"day\":%d},\"time\":{\"hour\":%d,\"minutes\":%d}";
- char *type3 = "\"date\":{\"year\":%d,\"month\":%d}";
+ const char *type1 = "\"date\":{\"year\":%d,\"month\":%d,\"day\":%d}";
+ const char *type2 = "\"date\":{\"year\":%d,\"month\":%d,\"day\":%d},\"time\":{\"hour\":%d,\"minutes\":%d}";
+ const char *type3 = "\"date\":{\"year\":%d,\"month\":%d}";
d = localtime(date);
void xmldate(time_t *date, int type)
{
struct tm *d;
- char *type1 = "<date><year>%d</year><month>%02d</month><day>%02d</day></date>";
- char *type2 = "<date><year>%d</year><month>%02d</month><day>%02d</day></date><time><hour>%02d</hour><minute>%02d</minute></time>";
- char *type3 = "<date><year>%d</year><month>%02d</month></date>";
+ const char *type1 = "<date><year>%d</year><month>%02d</month><day>%02d</day></date>";
+ const char *type2 = "<date><year>%d</year><month>%02d</month><day>%02d</day></date><time><hour>%02d</hour><minute>%02d</minute></time>";
+ const char *type3 = "<date><year>%d</year><month>%02d</month></date>";
d = localtime(date);
/* add new node if list is empty */
if (p == NULL) {
- n = malloc(sizeof(ibwnode));
+ n = (ibwnode *) malloc(sizeof(ibwnode));
if (n == NULL) {
return 0;
}
/* add new node if not found */
- n = malloc(sizeof(ibwnode));
+ n = (ibwnode *) malloc(sizeof(ibwnode));
if (n == NULL) {
return 0;
#endif
/* initialize list */
- *ifacelist = malloc(sizeof(char));
+ *ifacelist = (char *) malloc(sizeof(char));
if (*ifacelist == NULL) {
panicexit(__FILE__, __LINE__);
}
sscanf(procline, "%63s", temp);
if (strlen(temp)>0 && (isdigit(temp[(strlen(temp)-1)]) || temp[(strlen(temp)-1)]==':')) {
sscanf(temp, "%31[^':']s", interface);
- *ifacelist = realloc(*ifacelist, ( ( strlen(*ifacelist) + strlen(interface) + 2 ) * sizeof(char)) );
+ *ifacelist = (char *) realloc(*ifacelist, ( ( strlen(*ifacelist) + strlen(interface) + 2 ) * sizeof(char)) );
if (*ifacelist == NULL) {
panicexit(__FILE__, __LINE__);
}
speed = getifspeed(interface);
if (speed > 0) {
snprintf(temp, 64, "(%u Mbit) ", speed);
- *ifacelist = realloc(*ifacelist, ( ( strlen(*ifacelist) + strlen(temp) + 1 ) * sizeof(char)) );
+ *ifacelist = (char *) realloc(*ifacelist, ( ( strlen(*ifacelist) + strlen(temp) + 1 ) * sizeof(char)) );
if (*ifacelist == NULL) {
panicexit(__FILE__, __LINE__);
}
if (di->d_name[0] == '.' || strlen(di->d_name) > 31) {
continue;
}
- *ifacelist = realloc(*ifacelist, ( ( strlen(*ifacelist) + strlen(di->d_name) + 2 ) * sizeof(char)) );
+ *ifacelist = (char *) realloc(*ifacelist, ( ( strlen(*ifacelist) + strlen(di->d_name) + 2 ) * sizeof(char)) );
if (*ifacelist == NULL) {
panicexit(__FILE__, __LINE__);
}
speed = getifspeed(di->d_name);
if (speed > 0) {
snprintf(temp, 64, "(%u Mbit) ", speed);
- *ifacelist = realloc(*ifacelist, ( ( strlen(*ifacelist) + strlen(temp) + 1 ) * sizeof(char)) );
+ *ifacelist = (char *) realloc(*ifacelist, ( ( strlen(*ifacelist) + strlen(temp) + 1 ) * sizeof(char)) );
if (*ifacelist == NULL) {
panicexit(__FILE__, __LINE__);
}
/* calculate maximum possible transfer since last update based on set maximum rate */
/* and add 10% in order to be on the safe side */
- maxtransfer = ceil((maxbw/(float)8)*interval*(float)1.1);
+ maxtransfer = ceilf((maxbw/8.0f)*interval*1.1f);
if (debug)
printf("interval: %"PRIu64" maxbw: %"PRIu32" maxrate: %"PRIu64" rxc: %"PRIu64" txc: %"PRIu64"\n", (uint64_t)interval, maxbw, maxtransfer, rxchange, txchange);
colorinitcheck("ctxd", ic->ctxd, cfg.ctxd, rgb);
}
-void colorinitcheck(char *color, int value, char *cfgtext, int *rgb)
+void colorinitcheck(const char *color, int value, const char *cfgtext, const int *rgb)
{
if (value==-1) {
printf("Error: ImageColorAllocate failed.\n");
void initimagecontent(IMAGECONTENT *ic);
void drawimage(IMAGECONTENT *ic);
void colorinit(IMAGECONTENT *ic);
-void colorinitcheck(char *color, int value, char *cfgtext, int *rgb);
+void colorinitcheck(const char *color, int value, const char *cfgtext, const int *rgb);
void layoutinit(IMAGECONTENT *ic, char *title, int width, int height);
void drawlegend(IMAGECONTENT *ic, int x, int y);
void drawbar(IMAGECONTENT *ic, int x, int y, int len, uint64_t rx, int rxk, uint64_t tx, int txk, uint64_t max);
return result;
}
-char *getunitprefix(int index)
+const char *getunitprefix(int index)
{
- static char *unitprefix[] = { "na", "KiB", "MiB", "GiB", "TiB",
+ static const char *unitprefix[] = { "na", "KiB", "MiB", "GiB", "TiB",
"KB", "MB", "GB", "TB" };
if (index>UNITPREFIXCOUNT) {
}
}
-char *getrateunitprefix(int unitmode, int index)
+const char *getrateunitprefix(int unitmode, int index)
{
- static char *rateunitprefix[] = { "na", "KiB/s", "MiB/s", "GiB/s", "TiB/s",
+ static const char *rateunitprefix[] = { "na", "KiB/s", "MiB/s", "GiB/s", "TiB/s",
"KB/s", "MB/s", "GB/s", "TB/s",
"Kibit/s", "Mibit/s", "Gibit/s", "Tibit/s",
"kbit/s", "Mbit/s", "Gbit/s", "Tbit/s" };
char *getrate(uint64_t mb, uint64_t kb, uint32_t interval, int len);
char *gettrafficrate(uint64_t bytes, uint32_t interval, int len);
uint64_t getscale(uint64_t kb);
-char *getunitprefix(int index);
-char *getrateunitprefix(int unitmode, int index);
+const char *getunitprefix(int index);
+const char *getrateunitprefix(int unitmode, int index);
uint64_t getunitdivisor(int unitmode, int index);
char *getratestring(uint64_t rate, int len, int declen, int unitmode);
int getpadding(int len, char *str);
printcfgfile();
return 0;
} else if (strcmp(argv[currentarg],"--delete")==0) {
- p.delete=1;
+ p.del=1;
p.query=0;
} else if (strcmp(argv[currentarg],"--iflist")==0) {
getiflist(&p.ifacelist, 1);
p->traffic = 0;
p->livetraffic = 0;
p->defaultiface = 1;
- p->delete=0;
+ p->del=0;
p->livemode = 0;
p->ifacelist = NULL;
p->cfgfile[0] = '\0';
void handledelete(PARAMS *p)
{
- if (!p->delete) {
+ if (!p->del) {
return;
}
typedef struct {
int update, query, newdb, reset, sync, merged, savemerged, import;
int create, active, files, force, cleartop, rebuildtotal, traffic;
- int livetraffic, defaultiface, delete, livemode;
+ int livetraffic, defaultiface, del, livemode;
char interface[32], dirname[512], nick[32], filename[512];
char definterface[32], cfgfile[512], *ifacelist, jsonmode, xmlmode;
} PARAMS;