Skip to contentSkip to conversation

xilinx: common: Fix static checker warnings

PATCH Applied Venkatesh Yadav Abbarapu 2 participants 2 messages Sep 26, 2022 – Oct 4, 2022 Arm/Zynq architecture

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xilinx: common: Fix static checker warnings

Avoid signed extension for uuid and byte.

Eliminate the below smatch warnings:
board/xilinx/common/board.c:128 xilinx_eeprom_legacy_cleanup()
warn: impossible condition '(byte == 255) => ((-128)-127 == 255)'

board/xilinx/common/board.c:466 board_late_init_xilinx()
warn: argument 3 to %02x specifier has type 'char' board/xilinx/common/board.c:466 board_late_init_xilinx()
warn: argument 4 to %02x specifier has type 'char'

---

 board/xilinx/common/board.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
board/xilinx/common/board.c +3 -3
index 9b4aded466..2b6ead5269 100644
@@ -119,7 +119,7 @@ struct xilinx_legacy_format {
 static void xilinx_eeprom_legacy_cleanup(char *eeprom, int size)
 {
 	int i;
-	char byte;
+	unsigned char byte;
 
 	for (i = 0; i < size; i++) {
 		byte = eeprom[i];
@@ -458,8 +458,8 @@ int board_late_init_xilinx(void)
 							desc->serial);
 
 			if (desc->uuid[0]) {
-				char uuid[UUID_STR_LEN + 1];
-				char *t = desc->uuid;
+				unsigned char uuid[UUID_STR_LEN + 1];
+				unsigned char *t = desc->uuid;
 
 				memset(uuid, 0, UUID_STR_LEN + 1);
 
Signature · 1 line
2.17.1
maintainer Applied
#1 lore raw
Quoted 31 lines · Venkatesh Yadav Abbarapu

Avoid signed extension for uuid and byte.

Eliminate the below smatch warnings:
board/xilinx/common/board.c:128 xilinx_eeprom_legacy_cleanup()
warn: impossible condition '(byte == 255) => ((-128)-127 == 255)'

board/xilinx/common/board.c:466 board_late_init_xilinx()
warn: argument 3 to %02x specifier has type 'char' board/xilinx/common/board.c:466 board_late_init_xilinx()
warn: argument 4 to %02x specifier has type 'char'

---

  board/xilinx/common/board.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
board/xilinx/common/board.c +1 -1
index 9b4aded466..2b6ead5269 100644
@@ -119,7 +119,7 @@ struct xilinx_legacy_format {
  static void xilinx_eeprom_legacy_cleanup(char *eeprom, int size)
  {
  	int i;
-	char byte;
+	unsigned char byte;
 
  	for (i = 0; i < size; i++) {
  		byte = eeprom[i];

board/xilinx/common/board.c int board_late_init_xilinx(void) · line 465

Quoted 10 lines
board/xilinx/common/board.c +2 -2
@@ -458,8 +458,8 @@ int board_late_init_xilinx(void)
  							desc->serial);
 
  			if (desc->uuid[0]) {
-				char uuid[UUID_STR_LEN + 1];
-				char *t = desc->uuid;
+				unsigned char uuid[UUID_STR_LEN + 1];
+				unsigned char *t = desc->uuid;
 
  				memset(uuid, 0, UUID_STR_LEN + 1);
 

Applied.
M