summaryrefslogtreecommitdiffstats
path: root/LoadAverageMeter.c
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2011-09-08 02:54:02 +0000
committerHisham Muhammad <hisham@gobolinux.org>2011-09-08 02:54:02 +0000
commit978019d34f71c08393d44f66a1ab71ccc5008ff1 (patch)
treef6f59bdea0aae2243f0a017f4089ab2806a9c23b /LoadAverageMeter.c
parentf7fe4b4722129a8444b2f07d2ef1ce9d2500e613 (diff)
sanity checks
Diffstat (limited to 'LoadAverageMeter.c')
-rw-r--r--LoadAverageMeter.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/LoadAverageMeter.c b/LoadAverageMeter.c
index 6c19e2d2..7646ad65 100644
--- a/LoadAverageMeter.c
+++ b/LoadAverageMeter.c
@@ -20,12 +20,15 @@ int LoadMeter_attributes[] = { LOAD };
static inline void LoadAverageMeter_scan(double* one, double* five, double* fifteen) {
int activeProcs, totalProcs, lastProc;
+ *one = 0; *five = 0; *fifteen = 0;
FILE *fd = fopen(PROCDIR "/loadavg", "r");
- int total = fscanf(fd, "%lf %lf %lf %d/%d %d", one, five, fifteen,
- &activeProcs, &totalProcs, &lastProc);
- (void) total;
- assert(total == 6);
- fclose(fd);
+ if (fd) {
+ int total = fscanf(fd, "%lf %lf %lf %d/%d %d", one, five, fifteen,
+ &activeProcs, &totalProcs, &lastProc);
+ (void) total;
+ assert(total == 6);
+ fclose(fd);
+ }
}
static void LoadAverageMeter_setValues(Meter* this, char* buffer, int size) {

© 2014-2024 Faster IT GmbH | imprint | privacy policy