Re: [PATCH v3] perf sched map: Add command-name, fuzzy-name options to filter the output map

From: Madadi Vineeth Reddy
Date: Tue Jun 18 2024 - 12:31:23 EST


Hi Chen Yu,

On 18/06/24 19:22, Chen Yu wrote:
> On 2024-06-17 at 18:19:30 +0530, Madadi Vineeth Reddy wrote:
>
>> +static struct CommandList *parse_commands(const char *commands)
>> +{
>> + char *commands_copy = strdup(commands);
>
> Should we check if commands_copy is NULL in case of allocation failure?
>

Thank you for the suggestion. I will fix it and send a v4.

Thanks and Regards
Madadi Vineeth Reddy

>> + char *token = strtok(commands_copy, ",");
>> + struct CommandList *cmd_list = malloc(sizeof(struct CommandList));
>> +
>> + if (cmd_list == NULL)
>> + return NULL;
>> +
>> + cmd_list->command_count = 0;
>> + cmd_list->command_list = NULL;
>> +
>> + while (token != NULL) {
>> + cmd_list->command_list = realloc(cmd_list->command_list, sizeof(char *)
>> + *(cmd_list->command_count + 1));
>> + cmd_list->command_list[cmd_list->command_count] = strdup(token);
>
> ditto.
>
> thanks,
> Chenyu