Skip to content

Commit

Permalink
thunderbolt: Make priority unsigned in struct tb_path
Browse files Browse the repository at this point in the history
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;

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

Fixes: 44242d6 ("thunderbolt: Add support for DMA tunnels")
Link: ClangBuiltLinux#454
Signed-off-by: Nathan Chancellor <[email protected]>
Reviewed-by: Nick Desaulniers <[email protected]>
Signed-off-by: Mika Westerberg <[email protected]>
  • Loading branch information
nathanchance authored and westeri committed Apr 25, 2019
1 parent c4630d6 commit 3720978
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/thunderbolt/tb.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 3720978

Please sign in to comment.