Skip to content

Commit a708376

Browse files
nathanchancethierryreding
authored andcommitted
soc/tegra: fuse: Fix bitwise vs. logical OR warning
A new warning in clang points out two instances where boolean expressions are being used with a bitwise OR instead of logical OR: drivers/soc/tegra/fuse/speedo-tegra20.c:72:9: warning: use of bitwise '|' with boolean operands [-Wbitwise-instead-of-logical] reg = tegra_fuse_read_spare(i) | ^~~~~~~~~~~~~~~~~~~~~~~~~~ || drivers/soc/tegra/fuse/speedo-tegra20.c:72:9: note: cast one or both operands to int to silence this warning drivers/soc/tegra/fuse/speedo-tegra20.c:87:9: warning: use of bitwise '|' with boolean operands [-Wbitwise-instead-of-logical] reg = tegra_fuse_read_spare(i) | ^~~~~~~~~~~~~~~~~~~~~~~~~~ || drivers/soc/tegra/fuse/speedo-tegra20.c:87:9: note: cast one or both operands to int to silence this warning 2 warnings generated. The motivation for the warning is that logical operations short circuit while bitwise operations do not. In this instance, tegra_fuse_read_spare() is not semantically returning a boolean, it is returning a bit value. Use u32 for its return type so that it can be used with either bitwise or boolean operators without any warnings. Fixes: 25cd5a3 ("ARM: tegra: Add speedo-based process identification") Link: ClangBuiltLinux#1488 Suggested-by: Michał Mirosław <[email protected]> Signed-off-by: Nathan Chancellor <[email protected]> Reviewed-by: Nick Desaulniers <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
1 parent 76d8947 commit a708376

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

drivers/soc/tegra/fuse/fuse-tegra.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ static struct platform_driver tegra_fuse_driver = {
320320
};
321321
builtin_platform_driver(tegra_fuse_driver);
322322

323-
bool __init tegra_fuse_read_spare(unsigned int spare)
323+
u32 __init tegra_fuse_read_spare(unsigned int spare)
324324
{
325325
unsigned int offset = fuse->soc->info->spare + spare * 4;
326326

drivers/soc/tegra/fuse/fuse.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ struct tegra_fuse {
6565
void tegra_init_revision(void);
6666
void tegra_init_apbmisc(void);
6767

68-
bool __init tegra_fuse_read_spare(unsigned int spare);
68+
u32 __init tegra_fuse_read_spare(unsigned int spare);
6969
u32 __init tegra_fuse_read_early(unsigned int offset);
7070

7171
u8 tegra_get_major_rev(void);

0 commit comments

Comments
 (0)