All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] coresight: cti: Remove unnecessary NULL check in cti_sig_type_name
@ 2020-03-02 21:34 ` Nathan Chancellor
  0 siblings, 0 replies; 8+ messages in thread
From: Nathan Chancellor @ 2020-03-02 21:34 UTC (permalink / raw)
  To: Mathieu Poirier
  Cc: Suzuki K Poulose, Mike Leach, Alexander Shishkin,
	linux-arm-kernel, linux-kernel, clang-built-linux,
	Nathan Chancellor

Clang warns:

drivers/hwtracing/coresight/coresight-cti-sysfs.c:948:11: warning:
address of array 'grp->sig_types' will always evaluate to 'true'
[-Wpointer-bool-conversion]
        if (grp->sig_types) {
        ~~  ~~~~~^~~~~~~~~
1 warning generated.

sig_types is at the end of a struct so it cannot be NULL.

Fixes: 85b6684eab65 ("coresight: cti: Add connection information to sysfs")
Link: https://github.com/ClangBuiltLinux/linux/issues/914
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
 drivers/hwtracing/coresight/coresight-cti-sysfs.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight-cti-sysfs.c b/drivers/hwtracing/coresight/coresight-cti-sysfs.c
index abb7f492c2cb..214d6552b494 100644
--- a/drivers/hwtracing/coresight/coresight-cti-sysfs.c
+++ b/drivers/hwtracing/coresight/coresight-cti-sysfs.c
@@ -945,10 +945,8 @@ cti_sig_type_name(struct cti_trig_con *con, int used_count, bool in)
 	int idx = 0;
 	struct cti_trig_grp *grp = in ? con->con_in : con->con_out;
 
-	if (grp->sig_types) {
-		if (used_count < grp->nr_sigs)
-			idx = grp->sig_types[used_count];
-	}
+	if (used_count < grp->nr_sigs)
+		idx = grp->sig_types[used_count];
 	return sig_type_names[idx];
 }
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH] coresight: cti: Remove unnecessary NULL check in cti_sig_type_name
@ 2020-03-02 21:34 ` Nathan Chancellor
  0 siblings, 0 replies; 8+ messages in thread
From: Nathan Chancellor @ 2020-03-02 21:34 UTC (permalink / raw)
  To: Mathieu Poirier
  Cc: Suzuki K Poulose, Alexander Shishkin, linux-kernel,
	clang-built-linux, Nathan Chancellor, linux-arm-kernel,
	Mike Leach

Clang warns:

drivers/hwtracing/coresight/coresight-cti-sysfs.c:948:11: warning:
address of array 'grp->sig_types' will always evaluate to 'true'
[-Wpointer-bool-conversion]
        if (grp->sig_types) {
        ~~  ~~~~~^~~~~~~~~
1 warning generated.

sig_types is at the end of a struct so it cannot be NULL.

Fixes: 85b6684eab65 ("coresight: cti: Add connection information to sysfs")
Link: https://github.com/ClangBuiltLinux/linux/issues/914
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
 drivers/hwtracing/coresight/coresight-cti-sysfs.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight-cti-sysfs.c b/drivers/hwtracing/coresight/coresight-cti-sysfs.c
index abb7f492c2cb..214d6552b494 100644
--- a/drivers/hwtracing/coresight/coresight-cti-sysfs.c
+++ b/drivers/hwtracing/coresight/coresight-cti-sysfs.c
@@ -945,10 +945,8 @@ cti_sig_type_name(struct cti_trig_con *con, int used_count, bool in)
 	int idx = 0;
 	struct cti_trig_grp *grp = in ? con->con_in : con->con_out;
 
-	if (grp->sig_types) {
-		if (used_count < grp->nr_sigs)
-			idx = grp->sig_types[used_count];
-	}
+	if (used_count < grp->nr_sigs)
+		idx = grp->sig_types[used_count];
 	return sig_type_names[idx];
 }
 
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] coresight: cti: Remove unnecessary NULL check in cti_sig_type_name
  2020-03-02 21:34 ` Nathan Chancellor
@ 2020-03-02 21:51   ` Nick Desaulniers
  -1 siblings, 0 replies; 8+ messages in thread
