Re: [PATCH v5] trace-cmd split: Enable support for buffer selection

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 19 Feb 2024 17:43:20 +0100
Pierre Gondois <pierre.gondois@xxxxxxx> wrote:

Hi Pierre,

This looks good, except I have on small nit ;-)

> @@ -120,6 +116,50 @@ static void free_handles(struct list_head *list)
>  	}
>  }
>  
> +static struct list_head inst_list;
> +
> +struct inst_list {
> +	struct list_head		list;
> +	const char			*name;

Why "const char *name" and not just "char *name"?

> +	struct handle_list		*handle;
> +
> +	/* Identify the top instance in the input trace. */
> +	bool				was_top_instance;
> +
> +	/* Identify the top instance in the output trace. */
> +	bool				is_top_instance;
> +};
> +
> +static void free_inst(struct list_head *list)
> +{
> +	struct inst_list *item, *n;
> +
> +	list_for_each_entry_safe(item, n, list, list) {
> +		list_del(&item->list);
> +		free((char *)item->name);

Then you don't need to do the typecast to free.

> +		free(item);
> +	}
> +}
> +
> +static struct inst_list *add_inst(const char *name, bool was_top_instance,
> +				  bool is_top_instance)
> +{
> +	struct inst_list *item;
> +
> +	item = calloc(1, sizeof(*item));
> +	if (!item)
> +		die("Failed to allocate output_file item");
> +
> +	item->name = strdup(name);

You are using strdup(), which means "name" isn't pointing to a const.

-- Steve

> +	if (!item->name)
> +		die("Failed to duplicate %s", name);
> +
> +	item->was_top_instance = was_top_instance;
> +	item->is_top_instance = is_top_instance;
> +	list_add_tail(&item->list, &inst_list);
> +	return item;
> +}
> +




[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux