All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] thunderbolt: Make priority unsigned in struct tb_path
@ 2019-04-24 18:34 Nathan Chancellor
  2019-04-24 18:49 ` Nick Desaulniers
  0 siblings, 1 reply; 5+ messages in thread
From: Nathan Chancellor @ 2019-04-24 18:34 UTC (permalink / raw)
  To: Andreas Noever, Michael Jamet, Mika Westerberg, Yehezkel Bernat
  Cc: linux-kernel, clang-built-linux, Nick Desaulniers, Nathan Chancellor

Clang warns:

drivers/thunderbolt/tunnel.c:504:17: warning: implicit truncation from
'int' to bit-field changes value from 5 to -3
[-Wbitfield-constant-conversion]
        path->priority = 5;
                       ^ ~
1 warning generated.

The priority member in struct tb_path is only ever assigned a positive
number:

$ rg -n priority drivers/thunderbolt/path.c
drivers/thunderbolt/tunnel.c:99:        path->priority = 3;
drivers/thunderbolt/tunnel.c:308:       path->priority = 2;
drivers/thunderbolt/tunnel.c:323:       path->priority = 1;
drivers/thunderbolt/tunnel.c:504:       path->priority = 5;

Furthmore, that value is only assigned to an unsigned integer in
tb_path_activate (the priority member in struct tb_regs_hop).

Fixes: 44242d6c9703 ("thunderbolt: Add support for DMA tunnels")
Link: https://github.com/ClangBuiltLinux/linux/issues/454
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
 drivers/thunderbolt/tb.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/thunderbolt/tb.h b/drivers/thunderbolt/tb.h
index 15d225dcb403..b12c8f33d89c 100644
--- a/drivers/thunderbolt/tb.h
+++ b/drivers/thunderbolt/tb.h
@@ -225,7 +225,7 @@ struct tb_path {
 	enum tb_path_port ingress_fc_enable;
 	enum tb_path_port egress_fc_enable;
 
-	int priority:3;
+	unsigned int priority:3;
 	int weight:4;
 	bool drop_packages;
 	bool activated;
-- 
2.21.0


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

* Re: [PATCH] thunderbolt: Make priority unsigned in struct tb_path
  2019-04-24 18:34 [PATCH] thunderbolt: Make priority unsigned in struct tb_path Nathan Chancellor
@ 2019-04-24 18:49 ` Nick Desaulniers
  2019-04-24 19:00   ` Nathan Chancellor
  0 siblings, 1 reply; 5+ messages in thread
From: Nick Desaulniers @ 2019-04-24 18:49 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Andreas Noever, Michael Jamet, Mika Westerberg, Yehezkel Bernat,
	LKML, clang-built-linux

On Wed, Apr 24, 2019 at 11:34 AM Nathan Chancellor
<natechancellor@gmail.com> wrote:
>
> Clang warns:
>
> drivers/thunderbolt/tunnel.c:504:17: warning: implicit truncation from
> 'int' to bit-field changes value from 5 to -3
> [-Wbitfield-constant-conversion]
>         path->priority = 5;
>                        ^ ~
> 1 warning generated.
>
> The priority member in struct tb_path is only ever assigned a positive
> number:
>
> $ rg -n priority drivers/thunderbolt/path.c
> drivers/thunderbolt/tunnel.c:99:        path->priority = 3;
> drivers/thunderbolt/tunnel.c:308:       path->priority = 2;
> drivers/thunderbolt/tunnel.c:323:       path->priority = 1;
> drivers/thunderbolt/tunnel.c:504:       path->priority = 5;

LGTM.  Looks like drivers/thunderbolt/tb_regs.h also defines it as u32
(no change needed here).
Triple checking it's uses, looks like it gets assigned:
drivers/thunderbolt/path.c#L492:
hop.priority = path->priority;
hop is an instance of a struct tb_regs_hop, which is the definition I
was looking at above.  LGTM thanks Nathan!
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

>
> Furthmore, that value is only assigned to an unsigned integer in
> tb_path_activate (the priority member in struct tb_regs_hop).
>
> Fixes: 44242d6c9703 ("thunderbolt: Add support for DMA tunnels")
> Link: https://github.com/ClangBuiltLinux/linux/issues/454
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> ---
>  drivers/thunderbolt/tb.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/thunderbolt/tb.h b/drivers/thunderbolt/tb.h
> index 15d225dcb403..b12c8f33d89c 100644
> --- a/drivers/thunderbolt/tb.h
> +++ b/drivers/thunderbolt/tb.h
> @@ -225,7 +225,7 @@ struct tb_path {
>         enum tb_path_port ingress_fc_enable;
>         enum tb_path_port egress_fc_enable;
>
> -       int priority:3;
> +       unsigned int priority:3;
>         int weight:4;
>         bool drop_packages;
>         bool activated;
> --
> 2.21.0
>


-- 
Thanks,
~Nick Desaulniers

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

* Re: [PATCH] thunderbolt: Make priority unsigned in struct tb_path
  2019-04-24 18:49 ` Nick Desaulniers
