Messages in this thread | | | Date | Mon, 23 Feb 2015 15:07:15 +0900 | From | Masami Hiramatsu <> | Subject | Re: Re: [perf/core PATCH v4 2/2] perf buildid-cache: Add --purge FILE to remove all caches of FILE |
| |
(2015/02/21 4:07), Hemant Kumar wrote: > Hi Masami, > > Just a small suggestion below. > > On 02/20/2015 03:11 PM, Masami Hiramatsu wrote: >> [SNIP] >> + >> +struct strlist *build_id_cache__list_build_ids(const char *pathname) >> +{ >> + struct strlist *list; >> + char *dirname; >> + DIR *dir; >> + struct dirent *d; >> + >> + list = strlist__new(true, NULL); >> + dirname = build_id_cache__dirname_from_path(pathname, false, false); >> + if (!list || !dirname) >> + goto error_free; >> + >> + /* List up all dirents */ >> + dir = opendir(dirname); >> + if (!dir) >> + goto error_free; >> + while ((d = readdir(dir)) != NULL) { >> + if (!strcmp(d->d_name, ".") || !strcmp(d->d_name, "..")) >> + continue; >> + strlist__add(list, d->d_name); >> + } >> + closedir(dir); >> + >> + free(dirname); >> + return list; >> + >> +error_free: >> + free(dirname); >> + if (list) >> + strlist__delete(list); > > Maybe we don't need the "if (list)" check here as strlist__delete > already checks for this.
Ah, right!
Thanks!
-- Masami HIRAMATSU Software Platform Research Dept. Linux Technology Research Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: masami.hiramatsu.pt@hitachi.com
| |