Skip to content

Commit

Permalink
Address -Wall -Werror error in dstat/parse_stat.c (gcc 7.5+)
Browse files Browse the repository at this point in the history
  • Loading branch information
nichamon authored and tom95858 committed Nov 20, 2020
1 parent 99835de commit 41fd03e
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions ldms/src/sampler/dstat/parse_stat.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,12 @@ int parse_proc_pid_fd(struct proc_pid_fd *s, const char *pid, bool details)
s->fd_anon_inode = 0;
s->fd_pipe = 0;
s->fd_path = 0;
struct dirent entry;
struct dirent *result;
long n;
char *endptr;
rc = readdir_r(dirp, &entry, &result);
while (!rc && result != NULL) {
n = strtol(entry.d_name, &endptr, 10);
result = readdir(dirp);
while (result != NULL) {
n = strtol(result->d_name, &endptr, 10);
if (endptr && (endptr[0] != '\0')) {
/* This is not a file descriptor, e.g., '.' and '..' */
goto next;
Expand All @@ -230,7 +229,7 @@ int parse_proc_pid_fd(struct proc_pid_fd *s, const char *pid, bool details)
s->fd_max = n;
}
buf[0] = '\0';
snprintf(dname, 2*PIDFMAX, "/proc/%s/fd/%s", pid, entry.d_name);
snprintf(dname, 2*PIDFMAX, "/proc/%s/fd/%ld", pid, n);
blen = readlink(dname, buf, BUFMAX);
switch (buf[0]) {
case '.':
Expand Down Expand Up @@ -261,7 +260,7 @@ int parse_proc_pid_fd(struct proc_pid_fd *s, const char *pid, bool details)
}
}
next:
rc = readdir_r(dirp, &entry, &result);
result = readdir(dirp);
}
closedir(dirp);
return rc;
Expand Down

0 comments on commit 41fd03e

Please sign in to comment.