2023-09-28 18:01:09

by Julia Lawall

[permalink] [raw]
Subject: [PATCH] tracing/eprobe: drop unneeded breaks

Drop break after return.

Signed-off-by: Julia Lawall <[email protected]>

---
kernel/trace/trace_eprobe.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/kernel/trace/trace_eprobe.c b/kernel/trace/trace_eprobe.c
index 72714cbf475c..03c851f57969 100644
--- a/kernel/trace/trace_eprobe.c
+++ b/kernel/trace/trace_eprobe.c
@@ -788,12 +788,9 @@ find_and_get_event(const char *system, const char *event_name)
name = trace_event_name(tp_event);
if (!name || strcmp(event_name, name))
continue;
- if (!trace_event_try_get_ref(tp_event)) {
+ if (!trace_event_try_get_ref(tp_event))
return NULL;
- break;
- }
return tp_event;
- break;
}
return NULL;
}


2023-09-29 11:42:52

by Masami Hiramatsu

[permalink] [raw]
Subject: Re: [PATCH] tracing/eprobe: drop unneeded breaks

On Thu, 28 Sep 2023 12:43:34 +0200
Julia Lawall <[email protected]> wrote:

> Drop break after return.
>

Good catch! This looks good to me.

Acked-by: Masami Hiramatsu (Google) <[email protected]>

And

Fixes: 7491e2c44278 ("tracing: Add a probe that attaches to trace events")

> Signed-off-by: Julia Lawall <[email protected]>
>
> ---
> kernel/trace/trace_eprobe.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/kernel/trace/trace_eprobe.c b/kernel/trace/trace_eprobe.c
> index 72714cbf475c..03c851f57969 100644
> --- a/kernel/trace/trace_eprobe.c
> +++ b/kernel/trace/trace_eprobe.c
> @@ -788,12 +788,9 @@ find_and_get_event(const char *system, const char *event_name)
> name = trace_event_name(tp_event);
> if (!name || strcmp(event_name, name))
> continue;
> - if (!trace_event_try_get_ref(tp_event)) {
> + if (!trace_event_try_get_ref(tp_event))
> return NULL;
> - break;
> - }
> return tp_event;
> - break;
> }
> return NULL;
> }
>


--
Masami Hiramatsu (Google) <[email protected]>

2023-09-29 21:47:00

by Julia Lawall

[permalink] [raw]
Subject: Re: [PATCH] tracing/eprobe: drop unneeded breaks



On Fri, 29 Sep 2023, Masami Hiramatsu wrote:

> On Thu, 28 Sep 2023 12:43:34 +0200
> Julia Lawall <[email protected]> wrote:
>
> > Drop break after return.
> >
>
> Good catch! This looks good to me.
>
> Acked-by: Masami Hiramatsu (Google) <[email protected]>
>
> And
>
> Fixes: 7491e2c44278 ("tracing: Add a probe that attaches to trace events")

Thanks. I didn't include that because it's not a bug. But it does break
Coccinelle, which is how I noticed it.

julia

>
> > Signed-off-by: Julia Lawall <[email protected]>
> >
> > ---
> > kernel/trace/trace_eprobe.c | 5 +----
> > 1 file changed, 1 insertion(+), 4 deletions(-)
> >
> > diff --git a/kernel/trace/trace_eprobe.c b/kernel/trace/trace_eprobe.c
> > index 72714cbf475c..03c851f57969 100644
> > --- a/kernel/trace/trace_eprobe.c
> > +++ b/kernel/trace/trace_eprobe.c
> > @@ -788,12 +788,9 @@ find_and_get_event(const char *system, const char *event_name)
> > name = trace_event_name(tp_event);
> > if (!name || strcmp(event_name, name))
> > continue;
> > - if (!trace_event_try_get_ref(tp_event)) {
> > + if (!trace_event_try_get_ref(tp_event))
> > return NULL;
> > - break;
> > - }
> > return tp_event;
> > - break;
> > }
> > return NULL;
> > }
> >
>
>
> --
> Masami Hiramatsu (Google) <[email protected]>
>

