}
END_TEST
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wused-but-marked-unused"
START_TEST(dmonth_return_within_range)
{
int m;
ck_assert_int_le(m, 31);
}
END_TEST
+#pragma clang diagnostic pop
START_TEST(leapyears_are_known)
{
timeused("something", 0);
fflush(stdout);
- len = read(pipe, buffer, 512);
+ len = (int)read(pipe, buffer, 512);
ck_assert_int_gt(len, 0);
ck_assert_ptr_ne(strstr(buffer, "something() in 0"), NULL);
}
END_TEST
+__attribute__((noreturn))
START_TEST(can_panic)
{
suppress_output();
ret = db_open_rw(1);
ck_assert_int_eq(ret, 1);
- ret = addinterfaces(&s);
+ ret = (int)addinterfaces(&s);
ck_assert_int_eq(ret, 2);
ck_assert_int_eq(db_getinterfacecountbyname("ethone"), 1);
ret = db_open_rw(1);
ck_assert_int_eq(ret, 1);
- ret = addinterfaces(&s);
+ ret = (int)addinterfaces(&s);
ck_assert_int_eq(ret, 2);
ck_assert_int_eq(db_getinterfacecountbyname("ethone"), 1);
fake_proc_net_dev("a", "eththree", 9, 10, 11, 12);
- ret = addinterfaces(&s);
+ ret = (int)addinterfaces(&s);
ck_assert_int_eq(ret, 1);
ck_assert_int_eq(db_getinterfacecountbyname("ethone"), 1);
ck_assert_int_eq(datacache_count(&s.dcache), 0);
s.running = 1;
- ret = addinterfaces(&s);
+ ret = (int)addinterfaces(&s);
ck_assert_int_eq(ret, 2);
ck_assert_int_eq(datacache_count(&s.dcache), 2);
fake_proc_net_dev("a", "eththree", 9, 10, 11, 12);
- ret = addinterfaces(&s);
+ ret = (int)addinterfaces(&s);
ck_assert_int_eq(ret, 1);
ck_assert_int_eq(datacache_count(&s.dcache), 3);
ck_assert_int_eq(ret, 1);
for (i=1; i<100; i++) {
- ret = db_addtraffic_dated("something", i*1234, i*2345, i*85000);
+ ret = db_addtraffic_dated("something", (uint64_t)i*1234, (uint64_t)i*2345, (uint64_t)i*85000);
ck_assert_int_eq(ret, 1);
}
ck_assert_int_eq(len, 10);
fflush(stdout);
- len = read(pipe, buffer, 512);
+ len = (int)read(pipe, buffer, 512);
ck_assert_str_eq(buffer, " rrrrrrrrrr");
}
END_TEST
ck_assert_int_eq(len, 10);
fflush(stdout);
- len = read(pipe, buffer, 512);
+ len = (int)read(pipe, buffer, 512);
ck_assert_str_eq(buffer, " tttttttttt");
}
END_TEST
ck_assert_int_eq(len, 10);
fflush(stdout);
- len = read(pipe, buffer, 512);
+ len = (int)read(pipe, buffer, 512);
ck_assert_str_eq(buffer, " rrrrrttttt");
}
END_TEST
ck_assert_int_eq(len, 10);
fflush(stdout);
- len = read(pipe, buffer, 512);
+ len = (int)read(pipe, buffer, 512);
ck_assert_str_eq(buffer, " rttttttttt");
}
END_TEST
ck_assert_int_eq(len, 10);
fflush(stdout);
- len = read(pipe, buffer, 512);
+ len = (int)read(pipe, buffer, 512);
ck_assert_str_eq(buffer, " tttttttttt");
}
END_TEST
int writedb(DATA *data, const char *iface, const char *dirname, int newdb)
{
- FILE *db;
+ FILE *testdb;
char file[512], backup[512];
snprintf(file, 512, "%s/%s", dirname, iface);
/* make sure version stays correct */
data->version=LEGACYDBVERSION;
- if ((db=fopen(file,"w"))==NULL) {
+ if ((testdb=fopen(file,"w"))==NULL) {
snprintf(errorstring, 1024, "Unable to open database \"%s\" for writing: %s", file, strerror(errno));
printe(PT_Error);
return 0;
}
/* lock file */
- if (!lockdb(fileno(db), 1)) {
- fclose(db);
+ if (!lockdb(fileno(testdb), 1)) {
+ fclose(testdb);
return 0;
}
data->lastupdated=time(NULL);
}
- if (fwrite(data,sizeof(DATA),1,db)==0) {
+ if (fwrite(data,sizeof(DATA),1,testdb)==0) {
snprintf(errorstring, 1024, "Unable to write database \"%s\": %s", file, strerror(errno));
printe(PT_Error);
- fclose(db);
+ fclose(testdb);
return 0;
} else {
if (debug) {
printf("db: Database \"%s\" saved.\n", file);
}
- fclose(db);
+ fclose(testdb);
if ((newdb) && (noexit==0)) {
snprintf(errorstring, 1024, "-> A new database has been created.");
printe(PT_Info);
/* copy data */
while((bytes = (int)read(c, buffer, sizeof(buffer))) > 0) {
- if (write(b, buffer, bytes) < 0) {
+ if (write(b, buffer, (size_t)bytes) < 0) {
close(c);
fclose(bf);
return 0;
iter = dc;
ret = datacache_seek(&iter, "eth3");
for (i=1; i<=10; i++) {
- ret = xferlog_add(&iter->log, i, i*10, i*20);
+ ret = xferlog_add(&iter->log, (time_t)i, (uint64_t)i*10, (uint64_t)i*20);
ck_assert_int_eq(ret, 1);
}
ck_assert_int_eq(iter->log->timestamp, 10);
START_TEST(db_getinterfacecount_counts_interfaces)
{
- uint64_t ret;
+ int ret;
defaultcfg();
suppress_output();
ret = db_open_rw(1);
ck_assert_int_eq(ret, 1);
- ret = db_getinterfacecount();
+ ret = (int)db_getinterfacecount();
ck_assert_int_eq(ret, 0);
ret = db_addinterface("eth0");
ck_assert_int_eq(ret, 1);
- ret = db_getinterfacecount();
+ ret = (int)db_getinterfacecount();
ck_assert_int_eq(ret, 1);
ret = db_addinterface("eth0");
ck_assert_int_eq(ret, 0);
- ret = db_getinterfacecount();
+ ret = (int)db_getinterfacecount();
ck_assert_int_eq(ret, 1);
ret = db_addinterface("eth1");
ck_assert_int_eq(ret, 1);
- ret = db_getinterfacecount();
+ ret = (int)db_getinterfacecount();
ck_assert_int_eq(ret, 2);
ret = db_close();
START_TEST(db_getinterfacecountbyname_counts_interfaces)
{
- uint64_t ret;
+ int ret;
defaultcfg();
ret = db_addinterface("eth1");
ck_assert_int_eq(ret, 1);
- ret = db_getinterfacecountbyname("foo");
+ ret = (int)db_getinterfacecountbyname("foo");
ck_assert_int_eq(ret, 0);
- ret = db_getinterfacecountbyname("eth0");
+ ret = (int)db_getinterfacecountbyname("eth0");
ck_assert_int_eq(ret, 1);
- ret = db_getinterfacecountbyname("eth1");
+ ret = (int)db_getinterfacecountbyname("eth1");
ck_assert_int_eq(ret, 1);
- ret = db_getinterfacecountbyname("eth2");
+ ret = (int)db_getinterfacecountbyname("eth2");
ck_assert_int_eq(ret, 0);
- ret = db_getinterfacecountbyname("");
+ ret = (int)db_getinterfacecountbyname("");
ck_assert_int_eq(ret, 2);
ret = db_close();
}
END_TEST
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wused-but-marked-unused"
START_TEST(getunitprefix_returns_something_with_all_cfg_combinations)
{
const char *string;
}
}
END_TEST
+#pragma clang diagnostic pop
START_TEST(spacecheck_does_not_check_when_not_configured)
{