@ 2019-04-24 19:00   ` Nathan Chancellor
  2019-04-24 19:02     ` Nick Desaulniers
  2019-04-25  9:22     ` Mika Westerberg
  0 siblings, 2 replies; 5+ messages in thread
From: Nathan Chancellor @ 2019-04-24 19:00 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: Andreas Noever, Michael Jamet, Mika Westerberg, Yehezkel Bernat,
	LKML, clang-built-linux

On Wed, Apr 24, 2019 at 11:49:37AM -0700, Nick Desaulniers wrote:
> On Wed, Apr 24, 2019 at 11:34 AM Nathan Chancellor
> <natechancellor@gmail.com> wrote:
> >
> > Clang warns:
> >
> > drivers/thunderbolt/tunnel.c:504:17: warning: implicit truncation from
> > 'int' to bit-field changes value from 5 to -3
> > [-Wbitfield-constant-conversion]
> >         path->priority = 5;
> >                        ^ ~
> > 1 warning generated.
> >
> > The priority member in struct tb_path is only ever assigned a positive
> > number:
> >
> > $ rg -n priority drivers/thunderbolt/path.c
> > drivers/thunderbolt/tunnel.c:99:        path->priority = 3;
> > drivers/thunderbolt/tunnel.c:308:       path->priority = 2;
> > drivers/thunderbolt/tunnel.c:323:       path->priority = 1;
> > drivers/thunderbolt/tunnel.c:504:       path->priority = 5;
> 
> LGTM.  Looks like drivers/thunderbolt/tb_regs.h also defines it as u32
> (no change needed here).
> Triple checking it's uses, looks like it gets assigned:
> drivers/thunderbolt/path.c#L492:
> hop.priority = path->priority;
> hop is an instance of a struct tb_regs_hop, which is the definition I
> was looking at above.  LGTM thanks Nathan!
> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

Thanks for the review!

> 
> >
> > Furthmore, that value is only assigned to an unsigned integer in

Although apparently I can't spell... should be "Furthermore".

> > tb_path_activate (the priority member in struct tb_regs_hop).
> >
> > Fixes: 44242d6c9703 ("thunderbolt: Add support for DMA tunnels")
> > Link: https://github.com/ClangBuiltLinux/linux/issues/454
> > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> > ---
> >  drivers/thunderbolt/tb.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/thunderbolt/tb.h b/drivers/thunderbolt/tb.h
> > index 15d225dcb403..b12c8f33d89c 100644
> > --- a/drivers/thunderbolt/tb.h
> > +++ b/drivers/thunderbolt/tb.h
> > @@ -225,7 +225,7 @@ struct tb_path {
> >         enum tb_path_port ingress_fc_enable;
> >         enum tb_path_port egress_fc_enable;
> >
> > -       int priority:3;
> > +       unsigned int priority:3;
> >         int weight:4;
> >         bool drop_packages;
> >         bool activated;
> > --
> > 2.21.0
> >
> 
> 
> -- 
> Thanks,
> ~Nick Desaulniers

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

* Re: [PATCH] thunderbolt: Make priority unsigned in struct tb_path
  2019-04-24 19:00   ` Nathan Chancellor
