sanity checks

This commit is contained in:
Hisham Muhammad
2011-09-08 02:54:02 +00:00
parent f7fe4b4722
commit 978019d34f
2 changed files with 12 additions and 7 deletions

View File

@ -21,8 +21,10 @@ int UptimeMeter_attributes[] = {
static void UptimeMeter_setValues(Meter* this, char* buffer, int len) {
double uptime = 0;
FILE* fd = fopen(PROCDIR "/uptime", "r");
fscanf(fd, "%lf", &uptime);
fclose(fd);
if (fd) {
fscanf(fd, "%lf", &uptime);
fclose(fd);
}
int totalseconds = (int) ceil(uptime);
int seconds = totalseconds % 60;
int minutes = (totalseconds/60) % 60;