Thread (76 messages) 76 messages, 12 authors, 2023-10-09

Re: [RFC PATCH v2 06/20] tracing/filters: Optimise scalar vs cpumask filtering when the user mask is a single CPU

From: Valentin Schneider <vschneid@redhat.com>
Date: 2023-07-31 17:22:15
Also in: bpf, kvm, linux-doc, linux-kselftest, linux-mm, lkml, rcu

On 31/07/23 19:03, Dan Carpenter wrote:
On Mon, Jul 31, 2023 at 11:54:53AM -0400, Steven Rostedt wrote:
quoted
On Mon, 31 Jul 2023 15:07:52 +0300
Dan Carpenter [off-list ref] wrote:
quoted
On Sat, Jul 29, 2023 at 03:55:47PM -0400, Steven Rostedt wrote:
quoted
quoted
@@ -1761,6 +1761,11 @@ static int parse_pred(const char *str, void *data,
                               FILTER_PRED_FN_CPUMASK;
               } else if (field->filter_type == FILTER_CPU) {
                       pred->fn_num = FILTER_PRED_FN_CPU_CPUMASK;
+		} else if (single) {
+			pred->op = pred->op == OP_BAND ? OP_EQ : pred->op;
Nit, the above can be written as:

                 pred->op = pret->op != OP_BAND ? : OP_EQ;
Heh.  Those are not equivalent.  The right way to write this is:
You mean because of my typo?
No, I hadn't seen the s/pred/pret/ typo.  Your code does:

      if (pred->op != OP_BAND)
              pred->op = true;
      else
              pred->op OP_EQ;

Realy we should probably trigger a static checker warning any time
someone does a compare operations as part of a "x = comparison ?: bar;
Years ago, someone asked me to do that with regards to error codes like:

      return ret < 0 ?: -EINVAL;

but I don't remember the results.
FWIW this is caught by GCC:

     error: the omitted middle operand in ?: will always be ‘true’, suggest explicit middle operand [-Werror=parentheses]
     pred->op = pred->op != OP_BAND ? : OP_EQ;

regards,
dan carpenter
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help