Skip to contentSkip to conversation

clk/sophgo: Using BUG() instead of unreachable() in mmux_get_parent_id()

PATCH Applied Li Qiang 3 participants 3 messages Jul 9, 2024 – Jul 10, 2024 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Li Qiang

author
#1 lore raw

PATCH v2 1/1 clk/sophgo: Using BUG() instead of unreachable() in mmux_get_parent_id()

In general it's a good idea to avoid using bare unreachable() because it introduces undefined behavior in compiled code. but it caused a compilation warning, Using BUG() instead of unreachable() to resolve compilation warnings.

Fixes the following warnings:
drivers/clk/sophgo/clk-cv18xx-ip.o: warning: objtool: mmux_round_rate() falls through to next function bypass_div_round_rate()

Fixes 80fd61ec46124 ("clk: sophgo: Add clock support for CV1800 SoC")
---
 drivers/clk/sophgo/clk-cv18xx-ip.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/sophgo/clk-cv18xx-ip.c +1 -1
index 805f561725ae..b186e64d4813 100644
@@ -613,7 +613,7 @@ static u8 mmux_get_parent_id(struct cv1800_clk_mmux *mmux)
 			return i;
 	}
 
-	unreachable();
+	BUG();
 }
 
 static int mmux_enable(struct clk_hw *hw)
Signature · 1 line
2.25.1
#2 lore raw
Quoted 6 lines · Li Qiang

In general it's a good idea to avoid using bare unreachable() because it introduces undefined behavior in compiled code. but it caused a compilation warning, Using BUG() instead of unreachable() to resolve compilation warnings.

Fixes the following warnings:
drivers/clk/sophgo/clk-cv18xx-ip.o: warning: objtool: mmux_round_rate() falls through to next function bypass_div_round_rate()

I tried to build this drivers/clk/sophgo/clk-cv18xx-ip.c but don't see the warning. I'm using make W=1 with gcc 13.2.0

What's the meaning of this warning message and how to reproduce this?

Quoted 20 lines
Fixes 80fd61ec46124 ("clk: sophgo: Add clock support for CV1800 SoC")
---
  drivers/clk/sophgo/clk-cv18xx-ip.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/sophgo/clk-cv18xx-ip.c +1 -1
index 805f561725ae..b186e64d4813 100644
@@ -613,7 +613,7 @@ static u8 mmux_get_parent_id(struct cv1800_clk_mmux *mmux)
  			return i;
  	}
 
-	unreachable();
+	BUG();
  }
 
  static int mmux_enable(struct clk_hw *hw)
maintainer Applied
#3 lore raw
In reply to Li Qiang

Quoting Li Qiang (2024-07-08 23:36:38)

Quoted 10 lines

In general it's a good idea to avoid using bare unreachable() because it introduces undefined behavior in compiled code. but it caused a compilation warning, Using BUG() instead of unreachable() to resolve compilation warnings.

Fixes the following warnings:
drivers/clk/sophgo/clk-cv18xx-ip.o: warning: objtool: mmux_round_rate() falls through to next function bypass_div_round_rate()

Fixes 80fd61ec46124 ("clk: sophgo: Add clock support for CV1800 SoC")

---

Applied to clk-next