All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Tanish Desai <tanishdesai37@gmail.com>
Cc: qemu-devel@nongnu.org, pbonzini@redhat.com,
	Mads Ynddal <mads@ynddal.dk>,
	Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [PATCH v2 2/2] tracetool/format: remove redundent trace-event checks
Date: Wed, 6 Aug 2025 17:53:27 +0100	[thread overview]
Message-ID: <aJOIhxTD9pxnOBPj@redhat.com> (raw)
In-Reply-To: <20250806150539.2871-3-tanishdesai37@gmail.com>

On Wed, Aug 06, 2025 at 03:05:39PM +0000, Tanish Desai wrote:
> Remove redundent if(check_trace_event) check
> from individual backends.
> Adding CHECK_TRACE_EVENT_GET_STATE in log,syslog,
> dtrace and simple backend.
> 
> Signed-off-by: Tanish Desai <tanishdesai37@gmail.com>
> ---
>  scripts/tracetool/backend/ftrace.py | 12 +++++-------
>  scripts/tracetool/backend/log.py    | 10 ++++------
>  scripts/tracetool/backend/simple.py |  9 ++-------
>  scripts/tracetool/backend/syslog.py |  8 ++------
>  4 files changed, 13 insertions(+), 26 deletions(-)
> 
> diff --git a/scripts/tracetool/backend/ftrace.py b/scripts/tracetool/backend/ftrace.py
> index 5fa30ccc08..c65d3b89b3 100644
> --- a/scripts/tracetool/backend/ftrace.py
> +++ b/scripts/tracetool/backend/ftrace.py
> @@ -16,6 +16,7 @@
>  
>  
>  PUBLIC = True
> +CHECK_TRACE_EVENT_GET_STATE = True
>  
>  
>  def generate_h_begin(events, group):
> @@ -28,11 +29,10 @@ def generate_h(event, group):
>      if len(event.args) > 0:
>          argnames = ", " + argnames
>  
> -    out('    {',
> -        '        char ftrace_buf[MAX_TRACE_STRLEN];',
> -        '        int unused __attribute__ ((unused));',
> -        '        int trlen;',
> -        '        if (trace_event_get_state(%(event_id)s)) {',
> +    out('        {',
> +        '            char ftrace_buf[MAX_TRACE_STRLEN];',
> +        '            int unused __attribute__ ((unused));',
> +        '            int trlen;',

This results in unecessary nested code blocks & indent.
For example:

static inline void trace_test_blah(void *context, const char *filename)
{
    if (trace_event_get_state(TRACE_TEST_BLAH)) {
        {
            char ftrace_buf[MAX_TRACE_STRLEN];
            int unused __attribute__ ((unused));
            int trlen;
#line 4 "trace-events"
            trlen = snprintf(ftrace_buf, MAX_TRACE_STRLEN,
                             "test_blah " "Blah context=%p filename=%s" "\n" , context, filename);
#line 33 "[stdout]"
            trlen = MIN(trlen, MAX_TRACE_STRLEN - 1);
            unused = write(trace_marker_fd, ftrace_buf, trlen);
        }
    }
}

Instead of


static inline void trace_test_blah(void *context, const char *filename)
{
    if (trace_event_get_state(TRACE_TEST_BLAH)) {
        char ftrace_buf[MAX_TRACE_STRLEN];
        int unused __attribute__ ((unused));
        int trlen;
#line 4 "trace-events"
        trlen = snprintf(ftrace_buf, MAX_TRACE_STRLEN,
                         "test_blah " "Blah context=%p filename=%s" "\n" , context, filename);
#line 33 "[stdout]"
        trlen = MIN(trlen, MAX_TRACE_STRLEN - 1);
        unused = write(trace_marker_fd, ftrace_buf, trlen);
    }
}



With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



  reply	other threads:[~2025-08-06 17:15 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-06 15:05 [PATCH v2 0/2] tracetool: remove no_check_foo() and if(true){..} blocks Tanish Desai
2025-08-06 15:05 ` [PATCH v2 1/2] tracetool: add CHECK_TRACE_EVENT_GET_STATE Tanish Desai
2025-08-06 19:13   ` Daniel P. Berrangé
2025-08-07 10:35     ` Paolo Bonzini
2025-08-20 12:14       ` Daniel P. Berrangé
2025-08-07 19:23   ` Stefan Hajnoczi
2025-08-06 15:05 ` [PATCH v2 2/2] tracetool/format: remove redundent trace-event checks Tanish Desai
2025-08-06 16:53   ` Daniel P. Berrangé [this message]
2025-08-07 19:25   ` Stefan Hajnoczi

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=aJOIhxTD9pxnOBPj@redhat.com \
    --to=berrange@redhat.com \
    --cc=mads@ynddal.dk \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=tanishdesai37@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.