Commit 9a230771 authored by Dan McGee's avatar Dan McGee Committed by Stephen Hemminger

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

parent 1b129bf2
...@@ -708,7 +708,7 @@ int main(int argc, char *argv[]) ...@@ -708,7 +708,7 @@ int main(int argc, char *argv[])
} }
if (!ignore_history) { if (!ignore_history) {
FILE *tfp; FILE *tfp;
long uptime; long uptime = -1;
if ((tfp = fopen("/proc/uptime", "r")) != NULL) { if ((tfp = fopen("/proc/uptime", "r")) != NULL) {
if (fscanf(tfp, "%ld", &uptime) != 1) if (fscanf(tfp, "%ld", &uptime) != 1)
uptime = -1; uptime = -1;
......
...@@ -560,7 +560,7 @@ int main(int argc, char *argv[]) ...@@ -560,7 +560,7 @@ int main(int argc, char *argv[])
} }
if (!ignore_history) { if (!ignore_history) {
FILE *tfp; FILE *tfp;
long uptime; long uptime = -1;
if ((tfp = fopen("/proc/uptime", "r")) != NULL) { if ((tfp = fopen("/proc/uptime", "r")) != NULL) {
if (fscanf(tfp, "%ld", &uptime) != 1) if (fscanf(tfp, "%ld", &uptime) != 1)
uptime = -1; uptime = -1;
......
...@@ -580,7 +580,7 @@ int main(int argc, char *argv[]) ...@@ -580,7 +580,7 @@ int main(int argc, char *argv[])
if (!ignore_history) { if (!ignore_history) {
FILE *tfp; FILE *tfp;
long uptime; long uptime = -1;
if ((tfp = fopen("/proc/uptime", "r")) != NULL) { if ((tfp = fopen("/proc/uptime", "r")) != NULL) {
if (fscanf(tfp, "%ld", &uptime) != 1) if (fscanf(tfp, "%ld", &uptime) != 1)
uptime = -1; uptime = -1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment