Skip to contentSkip to conversation

arm: sunxi: Correct warning in board_fit_config_name_match

PATCH In review Tom Rini 3 participants 3 messages Jul 17, 2023 – Nov 1, 2023 Arm/Allwinner sunXi SoC support

lore
Share & tools
lore

Tom Rini

author
#0 lore raw

PATCH 1/1 arm: sunxi: Correct warning in board_fit_config_name_match

When building this with clang, we get a warning about having excess parenthesis here, or that we're incorrectly using "==" when we want "=". Correct these by using parenthesis around our multiplication of constants as this is what was likely intended originally, even if not strictly required.

---
Cc: Andre Przywara <[email protected]>

---
 board/sunxi/board.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
board/sunxi/board.c +1 -1
index f321cd58a6e6..643e8db185b4 100644
@@ -957,7 +957,7 @@ int board_fit_config_name_match(const char *name)
 #ifdef CONFIG_PINE64_DT_SELECTION
 	if (strstr(best_dt_name, "-pine64-plus")) {
 		/* Differentiate the Pine A64 boards by their DRAM size. */
-		if ((gd->ram_size == 512 * 1024 * 1024))
+		if (gd->ram_size == (512 * 1024 * 1024))
 			best_dt_name = "sun50i-a64-pine64";
 	}
 #endif
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw

Hi Tom,

Quoted 19 lines · Tom Rini

When building this with clang, we get a warning about having excess parenthesis here, or that we're incorrectly using "==" when we want "=". Correct these by using parenthesis around our multiplication of constants as this is what was likely intended originally, even if not strictly required.

---
Cc: Andre Przywara <[email protected]>

---
 board/sunxi/board.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
board/sunxi/board.c +0 -0
index f321cd58a6e6..643e8db185b4 100644

board/sunxi/board.c int board_fit_config_name_match(const char *name) · line 960

Quoted 5 lines
board/sunxi/board.c +1 -1
@@ -957,7 +957,7 @@ int board_fit_config_name_match(const char *name)
 #ifdef CONFIG_PINE64_DT_SELECTION
        if (strstr(best_dt_name, "-pine64-plus")) {
                /* Differentiate the Pine A64 boards by their DRAM size. */
-               if ((gd->ram_size == 512 * 1024 * 1024))
+               if (gd->ram_size == (512 * 1024 * 1024))

But I suggest:

if (gd->ram_size == 512 * 1024 * 1024) // or SZ_512M

since the extra brackets might confuse people about the operator precedence.

Quoted 6 lines
board/sunxi/board.c +0 -1
                        best_dt_name = "sun50i-a64-pine64";
        }
 #endif
--

2.34.1

Regards,
Simon

#2 lore raw
In reply to Tom Rini

On Mon, 17 Jul 2023 15:29:20 -0400
Tom Rini <[email protected]> wrote:

Hi Tom,

Quoted 5 lines

When building this with clang, we get a warning about having excess parenthesis here, or that we're incorrectly using "==" when we want "=". Correct these by using parenthesis around our multiplication of constants as this is what was likely intended originally, even if not strictly required.

thanks, I will take this with SZ_512M, as Simon suggested. Will be part of the next PR.

Cheers,
Andre

Quoted 21 lines

---
Cc: Andre Przywara <[email protected]>

---
 board/sunxi/board.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
board/sunxi/board.c +1 -1
index f321cd58a6e6..643e8db185b4 100644
@@ -957,7 +957,7 @@ int board_fit_config_name_match(const char *name)
 #ifdef CONFIG_PINE64_DT_SELECTION
 	if (strstr(best_dt_name, "-pine64-plus")) {
 		/* Differentiate the Pine A64 boards by their DRAM size. */
-		if ((gd->ram_size == 512 * 1024 * 1024))
+		if (gd->ram_size == (512 * 1024 * 1024))
 			best_dt_name = "sun50i-a64-pine64";
 	}
 #endif