linux-trace-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Gabriele Paoloni <gpaoloni@redhat.com>
Cc: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>,
	mathieu.desnoyers@efficios.com, linux-kernel@vger.kernel.org,
	linux-trace-kernel@vger.kernel.org
Subject: Re: [RFC PATCH RESEND] tracing: add kernel documentation for trace_array_set_clr_event, trace_set_clr_event and supporting functions
Date: Wed, 9 Jul 2025 10:12:16 -0400	[thread overview]
Message-ID: <20250709101216.5949e86f@batman.local.home> (raw)
In-Reply-To: <CA+wEVJab6Gwkd7q58=v8uVhfmKpwNRAqtK67f15JtZcKSB_ziA@mail.gmail.com>

On Wed, 9 Jul 2025 15:35:50 +0200
Gabriele Paoloni <gpaoloni@redhat.com> wrote:

> > Hmm, now here's an interesting point. So this is to define requirements
> > of a function based on what the function is doing. But does the
> > function have to have strict requirements?  
> 
> IMO one of the main goals for these requirements is testability.
> In order to have testable requirements we should state what the
> valid input values are. In this case:
> 0 -> disable, 1 -> enable, everything else -> Error.
> 
> Now checking the code again it seems that the switch statement
> is missing a default "ret = -EINVAL" (or else it should be changed
> to boolean, but I guess it would have a wider impact on the rest
> of the code...).

Well, it's mostly used internally and the only places that call it uses
0 or 1, so there's never been any issue.

> 
> >
> > If it can handle "0" or "!0" does that mean that's how it will be
> > defined? Or can it just state "0" or "1" and yes "2" is UB. That is,
> > it's not part of the requirements but if someone passes in 2, it could
> > act as a 1 as it's UB and implementation defined. Not a requirement.  
> 
> Right now if 2 is passed the function would silently return success,
> but do we have a use case for this? I am trying to understand
> where the implementation defined behavior would be....

The issue is that all the callers pass in the proper value, and that
can be easily verified, but by adding the "anything else ERROR", it
would require adding more code that is not needed.

I rather just switch that and soft_disable into a boolean than to add
superficial error checks.

-- Steve

  reply	other threads:[~2025-07-09 14:12 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-20  8:56 [RFC PATCH RESEND] tracing: add kernel documentation for trace_array_set_clr_event, trace_set_clr_event and supporting functions Gabriele Paoloni
2025-07-01 23:59 ` Steven Rostedt
2025-07-02 13:45   ` Gabriele Paoloni
2025-07-02 14:40     ` Steven Rostedt
2025-07-02 15:19       ` Steven Rostedt
2025-07-02 17:16         ` Gabriele Paoloni
2025-07-08 22:12           ` Steven Rostedt
2025-07-02 16:38       ` Gabriele Paoloni
2025-07-09  1:06   ` Masami Hiramatsu
2025-07-09  1:25     ` Steven Rostedt
2025-07-09 13:35       ` Gabriele Paoloni
2025-07-09 14:12         ` Steven Rostedt [this message]
2025-07-09 14:49           ` Gabriele Paoloni

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=20250709101216.5949e86f@batman.local.home \
    --to=rostedt@goodmis.org \
    --cc=gpaoloni@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    /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).