struct dirent *e;
struct stat s;
- char *ipc;
- char *ipc_command;
+ char *ipc = NULL;
+ char *ipc_command = NULL;
if(! stat("/proc/net/nf_conntrack", &s))
ipc = "/proc/net/nf_conntrack";
else if(! stat("/proc/net/ip_conntrack", &s))
closedir(dir);
}
- if (((ipc != '\0') && ((info = fopen(ipc, "r")) != NULL)) ||
- ((ipc_command != '\0') && ((info=popen(ipc_command, "r")) != NULL)))
+ if ((ipc && ((info = fopen(ipc, "r")) != NULL)) ||
+ (ipc_command && ((info = popen(ipc_command, "r")) != NULL)))
{
udp = 0;
tcp = 0;
update_cnstat(udp, tcp, other);
- fclose(info);
+ if (ipc)
+ fclose(info);
+ else
+ pclose(info);
}
if ((info = fopen("/proc/loadavg", "r")) != NULL)
(uint16_t)(lf15 * 100));
}
- if (ipc != '\0')
- fclose(info);
- if (ipc_command != '\0')
- pclose(info);
+ fclose(info);
}
sleep(STEP_TIME);