Skip to contentSkip to conversation

board: ti: common: Fix pointer-bool-conversion warnings

PATCH New Tom Rini 2 participants 3 messages Jun 4, 2020 – Jun 18, 2020

lore
Share & tools
lore

Tom Rini

author
#0 lore raw

PATCH 1/1 board: ti: common: Fix pointer-bool-conversion warnings

When building this code with clang-10 a number of warnings will be generated along the lines of:
warning: address of array 'ep->version' will always evaluate to 'true'

Convert these checks to checking the strlen of the part of the array we care about. As this array will be null terminated previously by us, this is safe.

Cc Lokesh Vutla <[email protected]>
---
 board/ti/common/board_detect.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
board/ti/common/board_detect.c +7 -7
index 429668404a3b..e09ecda4d7e6 100644
@@ -669,17 +669,17 @@ void __maybe_unused set_board_info_env(char *name)
 
 	if (name)
 		env_set("board_name", name);
-	else if (ep->name)
+	else if (strlen(ep->name) != 0)
 		env_set("board_name", ep->name);
 	else
 		env_set("board_name", unknown);
 
-	if (ep->version)
+	if (strlen(ep->version) != 0)
 		env_set("board_rev", ep->version);
 	else
 		env_set("board_rev", unknown);
 
-	if (ep->serial)
+	if (strlen(ep->serial) != 0)
 		env_set("board_serial", ep->serial);
 	else
 		env_set("board_serial", unknown);
@@ -692,22 +692,22 @@ void __maybe_unused set_board_info_env_am6(char *name)
 
 	if (name)
 		env_set("board_name", name);
-	else if (ep->name)
+	else if (strlen(ep->name) != 0)
 		env_set("board_name", ep->name);
 	else
 		env_set("board_name", unknown);
 
-	if (ep->version)
+	if (strlen(ep->version) != 0)
 		env_set("board_rev", ep->version);
 	else
 		env_set("board_rev", unknown);
 
-	if (ep->software_revision)
+	if (strlen(ep->software_revision) != 0)
 		env_set("board_software_revision", ep->software_revision);
 	else
 		env_set("board_software_revision", unknown);
 
-	if (ep->serial)
+	if (strlen(ep->serial) != 0)
 		env_set("board_serial", ep->serial);
 	else
 		env_set("board_serial", unknown);
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/1 board: ti: common: Fix pointer-bool-conversion warnings

Quoted 9 lines · Tom Rini

When building this code with clang-10 a number of warnings will be generated along the lines of:
warning: address of array 'ep->version' will always evaluate to 'true'

Convert these checks to checking the strlen of the part of the array we care about. As this array will be null terminated previously by us, this is safe.

Cc Lokesh Vutla <[email protected]>> Signed-off-by: Tom Rini <[email protected]>

Thanks and regards,
Lokesh

#2 lore raw

PATCH 1/1 board: ti: common: Fix pointer-bool-conversion warnings

In reply to Tom Rini
Quoted 10 lines · Tom Rini

When building this code with clang-10 a number of warnings will be generated along the lines of:
warning: address of array 'ep->version' will always evaluate to 'true'

Convert these checks to checking the strlen of the part of the array we care about. As this array will be null terminated previously by us, this is safe.

Cc Lokesh Vutla <[email protected]>

Applied to u-boot-ti next.

Thanks and regards,
Lokesh