Fossil SCM

If getloadavg() fails, return 0.0 as function result in stead of a random number

jan.nijtmans 2014-03-09 22:33 trunk
Commit 1707129a8744a7d719ef69bcd6e08d1c98eb3c16
1 file changed +5 -7
+5 -7
--- src/loadctrl.c
+++ src/loadctrl.c
@@ -24,19 +24,17 @@
2424
2525
/*
2626
** Return the load average for the host processor
2727
*/
2828
double load_average(void){
29
-#ifdef _WIN32
30
- return 0.0;
31
-#elif defined(FOSSIL_OMIT_LOAD_AVERAGE)
32
- return 0.0;
33
-#else
29
+#if !defined(_WIN32) && !defined(FOSSIL_OMIT_LOAD_AVERAGE)
3430
double a[3];
35
- getloadavg(a, 3);
36
- return a[0];
31
+ if( getloadavg(a, 3)>0 ){
32
+ return a[0];
33
+ }
3734
#endif
35
+ return 0.0;
3836
}
3937
4038
/*
4139
** COMMAND: test-loadavg
4240
** %fossil test-loadavg
4341
--- src/loadctrl.c
+++ src/loadctrl.c
@@ -24,19 +24,17 @@
24
25 /*
26 ** Return the load average for the host processor
27 */
28 double load_average(void){
29 #ifdef _WIN32
30 return 0.0;
31 #elif defined(FOSSIL_OMIT_LOAD_AVERAGE)
32 return 0.0;
33 #else
34 double a[3];
35 getloadavg(a, 3);
36 return a[0];
 
37 #endif
 
38 }
39
40 /*
41 ** COMMAND: test-loadavg
42 ** %fossil test-loadavg
43
--- src/loadctrl.c
+++ src/loadctrl.c
@@ -24,19 +24,17 @@
24
25 /*
26 ** Return the load average for the host processor
27 */
28 double load_average(void){
29 #if !defined(_WIN32) && !defined(FOSSIL_OMIT_LOAD_AVERAGE)
 
 
 
 
30 double a[3];
31 if( getloadavg(a, 3)>0 ){
32 return a[0];
33 }
34 #endif
35 return 0.0;
36 }
37
38 /*
39 ** COMMAND: test-loadavg
40 ** %fossil test-loadavg
41

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button