@ 2019-04-24 19:02     ` Nick Desaulniers
  2019-04-25  9:22     ` Mika Westerberg
  1 sibling, 0 replies; 5+ messages in thread
From: Nick Desaulniers @ 2019-04-24 19:02 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Andreas Noever, Michael Jamet, Mika Westerberg, Yehezkel Bernat,
	LKML, clang-built-linux

On Wed, Apr 24, 2019 at 12:00 PM Nathan Chancellor
<natechancellor@gmail.com> wrote:
> > > Furthmore, that value is only assigned to an unsigned integer in
>
> Although apparently I can't spell... should be "Furthermore".

:set spell

there's probably a way to autoset this for commit messages.
-- 
Thanks,
~Nick Desaulniers

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

* Re: [PATCH] thunderbolt: Make priority unsigned in struct tb_path
  2019-04-24 19:00   ` Nathan Chancellor
  2019-04-24 19:02     ` Nick Desaulniers
@ 2019-04-25  9:22     ` Mika Westerberg
  1 sibling, 0 replies; 5+ messages in thread
From: Mika Westerberg @ 2019-04-25  9:22 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Nick Desaulniers, Andreas Noever, Michael Jamet, Yehezkel Bernat,
	LKML, clang-built-linux

On Wed, Apr 24, 2019 at 12:00:05PM -0700, Nathan Chancellor wrote:
> On Wed, Apr 24, 2019 at 11:49:37AM -0700, Nick Desaulniers wrote:
> > On Wed, Apr 24, 2019 at 11:34 AM Nathan Chancellor
> > <natechancellor@gmail.com> wrote:
> > >
> > > Clang warns:
> > >
> > > drivers/thunderbolt/tunnel.c:504:17: warning: implicit truncation from
> > > 'int' to bit-field changes value from 5 to -3
> > > [-Wbitfield-constant-conversion]
> > >         path->priority = 5;
> > >                        ^ ~
> > > 1 warning generated.
> > >
> > > The priority member in struct tb_path is only ever assigned a positive
> > > number:
> > >
> > > $ rg -n priority drivers/thunderbolt/path.c
> > > drivers/thunderbolt/tunnel.c:99:        path->priority = 3;
> > > drivers/thunderbolt/tunnel.c:308:       path->priority = 2;
> > > drivers/thunderbolt/tunnel.c:323:       path->priority = 1;
> > > drivers/thunderbolt/tunnel.c:504:       path->priority = 5;
> > 
> > LGTM.  Looks like drivers/thunderbolt/tb_regs.h also defines it as u32
> > (no change needed here).
> > Triple checking it's uses, looks like it gets assigned:
> > drivers/thunderbolt/path.c#L492:
> > hop.priority = path->priority;
> > hop is an instance of a struct tb_regs_hop, which is the definition I
> > was looking at above.  LGTM thanks Nathan!
> > Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
> 
> Thanks for the review!
> 
> > 
> > >
> > > Furthmore, that value is only assigned to an unsigned integer in
> 
> Although apparently I can't spell... should be "Furthermore".

Fixed the typo and applied to thunderbolt.git/next, thanks!

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

end of thread, other threads:[~2019-04-25  9:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-24 18:34 [PATCH] thunderbolt: Make priority unsigned in struct tb_path Nathan Chancellor
2019-04-24 18:49 ` Nick Desaulniers
2019-04-24 19:00   ` Nathan Chancellor
2019-04-24 19:02     ` Nick Desaulniers
2019-04-25  9:22     ` Mika Westerberg

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.