diff options
author | markj <markj@FreeBSD.org> | 2015-01-31 03:22:00 +0000 |
---|---|---|
committer | markj <markj@FreeBSD.org> | 2015-01-31 03:22:00 +0000 |
commit | aa993eaf7222e8015ec03249aa68da689c92132a (patch) | |
tree | 701e2b8f108a86b85cb5a8a291e28283e8390567 /lib | |
parent | 49907be68d661e3eb585890d39d4aef15bc20d24 (diff) | |
download | FreeBSD-src-aa993eaf7222e8015ec03249aa68da689c92132a.zip FreeBSD-src-aa993eaf7222e8015ec03249aa68da689c92132a.tar.gz |
Stop iterating and return if the caller-supplied callback function returns
a non-zero value.
MFC after: 1 week
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libproc/proc_sym.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/libproc/proc_sym.c b/lib/libproc/proc_sym.c index 90d40a8..d4f8262 100644 --- a/lib/libproc/proc_sym.c +++ b/lib/libproc/proc_sym.c @@ -153,9 +153,12 @@ proc_iter_objs(struct proc_handle *p, proc_map_f *func, void *cd) prmap_t map; char path[MAXPATHLEN]; char last[MAXPATHLEN]; + int error; if (p->nobjs == 0) return (-1); + + error = 0; memset(last, 0, sizeof(last)); for (i = 0; i < p->nobjs; i++) { rdl = &p->rdobjs[i]; @@ -169,11 +172,11 @@ proc_iter_objs(struct proc_handle *p, proc_map_f *func, void *cd) */ if (strcmp(path, last) == 0) continue; - (*func)(cd, &map, path); + if ((error = (*func)(cd, &map, path)) != 0) + break; strlcpy(last, path, sizeof(last)); } - - return (0); + return (error); } prmap_t * @@ -599,7 +602,8 @@ proc_iter_symbyaddr(struct proc_handle *p, const char *object, int which, s = elf_strptr(e, stridx, sym.st_name); if (ehdr.e_type != ET_EXEC) sym.st_value += map->pr_vaddr; - (*func)(cd, &sym, s); + if ((error = (*func)(cd, &sym, s)) != 0) + goto err2; } error = 0; err2: |