lkml.org 
[lkml]   [2023]   [Aug]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH v5 1/5] perf metric: Event "Compat" value supports matching multiple identifiers
From
On 02/08/2023 10:38, Jing Zhang wrote:
>>>> n;
>>>> +
>>>> +    str = strdup(compat);
>>> why duplicate this? are you modifying something?
>>>
>> This is really a redundant step, I will remove it.
>>
> Hi John,
>
> I reviewed this code again and found that it still needs to duplicate "compat" because "compat" is a
> const str* type and cannot be used as a parameter for the strtok_r function. If it is cast to char*,
> using "compat" as a parameter for strtok_r is also unsafe and can cause a "Segmentation fault" error.
> Therefore, let's keep the step of duplicating "compat".

ok, so then please add a small comment on why the strdup() call is needed.

Thanks,
John

\
 
 \ /
  Last update: 2023-08-02 11:45    [W:0.111 / U:0.056 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site