From: Nick Desaulniers @ 2020-03-02 21:51 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Mathieu Poirier, Suzuki K Poulose, Mike Leach,
	Alexander Shishkin, Linux ARM, LKML, clang-built-linux

On Mon, Mar 2, 2020 at 1:34 PM Nathan Chancellor
<natechancellor@gmail.com> wrote:
>
> Clang warns:
>
> drivers/hwtracing/coresight/coresight-cti-sysfs.c:948:11: warning:
> address of array 'grp->sig_types' will always evaluate to 'true'
> [-Wpointer-bool-conversion]
>         if (grp->sig_types) {
>         ~~  ~~~~~^~~~~~~~~
> 1 warning generated.
>
> sig_types is at the end of a struct so it cannot be NULL.
>
> Fixes: 85b6684eab65 ("coresight: cti: Add connection information to sysfs")
> Link: https://github.com/ClangBuiltLinux/linux/issues/914
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>

Yep, GCC and Clang both eliminate the false case as impossible:
https://godbolt.org/z/tjbDqR
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

> ---
>  drivers/hwtracing/coresight/coresight-cti-sysfs.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/hwtracing/coresight/coresight-cti-sysfs.c b/drivers/hwtracing/coresight/coresight-cti-sysfs.c
> index abb7f492c2cb..214d6552b494 100644
> --- a/drivers/hwtracing/coresight/coresight-cti-sysfs.c
> +++ b/drivers/hwtracing/coresight/coresight-cti-sysfs.c
> @@ -945,10 +945,8 @@ cti_sig_type_name(struct cti_trig_con *con, int used_count, bool in)
>         int idx = 0;
>         struct cti_trig_grp *grp = in ? con->con_in : con->con_out;
>
> -       if (grp->sig_types) {
> -               if (used_count < grp->nr_sigs)
> -                       idx = grp->sig_types[used_count];
> -       }
> +       if (used_count < grp->nr_sigs)
> +               idx = grp->sig_types[used_count];
>         return sig_type_names[idx];
>  }
>
> --


-- 
Thanks,
~Nick Desaulniers

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] coresight: cti: Remove unnecessary NULL check in cti_sig_type_name
@ 2020-03-02 21:51   ` Nick Desaulniers
  0 siblings, 0 replies; 8+ messages in thread
From: Nick Desaulniers @ 2020-03-02 21:51 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Mathieu Poirier, Suzuki K Poulose, Alexander Shishkin, LKML,
	clang-built-linux, Linux ARM, Mike Leach

On Mon, Mar 2, 2020 at 1:34 PM Nathan Chancellor
<natechancellor@gmail.com> wrote:
>
> Clang warns:
>
> drivers/hwtracing/coresight/coresight-cti-sysfs.c:948:11: warning:
> address of array 'grp->sig_types' will always evaluate to 'true'
> [-Wpointer-bool-conversion]
>         if (grp->sig_types) {
>         ~~  ~~~~~^~~~~~~~~
> 1 warning generated.
>
> sig_types is at the end of a struct so it cannot be NULL.
>
> Fixes: 85b6684eab65 ("coresight: cti: Add connection information to sysfs")
> Link: https://github.com/ClangBuiltLinux/linux/issues/914
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>

Yep, GCC and Clang both eliminate the false case as impossible:
https://godbolt.org/z/tjbDqR
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

> ---
>  drivers/hwtracing/coresight/coresight-cti-sysfs.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/hwtracing/coresight/coresight-cti-sysfs.c b/drivers/hwtracing/coresight/coresight-cti-sysfs.c
> index abb7f492c2cb..214d6552b494 100644
> --- a/drivers/hwtracing/coresight/coresight-cti-sysfs.c
> +++ b/drivers/hwtracing/coresight/coresight-cti-sysfs.c
> @@ -945,10 +945,8 @@ cti_sig_type_name(struct cti_trig_con *con, int used_count, bool in)
>         int idx = 0;
>         struct cti_trig_grp *grp = in ? con->con_in : con->con_out;
>
> -       if (grp->sig_types) {
> -               if (used_count < grp->nr_sigs)
> -                       idx = grp->sig_types[used_count];
> -       }
> +       if (used_count < grp->nr_sigs)
> +               idx = grp->sig_types[used_count];
>         return sig_type_names[idx];
>  }
>
> --


-- 
Thanks,
~Nick Desaulniers

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] coresight: cti: Remove unnecessary NULL check in cti_sig_type_name
  2020-03-02 21:51   ` Nick Desaulniers
