Re: [PATCH v2 2/6] libtracefs: Change APIs to work with constant strings

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

 



On Tue, 10 Nov 2020 14:22:45 +0200
"Tzvetomir Stoyanov (VMware)" <tz.stoyanov@xxxxxxxxx> wrote:

> Some tracefs library APIs retrieve trace instance parameters as srings.
> As these strings are not meant to be changed by the API callers, set
> them to be constant. These APIs are affected:

>  tracefs_instance_get_name()

Correct, because we pass back a pointer to a stored internal name.


>  tracefs_event_systems()
>  tracefs_system_events()
>  tracefs_tracers()
>  tracefs_list_free()

I don't think we need to make the above const char*. We are allocating them
and these strings don't point to anything internal. In other words, they
are OK to modify without causing issues.

I think we only need the tracefs_instance_get_name() to be const.

Previously, I thought we were passing back internal pointers, but if we are
making strings with strdup, then we don't need to use const char *.

-- Steve





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

  Powered by Linux