mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>, Jiri Olsa <jolsa@kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] building libtraceevent with clang
Date: Fri, 10 Feb 2017 14:14:08 -0500	[thread overview]
Message-ID: <20170210141408.5eeb6e91@gandalf.local.home> (raw)
In-Reply-To: <20170210170317.GA14313@kernel.org>

On Fri, 10 Feb 2017 14:03:17 -0300
Arnaldo Carvalho de Melo <acme@kernel.org> wrote:

> Hi Steven,
> 
> 	I tried building perf (and thus libtraceevent) with clang and
> got this one:
> 
> kbuffer-parse.c:312:7: warning: variable 'length' is used uninitialized whenever switch case is taken [-Wsometimes-uninitialized]
>         case OLD_RINGBUF_TYPE_TIME_EXTEND:
>              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
> kbuffer-parse.c:339:29: note: uninitialized use occurs here
>         kbuf->next = kbuf->index + length;
>                                    ^~~~~~
> kbuffer-parse.c:297:21: note: initialize the variable 'length' to silence this warning
>         unsigned int length;
>                            ^
>                             = 0
> 1 warning generated.

Hmm, I'm surprised gcc never complained.

> 
> 
> Please take a look if the following is what should be done:
> 
> diff --git a/tools/lib/traceevent/kbuffer-parse.c b/tools/lib/traceevent/kbuffer-parse.c
> index 65984f1c2974..3f717294cb82 100644
> --- a/tools/lib/traceevent/kbuffer-parse.c
> +++ b/tools/lib/traceevent/kbuffer-parse.c
> @@ -309,20 +309,20 @@ static unsigned int old_update_pointers(struct kbuffer *kbuf)
>  		kbuf->next = kbuf->size;
>  		return 0;
>  
> -	case OLD_RINGBUF_TYPE_TIME_EXTEND:
> -		extend = read_4(kbuf, ptr);
> -		extend <<= TS_SHIFT;
> -		extend += delta;
> -		delta = extend;
> -		ptr += 4;
> -		break;
> -
>  	case OLD_RINGBUF_TYPE_TIME_STAMP:
>  		/* should never happen! */
>  		kbuf->curr = kbuf->size;
>  		kbuf->next = kbuf->size;
>  		kbuf->index = kbuf->size;
>  		return -1;
> +
> +	case OLD_RINGBUF_TYPE_TIME_EXTEND:
> +		extend = read_4(kbuf, ptr);
> +		extend <<= TS_SHIFT;
> +		extend += delta;
> +		delta = extend;
> +		ptr += 4;
> +		/* Fall through */

No, actually, the length should be zeroed here.

	length = 0;

As the ptr is placed passed the metadata. At the end of this case
statement, the ptr will be after the metadata. The length is
to represent the length of the data that is part of the event. The
index is the ptr - start_data + length. As there's no data to this type
of event, it should be zero.

When I add length = 0, I get more events from my old 2.6.30 trace.dat
file :-/  I'll have to update my tests.

Care to send another patch?

-- Steve


>  	default:
>  		if (len)
>  			length = len * 4;

  reply	other threads:[~2017-02-10 19:14 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-10 17:03 Arnaldo Carvalho de Melo
2017-02-10 19:14 ` Steven Rostedt [this message]
2017-02-13 16:24   ` Arnaldo Carvalho de Melo
2017-02-13 16:26     ` Arnaldo Carvalho de Melo
2017-02-13 17:14       ` Steven Rostedt
2017-02-13 17:20         ` Arnaldo Carvalho de Melo
2017-02-13 17:46           ` Steven Rostedt
2017-02-17  2:00           ` Steven Rostedt
2017-02-17 13:44             ` Arnaldo Carvalho de Melo
2017-02-14  6:40         ` [tip:perf/core] tools lib traceevent: Initialize lenght on OLD_RING_BUFFER_TYPE_TIME_STAMP tip-bot for Steven Rostedt (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=20170210141408.5eeb6e91@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=acme@kernel.org \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=namhyung@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

all inboxes | Powered by JetHome®