lkml.org 
[lkml]   [2021]   [Feb]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v3 3/5] perf stat: Helper functions for PCIe root ports list in iostat mode
From
Date

On 1/29/2021 11:26 AM, Namhyung Kim wrote:
> Hello,
>
> On Tue, Jan 26, 2021 at 5:06 PM Alexander Antonov
> <alexander.antonov@linux.intel.com> wrote:
>> Introduce helper functions to control PCIe root ports list.
>> These helpers will be used in the follow-up patch.
>>
>> Signed-off-by: Alexander Antonov <alexander.antonov@linux.intel.com>
>> ---
> [SNIP]
>> +static int iio_root_ports_list_insert(struct iio_root_ports_list *list,
>> + struct iio_root_port * const rp)
>> +{
>> + struct iio_root_port **tmp_buf;
>> +
>> + if (list && rp) {
>> + rp->idx = list->nr_entries++;
>> + /* One more for NULL.*/
>> + tmp_buf = realloc(list->rps,
>> + (list->nr_entries + 1) * sizeof(*list->rps));
> Why is this +1 needed since you already have the number of
> entries in the list?
>
> Thanks,
> Namhyung

Hello,

My first approach for iteration through root ports list was using
NULL-terminated array.
And seems like I just forgot to remove this code. I will fix it.

Thank you,
Alexander

>
>> + if (!tmp_buf) {
>> + pr_err("Failed to realloc memory\n");
>> + return -ENOMEM;
>> + }
>> + tmp_buf[rp->idx] = rp;
>> + tmp_buf[list->nr_entries] = NULL;
>> + list->rps = tmp_buf;
>> + }
>> + return 0;
>> +}
>> --
>> 2.19.1
>>

\
 
 \ /
  Last update: 2021-02-01 19:00    [W:0.168 / U:0.120 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site