lkml.org 
[lkml]   [2015]   [Feb]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: 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




\
 
 \ /
  Last update: 2015-02-23 07:21    [W:0.270 / U:0.196 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site