@ 2020-03-02 21:57     ` Nick Desaulniers
  -1 siblings, 0 replies; 8+ messages in thread
From: Nick Desaulniers @ 2020-03-02 21:57 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Mathieu Poirier, Suzuki K Poulose, Mike Leach,
	Alexander Shishkin, Linux ARM, LKML, clang-built-linux

On Mon, Mar 2, 2020 at 1:51 PM Nick Desaulniers <ndesaulniers@google.com> wrote:
>
> On Mon, Mar 2, 2020 at 1:34 PM Nathan Chancellor
> <natechancellor@gmail.com> wrote:
> >
> > Clang warns:
> >
> > drivers/hwtracing/coresight/coresight-cti-sysfs.c:948:11: warning:
> > address of array 'grp->sig_types' will always evaluate to 'true'
> > [-Wpointer-bool-conversion]
> >         if (grp->sig_types) {
> >         ~~  ~~~~~^~~~~~~~~
> > 1 warning generated.
> >
> > sig_types is at the end of a struct so it cannot be NULL.
> >
> > Fixes: 85b6684eab65 ("coresight: cti: Add connection information to sysfs")
> > Link: https://github.com/ClangBuiltLinux/linux/issues/914
> > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
>
> Yep, GCC and Clang both eliminate the false case as impossible:
> https://godbolt.org/z/tjbDqR
> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

0day just reported this, too (3 minutes after you sent your patch)
https://groups.google.com/forum/#!msg/clang-built-linux/_SpkRyhMIxI/IrBtEk-8AAAJ
If you wanted to show some love for the bot:
Reported-by: kbuild test robot <lkp@intel.com>

>
> > ---
> >  drivers/hwtracing/coresight/coresight-cti-sysfs.c | 6 ++----
> >  1 file changed, 2 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/hwtracing/coresight/coresight-cti-sysfs.c b/drivers/hwtracing/coresight/coresight-cti-sysfs.c
> > index abb7f492c2cb..214d6552b494 100644
> > --- a/drivers/hwtracing/coresight/coresight-cti-sysfs.c
> > +++ b/drivers/hwtracing/coresight/coresight-cti-sysfs.c
> > @@ -945,10 +945,8 @@ cti_sig_type_name(struct cti_trig_con *con, int used_count, bool in)
> >         int idx = 0;
> >         struct cti_trig_grp *grp = in ? con->con_in : con->con_out;
> >
> > -       if (grp->sig_types) {
> > -               if (used_count < grp->nr_sigs)
> > -                       idx = grp->sig_types[used_count];
> > -       }
> > +       if (used_count < grp->nr_sigs)
> > +               idx = grp->sig_types[used_count];
> >         return sig_type_names[idx];
> >  }
> >
> > --
>
>
> --
> Thanks,
> ~Nick Desaulniers



-- 
Thanks,
~Nick Desaulniers

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] coresight: cti: Remove unnecessary NULL check in cti_sig_type_name
@ 2020-03-02 21:57     ` Nick Desaulniers
  0 siblings, 0 replies; 8+ messages in thread
