Stop iterating and return if the caller-supplied callback function returns

a non-zero value.

MFC after:	1 week
This commit is contained in:
Mark Johnston 2015-01-31 03:22:00 +00:00
parent 4c99145742
commit c7fa6f0bb0
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=277961

View File

@ -153,9 +153,12 @@ proc_iter_objs(struct proc_handle *p, proc_map_f *func, void *cd)
prmap_t map; prmap_t map;
char path[MAXPATHLEN]; char path[MAXPATHLEN];
char last[MAXPATHLEN]; char last[MAXPATHLEN];
int error;
if (p->nobjs == 0) if (p->nobjs == 0)
return (-1); return (-1);
error = 0;
memset(last, 0, sizeof(last)); memset(last, 0, sizeof(last));
for (i = 0; i < p->nobjs; i++) { for (i = 0; i < p->nobjs; i++) {
rdl = &p->rdobjs[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) if (strcmp(path, last) == 0)
continue; continue;
(*func)(cd, &map, path); if ((error = (*func)(cd, &map, path)) != 0)
break;
strlcpy(last, path, sizeof(last)); strlcpy(last, path, sizeof(last));
} }
return (error);
return (0);
} }
prmap_t * 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); s = elf_strptr(e, stridx, sym.st_name);
if (ehdr.e_type != ET_EXEC) if (ehdr.e_type != ET_EXEC)
sym.st_value += map->pr_vaddr; sym.st_value += map->pr_vaddr;
(*func)(cd, &sym, s); if ((error = (*func)(cd, &sym, s)) != 0)
goto err2;
} }
error = 0; error = 0;
err2: err2: