Skip to content

Commit

Permalink
Fix nits for /tmp/perf-pid.map support
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Drayton committed Jun 21, 2016
1 parent 6862875 commit db724e2
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/cc/bcc_perf_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@ int bcc_perf_map_nspid(int pid) {
// return the original PID if the NSpid line is missing
int nspid = pid;

size_t size;
size_t size = 0;
char *line = NULL;
while (getline(&line, &size, status) != -1)
while (getline(&line, &size, status) != -1) {
if (strstr(line, "NSpid:") != NULL)
// PID namespaces can be nested -- last number is innermost PID
nspid = (int)strtol(strrchr(line, '\t'), NULL, 10);
}
free(line);

return nspid;
Expand Down Expand Up @@ -70,7 +71,7 @@ int bcc_perf_map_foreach_sym(const char *path, bcc_perf_map_symcb callback,
return -1;

char *line = NULL;
size_t size;
size_t size = 0;
long long begin, len;
while (getline(&line, &size, file) != -1) {
char *cursor = line;
Expand Down

0 comments on commit db724e2

Please sign in to comment.