From: Nick Desaulniers @ 2020-03-02 21:57 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Mathieu Poirier, Suzuki K Poulose, Alexander Shishkin, LKML,
	clang-built-linux, Linux ARM, Mike Leach

On Mon, Mar 2, 2020 at 1:51 PM Nick Desaulniers <ndesaulniers@google.com> wrote:
>
> On Mon, Mar 2, 2020 at 1:34 PM Nathan Chancellor
> <natechancellor@gmail.com> wrote:
> >
> > Clang warns:
> >
> > drivers/hwtracing/coresight/coresight-cti-sysfs.c:948:11: warning:
> > address of array 'grp->sig_types' will always evaluate to 'true'
> > [-Wpointer-bool-conversion]
> >         if (grp->sig_types) {
> >         ~~  ~~~~~^~~~~~~~~
> > 1 warning generated.
> >
> > sig_types is at the end of a struct so it cannot be NULL.
> >
> > Fixes: 85b6684eab65 ("coresight: cti: Add connection information to sysfs")
> > Link: https://github.com/ClangBuiltLinux/linux/issues/914
> > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
>
> Yep, GCC and Clang both eliminate the false case as impossible:
> https://godbolt.org/z/tjbDqR
> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

0day just reported this, too (3 minutes after you sent your patch)
https://groups.google.com/forum/#!msg/clang-built-linux/_SpkRyhMIxI/IrBtEk-8AAAJ
If you wanted to show some love for the bot:
Reported-by: kbuild test robot <lkp@intel.com>

>
> > ---
> >  drivers/hwtracing/coresight/coresight-cti-sysfs.c | 6 ++----
> >  1 file changed, 2 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/hwtracing/coresight/coresight-cti-sysfs.c b/drivers/hwtracing/coresight/coresight-cti-sysfs.c
> > index abb7f492c2cb..214d6552b494 100644
> > --- a/drivers/hwtracing/coresight/coresight-cti-sysfs.c
> > +++ b/drivers/hwtracing/coresight/coresight-cti-sysfs.c
> > @@ -945,10 +945,8 @@ cti_sig_type_name(struct cti_trig_con *con, int used_count, bool in)
> >         int idx = 0;
> >         struct cti_trig_grp *grp = in ? con->con_in : con->con_out;
> >
> > -       if (grp->sig_types) {
> > -               if (used_count < grp->nr_sigs)
> > -                       idx = grp->sig_types[used_count];
> > -       }
> > +       if (used_count < grp->nr_sigs)
> > +               idx = grp->sig_types[used_count];
> >         return sig_type_names[idx];
> >  }
> >
> > --
>
>
> --
> Thanks,
> ~Nick Desaulniers



-- 
Thanks,
~Nick Desaulniers

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] coresight: cti: Remove unnecessary NULL check in cti_sig_type_name
  2020-03-02 21:34 ` Nathan Chancellor
@ 2020-03-04 17:13   ` Mathieu Poirier
  -1 siblings, 0 replies; 8+ messages in thread
From: Mathieu Poirier @ 2020-03-04 17:13 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Suzuki K Poulose, Mike Leach, Alexander Shishkin,
	linux-arm-kernel, Linux Kernel Mailing List, clang-built-linux

