Skip to contentSkip to conversation

thunderbolt: Make priority unsigned in struct tb_path

PATCH In review Nathan Chancellor 3 participants 5 messages Apr 24, 2019 – Apr 25, 2019 Thunderbolt driver

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 thunderbolt: Make priority unsigned in struct tb_path

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")
---
 drivers/thunderbolt/tb.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thunderbolt/tb.h +1 -1
index 15d225dcb403..b12c8f33d89c 100644
@@ -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;
Signature · 1 line
2.21.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · 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.

Quoted 8 lines

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!

Quoted 27 lines

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")
---
 drivers/thunderbolt/tb.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thunderbolt/tb.h +1 -2
index 15d225dcb403..b12c8f33d89c 100644
@@ -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

Signature · 2 lines
Thanks,
~Nick Desaulniers
#2 lore raw
Quoted 21 lines · Nick Desaulniers
Quoted 10 lines · 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.

Quoted 8 lines

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;
Quoted 8 lines

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!

Thanks for the review!

Quoted 3 lines
Quoted 3 lines

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

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

Quoted 30 lines
Quoted 25 lines

tb_path_activate (the priority member in struct tb_regs_hop).

Fixes 44242d6c9703 ("thunderbolt: Add support for DMA tunnels")
---
 drivers/thunderbolt/tb.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thunderbolt/tb.h +1 -2
index 15d225dcb403..b12c8f33d89c 100644
@@ -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

Signature · 2 lines
Thanks,
~Nick Desaulniers
#3 lore raw
Quoted 3 lines · Nathan Chancellor
Quoted 1 line
Quoted 1 line

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.

Signature · 2 lines
Thanks,
~Nick Desaulniers
#4 lore raw
In reply to Nathan Chancellor
Quoted 31 lines · Nathan Chancellor
Quoted 21 lines · Nick Desaulniers
Quoted 10 lines · 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.

Quoted 8 lines

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;
Quoted 8 lines

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!

Quoted 7 lines

Thanks for the review!

Quoted 3 lines
Quoted 3 lines

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!