linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com>
Cc: linux-trace-devel@vger.kernel.org
Subject: Re: [PATCH v2 2/6] libtracefs: Change APIs to work with constant strings
Date: Wed, 11 Nov 2020 17:43:15 -0500	[thread overview]
Message-ID: <20201111174302.2d8d2c84@gandalf.local.home> (raw)
In-Reply-To: <20201110122249.911664-3-tz.stoyanov@gmail.com>

On Tue, 10 Nov 2020 14:22:45 +0200
"Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com> 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



WARNING: multiple messages have this Message-ID (diff)
From: Steven Rostedt <rostedt@goodmis.org>
To: "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com>
Cc: linux-trace-devel@vger.kernel.org
Subject: Re: [PATCH v2 2/6] libtracefs: Change APIs to work with constant strings
Date: Wed, 11 Nov 2020 17:43:02 -0500	[thread overview]
Message-ID: <20201111174302.2d8d2c84@gandalf.local.home> (raw)
Message-ID: <20201111224302.pxS1jA_GiZZoX8KiSnto2a-ozGhyNo8gKTRmeYgSbRA@z> (raw)
In-Reply-To: <20201110122249.911664-3-tz.stoyanov@gmail.com>

On Tue, 10 Nov 2020 14:22:45 +0200
"Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com> 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 *.

  reply	other threads:[~2020-11-12  1:56 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-10 12:22 [PATCH v2 0/6] libtracefs fixes and improvements Tzvetomir Stoyanov (VMware)
2020-11-10 12:22 ` [PATCH v2 1/6] trace-cmd: Change tracefs.h include path Tzvetomir Stoyanov (VMware)
2020-11-10 12:22 ` [PATCH v2 2/6] libtracefs: Change APIs to work with constant strings Tzvetomir Stoyanov (VMware)
2020-11-11 22:43   ` Steven Rostedt [this message]
2020-11-11 22:43     ` Steven Rostedt
2020-11-10 12:22 ` [PATCH v2 3/6] libtracefs: Add new API to check if instance exists Tzvetomir Stoyanov (VMware)
2020-11-10 12:22 ` [PATCH v2 4/6] libtracefs: Combine allocate and create APIs into one Tzvetomir Stoyanov (VMware)
2020-11-12  1:26   ` Steven Rostedt
2020-11-10 12:22 ` [PATCH v2 5/6] libtracefs: Add new tracefs API tracefs_instances_walk() Tzvetomir Stoyanov (VMware)
2020-11-12  1:31   ` Steven Rostedt
2020-11-12  5:01     ` Tzvetomir Stoyanov
2020-11-10 12:22 ` [PATCH v2 6/6] trace-cmd: Add new libtrasefs API to get the current trace clock Tzvetomir Stoyanov (VMware)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201111174302.2d8d2c84@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=tz.stoyanov@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).