ensure uptime is initialized if /proc/uptime cannot be opened

This commit is contained in:
Dan McGee 2011-08-31 12:16:36 -07:00 committed by Stephen Hemminger
parent 1b129bf2fe
commit 9a230771c0
3 changed files with 3 additions and 3 deletions

View File

@ -708,7 +708,7 @@ int main(int argc, char *argv[])
}
if (!ignore_history) {
FILE *tfp;
long uptime;
long uptime = -1;
if ((tfp = fopen("/proc/uptime", "r")) != NULL) {
if (fscanf(tfp, "%ld", &uptime) != 1)
uptime = -1;

View File

@ -560,7 +560,7 @@ int main(int argc, char *argv[])
}
if (!ignore_history) {
FILE *tfp;
long uptime;
long uptime = -1;
if ((tfp = fopen("/proc/uptime", "r")) != NULL) {
if (fscanf(tfp, "%ld", &uptime) != 1)
uptime = -1;

View File

@ -580,7 +580,7 @@ int main(int argc, char *argv[])
if (!ignore_history) {
FILE *tfp;
long uptime;
long uptime = -1;
if ((tfp = fopen("/proc/uptime", "r")) != NULL) {
if (fscanf(tfp, "%ld", &uptime) != 1)
uptime = -1;