On Mon, 2 Mar 2020 at 14:34, Nathan Chancellor <natechancellor@gmail.com> wrote:
>
> Clang warns:
>
> drivers/hwtracing/coresight/coresight-cti-sysfs.c:948:11: warning:
> address of array 'grp->sig_types' will always evaluate to 'true'
> [-Wpointer-bool-conversion]
>         if (grp->sig_types) {
>         ~~  ~~~~~^~~~~~~~~
> 1 warning generated.
>
> sig_types is at the end of a struct so it cannot be NULL.
>
> Fixes: 85b6684eab65 ("coresight: cti: Add connection information to sysfs")
> Link: https://github.com/ClangBuiltLinux/linux/issues/914
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> ---
>  drivers/hwtracing/coresight/coresight-cti-sysfs.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/hwtracing/coresight/coresight-cti-sysfs.c b/drivers/hwtracing/coresight/coresight-cti-sysfs.c
> index abb7f492c2cb..214d6552b494 100644
> --- a/drivers/hwtracing/coresight/coresight-cti-sysfs.c
> +++ b/drivers/hwtracing/coresight/coresight-cti-sysfs.c
> @@ -945,10 +945,8 @@ cti_sig_type_name(struct cti_trig_con *con, int used_count, bool in)
>         int idx = 0;
>         struct cti_trig_grp *grp = in ? con->con_in : con->con_out;
>
> -       if (grp->sig_types) {
> -               if (used_count < grp->nr_sigs)
> -                       idx = grp->sig_types[used_count];
> -       }
> +       if (used_count < grp->nr_sigs)
> +               idx = grp->sig_types[used_count];
>         return sig_type_names[idx];
>  }

Applied - thanks,
Mathieu

>
> --
> 2.25.1
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] coresight: cti: Remove unnecessary NULL check in cti_sig_type_name
@ 2020-03-04 17:13   ` Mathieu Poirier
  0 siblings, 0 replies; 8+ messages in thread
From: Mathieu Poirier @ 2020-03-04 17:13 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Suzuki K Poulose, Alexander Shishkin, Linux Kernel Mailing List,
	clang-built-linux, linux-arm-kernel, Mike Leach

On Mon, 2 Mar 2020 at 14:34, Nathan Chancellor <natechancellor@gmail.com> wrote:
>
> Clang warns:
>
> drivers/hwtracing/coresight/coresight-cti-sysfs.c:948:11: warning:
> address of array 'grp->sig_types' will always evaluate to 'true'
> [-Wpointer-bool-conversion]
>         if (grp->sig_types) {
>         ~~  ~~~~~^~~~~~~~~
> 1 warning generated.
>
> sig_types is at the end of a struct so it cannot be NULL.
>
> Fixes: 85b6684eab65 ("coresight: cti: Add connection information to sysfs")
> Link: https://github.com/ClangBuiltLinux/linux/issues/914
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> ---
>  drivers/hwtracing/coresight/coresight-cti-sysfs.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/hwtracing/coresight/coresight-cti-sysfs.c b/drivers/hwtracing/coresight/coresight-cti-sysfs.c
> index abb7f492c2cb..214d6552b494 100644
> --- a/drivers/hwtracing/coresight/coresight-cti-sysfs.c
> +++ b/drivers/hwtracing/coresight/coresight-cti-sysfs.c
> @@ -945,10 +945,8 @@ cti_sig_type_name(struct cti_trig_con *con, int used_count, bool in)
>         int idx = 0;
>         struct cti_trig_grp *grp = in ? con->con_in : con->con_out;
>
> -       if (grp->sig_types) {
> -               if (used_count < grp->nr_sigs)
> -                       idx = grp->sig_types[used_count];
> -       }
> +       if (used_count < grp->nr_sigs)
> +               idx = grp->sig_types[used_count];
>         return sig_type_names[idx];
>  }

Applied - thanks,
Mathieu

>
> --
> 2.25.1
>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-03-04 17:14 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-02 21:34 [PATCH] coresight: cti: Remove unnecessary NULL check in cti_sig_type_name Nathan Chancellor
2020-03-02 21:34 ` Nathan Chancellor
2020-03-02 21:51 ` Nick Desaulniers
2020-03-02 21:51   ` Nick Desaulniers
2020-03-02 21:57   ` Nick Desaulniers
2020-03-02 21:57     ` Nick Desaulniers
2020-03-04 17:13 ` Mathieu Poirier
2020-03-04 17:13   ` Mathieu Poirier

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.