Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 199100
b: refs/heads/master
c: b448c4b
h: refs/heads/master
v: v3
  • Loading branch information
Arnaldo Carvalho de Melo committed May 19, 2010
1 parent 03398ec commit 6e98ead
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a41794cdd7ee94a5199e14f642c26d649d383fa5
refs/heads/master: b448c4b613542c16ad66042017946e68da4e422b
29 changes: 19 additions & 10 deletions trunk/tools/perf/util/probe-finder.c
Original file line number Diff line number Diff line change
Expand Up @@ -743,32 +743,36 @@ static int find_lazy_match_lines(struct list_head *head,
const char *fname, const char *pat)
{
char *fbuf, *p1, *p2;
int fd, ret, line, nlines = 0;
int fd, line, nlines = -1;
struct stat st;

fd = open(fname, O_RDONLY);
if (fd < 0) {
pr_warning("Failed to open %s: %s\n", fname, strerror(-fd));
return fd;
return -errno;
}

ret = fstat(fd, &st);
if (ret < 0) {
if (fstat(fd, &st) < 0) {
pr_warning("Failed to get the size of %s: %s\n",
fname, strerror(errno));
return ret;
nlines = -errno;
goto out_close;
}
fbuf = xmalloc(st.st_size + 2);
ret = read(fd, fbuf, st.st_size);
if (ret < 0) {

nlines = -ENOMEM;
fbuf = malloc(st.st_size + 2);
if (fbuf == NULL)
goto out_close;
if (read(fd, fbuf, st.st_size) < 0) {
pr_warning("Failed to read %s: %s\n", fname, strerror(errno));
return ret;
nlines = -errno;
goto out_free_fbuf;
}
close(fd);
fbuf[st.st_size] = '\n'; /* Dummy line */
fbuf[st.st_size + 1] = '\0';
p1 = fbuf;
line = 1;
nlines = 0;
while ((p2 = strchr(p1, '\n')) != NULL) {
*p2 = '\0';
if (strlazymatch(p1, pat)) {
Expand All @@ -778,7 +782,10 @@ static int find_lazy_match_lines(struct list_head *head,
line++;
p1 = p2 + 1;
}
out_free_fbuf:
free(fbuf);
out_close:
close(fd);
return nlines;
}

Expand Down Expand Up @@ -955,6 +962,8 @@ int find_kprobe_trace_events(int fd, struct perf_probe_event *pev,
if (!dbg) {
pr_warning("No dwarf info found in the vmlinux - "
"please rebuild with CONFIG_DEBUG_INFO=y.\n");
free(pf.tevs);
*tevs = NULL;
return -EBADF;
}

Expand Down

0 comments on commit 6e98ead

Please sign in to comment.