2023-09-30 09:19:25

by Masami Hiramatsu

[permalink] [raw]
Subject: Re: [PATCH] tracing/eprobe: drop unneeded breaks

On Fri, 29 Sep 2023 13:37:08 +0200 (CEST)
Julia Lawall <[email protected]> wrote:

>
>
> On Fri, 29 Sep 2023, Masami Hiramatsu wrote:
>
> > On Thu, 28 Sep 2023 12:43:34 +0200
> > Julia Lawall <[email protected]> wrote:
> >
> > > Drop break after return.
> > >
> >
> > Good catch! This looks good to me.
> >
> > Acked-by: Masami Hiramatsu (Google) <[email protected]>
> >
> > And
> >
> > Fixes: 7491e2c44278 ("tracing: Add a probe that attaches to trace events")
>
> Thanks. I didn't include that because it's not a bug. But it does break
> Coccinelle, which is how I noticed it.

OK, I got it. I thought it may cause a compiler warning because the
'break' never be executed. (maybe it is just a flow-control word,
so it may not need to be warned, but a bit storange.)

>
> julia
>
> >
> > > Signed-off-by: Julia Lawall <[email protected]>
> > >
> > > ---
> > > kernel/trace/trace_eprobe.c | 5 +----
> > > 1 file changed, 1 insertion(+), 4 deletions(-)
> > >
> > > diff --git a/kernel/trace/trace_eprobe.c b/kernel/trace/trace_eprobe.c
> > > index 72714cbf475c..03c851f57969 100644
> > > --- a/kernel/trace/trace_eprobe.c
> > > +++ b/kernel/trace/trace_eprobe.c
> > > @@ -788,12 +788,9 @@ find_and_get_event(const char *system, const char *event_name)
> > > name = trace_event_name(tp_event);
> > > if (!name || strcmp(event_name, name))
> > > continue;
> > > - if (!trace_event_try_get_ref(tp_event)) {
> > > + if (!trace_event_try_get_ref(tp_event))
> > > return NULL;
> > > - break;
> > > - }
> > > return tp_event;
> > > - break;
> > > }
> > > return NULL;
> > > }
> > >
> >
> >
> > --
> > Masami Hiramatsu (Google) <[email protected]>
> >


--
Masami Hiramatsu (Google) <[email protected]>

2023-10-12 10:41:17

by Dan Carpenter

[permalink] [raw]
Subject: Re: [PATCH] tracing/eprobe: drop unneeded breaks

On Sat, Sep 30, 2023 at 06:19:02PM +0900, Masami Hiramatsu wrote:
> On Fri, 29 Sep 2023 13:37:08 +0200 (CEST)
> Julia Lawall <[email protected]> wrote:
>
> >
> >
> > On Fri, 29 Sep 2023, Masami Hiramatsu wrote:
> >
> > > On Thu, 28 Sep 2023 12:43:34 +0200
> > > Julia Lawall <[email protected]> wrote:
> > >
> > > > Drop break after return.
> > > >
> > >
> > > Good catch! This looks good to me.
> > >
> > > Acked-by: Masami Hiramatsu (Google) <[email protected]>
> > >
> > > And
> > >
> > > Fixes: 7491e2c44278 ("tracing: Add a probe that attaches to trace events")
> >
> > Thanks. I didn't include that because it's not a bug. But it does break
> > Coccinelle, which is how I noticed it.
>
> OK, I got it. I thought it may cause a compiler warning because the
> 'break' never be executed. (maybe it is just a flow-control word,
> so it may not need to be warned, but a bit storange.)

I don't think GCC warns about unreachable code, but yeah, in Smatch
unreachable break statements do not trigger a warning. People like
to add extra break statements to switch statements.

regards,
dan carpenter