From: <Viktor.Rosendahl@bmw.de>
To: <rostedt@goodmis.org>, <davidcomponentone@gmail.com>
Cc: <vulab@iscas.ac.cn>, <colin.king@canonical.com>,
<linux-kernel@vger.kernel.org>, <zealci@zte.com.cn>
Subject: Re: [PATCH] Fix application of sizeof to pointer
Date: Tue, 12 Oct 2021 11:05:57 +0000 [thread overview]
Message-ID: <5941214abba2a844472a257d9bf068c2efb1f879.camel@bmw.de> (raw)
In-Reply-To: <20211011230633.262b54a5@oasis.local.home>
On Mon, 2021-10-11 at 23:06 -0400, Steven Rostedt wrote:
> On Tue, 12 Oct 2021 10:54:24 +0800
> davidcomponentone@gmail.com wrote:
>
> > From: David Yang <davidcomponentone@gmail.com>
> >
> > The coccinelle check report:
> > "./tools/tracing/latency/latency-collector.c:1541:10-16:
> > ERROR: application of sizeof to pointer"
> > Using the "strlen" to fix it.
> >
> > Reported-by: Zeal Robot <zealci@zte.com.cn>
> > Signed-off-by: David Yang <davidcomponentone@gmail.com>
> > ---
> > tools/tracing/latency/latency-collector.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/tools/tracing/latency/latency-collector.c
> > b/tools/tracing/latency/latency-collector.c
> > index 3a2e6bb781a8..b131007e6c70 100644
> > --- a/tools/tracing/latency/latency-collector.c
> > +++ b/tools/tracing/latency/latency-collector.c
> > @@ -1538,7 +1538,7 @@ static void tracing_loop(void)
> > mutex_lock(&print_mtx);
> > check_signals();
> > write_or_die(fd_stdout, queue_full_warning,
> > - sizeof(queue_full_warning));
> > + strlen(queue_full_warning) + 1);
>
> Really, the +1, although would match if queue_full_warning was an
> array, but in this use case, there's no reason to pass the nul
> character to the write.
I agree that the +1 should not be there because the null character would end up
in the output; write will not ignore it. It could be confusing if the output
would be be processed by another program.
best regards,
Viktor
>
> -- Steve
>
>
> > mutex_unlock(&print_mtx);
> > }
> > modified--;
next prev parent reply other threads:[~2021-10-12 11:13 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-12 2:54 davidcomponentone
2021-10-12 3:06 ` Steven Rostedt
2021-10-12 11:05 ` Viktor.Rosendahl [this message]
2021-10-12 3:01 davidcomponentone
2021-10-12 7:01 ` David Hildenbrand
2021-10-12 11:16 davidcomponentone
2021-10-20 17:55 ` Andrii Nakryiko
2021-10-21 0:50 ` David Yang
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=5941214abba2a844472a257d9bf068c2efb1f879.camel@bmw.de \
--to=viktor.rosendahl@bmw.de \
--cc=colin.king@canonical.com \
--cc=davidcomponentone@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=vulab@iscas.ac.cn \
--cc=zealci@zte.com.cn \
/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®