num_lines++;
- fgets(buf, sizeof(buf)-1, lf->fp);
+ if (fgets(buf, sizeof(buf)-1, lf->fp) == NULL)
+ fprintf(stderr, "Error: failed to read from input file stream.\n");
gettimeofday(&lf->last_read, NULL);
for (j = 0; j < lf->num_fields; j++) {
rewind(lf->fp);
if (!lf->compat) {
/* skip first line */
- fgets(buf, sizeof(buf)-1, lf->fp);
+ if (fgets(buf, sizeof(buf)-1, lf->fp) == NULL)
+ fprintf(stderr, "Error: failed to read from input file stream.\n");
}
scan_lines(lf, 1);
for (i = 0, lfi = &lf->fields[i];
- i < lf->num_fields; i++, lfi = &lf->fields[i]) {
+ i < lf->num_fields; i++, lfi = &lf->fields[i]) {
if (i == 0)
lfi->result = lfi->values[1];
else
lfi->result = (lfi->values[1]-lfi->values[0])
- / lf->interval.tv_sec;
+ / lf->interval.tv_sec;
}
rewind(lf->fp);
- fgets(buf, sizeof(buf)-1, lf->fp);
+ if (fgets(buf, sizeof(buf)-1, lf->fp) == NULL)
+ fprintf(stderr, "Error: failed to read from input file stream.\n");
scan_lines(lf, 0);
}
}
char buf[FGETS_BUF_SIZE];
rewind(lf->fp);
- fgets(buf, sizeof(buf)-1, lf->fp);
+ if (fgets(buf, sizeof(buf)-1, lf->fp) == NULL)
+ fprintf(stderr, "Error: failed to read from input file stream.\n");
return __lnstat_scan_fields(lf, buf);
}
snprintf(tmp, sizeof(tmp), "%s/%d/stat", root, pid);
if ((fp = fopen(tmp, "r")) != NULL) {
- fscanf(fp, "%*d (%[^)])", process);
+ int ret = fscanf(fp, "%*d (%[^)])", process);
+ if (ret < 0)
+ fprintf(stderr, "Error: failed to read from input file stream.\n");
fclose(fp);
}
}
cnt = sizeof(*s)/sizeof(int);
- fgets(buf, sizeof(buf), fp);
+ if (fgets(buf, sizeof(buf), fp) == NULL)
+ goto out;
while(fgets(buf, sizeof(buf), fp) != NULL) {
int i;
for (i=0; i<sizeof(slabstat_ids)/sizeof(slabstat_ids[0]); i++) {
break;
}
+out:
fclose(fp);
return 0;
}
char buf[128];
FILE *fp = popen("/usr/sbin/rpcinfo -p 2>/dev/null", "r");
if (fp) {
- fgets(buf, sizeof(buf), fp);
+ if (fgets(buf, sizeof(buf), fp) == NULL)
+ fprintf(stderr, "Error: failed to read from input file stream.\n");
while (fgets(buf, sizeof(buf), fp) != NULL) {
unsigned int progn, port;
char proto[128], prog[128];
if (!ip_local_port_min) {
FILE *f = ephemeral_ports_open();
if (f) {
- fscanf(f, "%d %d",
- &ip_local_port_min, &ip_local_port_max);
+ int ret = fscanf(f, "%d %d",
+ &ip_local_port_min, &ip_local_port_max);
+ if (ret < 0)
+ fprintf(stderr, "Error: failed to read from input file stream.\n");
fclose(f);
} else {
ip_local_port_min = 1024;
if (!low) {
FILE *fp = ephemeral_ports_open();
if (fp) {
- fscanf(fp, "%d%d", &low, &high);
+ int ret = fscanf(fp, "%d%d", &low, &high);
+ if (ret < 0)
+ fprintf(stderr, "Error: failed to read from input file stream.\n");
fclose(fp);
}
}
if ((fp = net_unix_open()) == NULL)
return -1;
- fgets(buf, sizeof(buf)-1, fp);
+ if (fgets(buf, sizeof(buf)-1, fp) == NULL)
+ return -1;
if (memcmp(buf, "Peer", 4) == 0)
newformat = 1;
if ((fp = net_packet_open()) == NULL)
return -1;
- fgets(buf, sizeof(buf)-1, fp);
+ if (fgets(buf, sizeof(buf)-1, fp) == NULL)
+ fprintf(stderr, "Error: failed to read from input file stream.\n");
while (fgets(buf, sizeof(buf)-1, fp)) {
sscanf(buf, "%llx %*d %d %x %d %d %u %u %u",
if ((fp = net_netlink_open()) == NULL)
return -1;
- fgets(buf, sizeof(buf)-1, fp);
+ if (fgets(buf, sizeof(buf)-1, fp) == NULL)
+ fprintf(stderr, "Error: failed to read from input file stream.\n");
while (fgets(buf, sizeof(buf)-1, fp)) {
sscanf(buf, "%llx %d %d %x %d %d %llx %d",