Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve warning messages for defect hwclocks #1136

Merged
merged 1 commit into from
May 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,16 @@ void read_FTLconf(void)
buffer = parse_FTLconf(fp, "MAXLOGAGE");

fvalue = 0;
const char *hint = "";
if(buffer != NULL && sscanf(buffer, "%f", &fvalue))
{
if(fvalue >= 0.0f && fvalue <= 1.0f*MAXLOGAGE)
config.maxlogage = (int)(fvalue * 3600);
logg(" MAXLOGAGE: Importing up to %.1f hours of log data", (float)config.maxlogage/3600.0f);
else if(fvalue > 1.0f*MAXLOGAGE)
hint = " (value has been clipped to " str(MAXLOGAGE) " hours)";
}
logg(" MAXLOGAGE: Importing up to %.1f hours of log data%s",
(float)config.maxlogage/3600.0f, hint);

// PRIVACYLEVEL
// Specify if we want to anonymize the DNS queries somehow, available options are:
Expand Down
11 changes: 9 additions & 2 deletions src/overTime.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ void initOverTime(void)
}
}

bool warned_about_hwclock = false;
unsigned int getOverTimeID(time_t timestamp)
{
// Center timestamp in OVERTIME_INTERVAL
Expand All @@ -93,13 +94,19 @@ unsigned int getOverTimeID(time_t timestamp)
// Check bounds manually
if(id < 0)
{
logg("WARN: getOverTimeID(%llu): %u is negative: %llu", (long long)timestamp, id, (long long)firstTimestamp);
// Return first timestamp in case negative timestamp was determined
return 0;
}
else if(id > OVERTIME_SLOTS-1)
{
logg("WARN: getOverTimeID(%llu): %i is too large: %llu", (long long)timestamp, id, (long long)firstTimestamp);
if(!warned_about_hwclock)
{
const time_t lastTimestamp = overTime[OVERTIME_SLOTS-1].timestamp;
logg("WARN: Found database entries in the future (%llu, last: %llu). "
"Your over-time statistics may be incorrect",
(long long)timestamp, (long long)lastTimestamp);
warned_about_hwclock = true;
}
// Return last timestamp in case a too large timestamp was determined
return OVERTIME_SLOTS-1;
}
Expand Down