thunderbolt: Make priority unsigned in struct tb_path
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).
--- drivers/thunderbolt/tb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thunderbolt/tb.h +1 -1
@@ -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
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_pathis 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 structtb_regs_hop).Fixes 44242d6c9703 ("thunderbolt: Add support for DMA tunnels")Signed-off-by Nathan Chancellor <[email protected]>--- drivers/thunderbolt/tb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/thunderbolt/tb.h +1
-2@@ -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
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_pathis 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.halso 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 structtb_regs_hop, which is the definition I was looking at above. LGTM thanks Nathan!Reviewed-by Nick Desaulniers <[email protected]>
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 structtb_regs_hop).Fixes 44242d6c9703 ("thunderbolt: Add support for DMA tunnels")Signed-off-by Nathan Chancellor <[email protected]>--- drivers/thunderbolt/tb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/thunderbolt/tb.h +1
-2@@ -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
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
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_pathis 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.halso 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 structtb_regs_hop, which is the definition I was looking at above. LGTM thanks Nathan!Reviewed-by Nick Desaulniers <[email protected]>
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!