Elyes Haouas has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/70201 )
Change subject: lint/checkpatch: Add check for initialized const char arrays ......................................................................
lint/checkpatch: Add check for initialized const char arrays
This reduce the difference with linux v6.1-rc7.
Change-Id: I9f0e9f12a177c32b401fda74cbb30c5c259b3744 Signed-off-by: Elyes Haouas ehaouas@noos.fr --- M src/drivers/intel/fsp1_1/raminit.c M src/drivers/uart/uart8250io.c M src/drivers/uart/uart8250mem.c M src/lib/ubsan.c M util/lint/checkpatch.pl 5 files changed, 30 insertions(+), 9 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/01/70201/1
diff --git a/src/drivers/intel/fsp1_1/raminit.c b/src/drivers/intel/fsp1_1/raminit.c index 7da85d4..4c316a9 100644 --- a/src/drivers/intel/fsp1_1/raminit.c +++ b/src/drivers/intel/fsp1_1/raminit.c @@ -128,7 +128,7 @@ } else { fsp_reserved_bytes = fsp_memory->ResourceLength; printk(BIOS_DEBUG, "Reserving 0x%016lx bytes for FSP\n", - (unsigned long int)fsp_reserved_bytes); + (unsigned long)fsp_reserved_bytes); }
/* Display SMM area */ diff --git a/src/drivers/uart/uart8250io.c b/src/drivers/uart/uart8250io.c index a7fc346..89ec229 100644 --- a/src/drivers/uart/uart8250io.c +++ b/src/drivers/uart/uart8250io.c @@ -26,14 +26,14 @@
static void uart8250_tx_byte(unsigned int base_port, unsigned char data) { - unsigned long int i = SINGLE_CHAR_TIMEOUT; + unsigned long i = SINGLE_CHAR_TIMEOUT; while (i-- && !uart8250_can_tx_byte(base_port)); outb(data, base_port + UART8250_TBR); }
static void uart8250_tx_flush(unsigned int base_port) { - unsigned long int i = FIFO_TIMEOUT; + unsigned long i = FIFO_TIMEOUT; while (i-- && !(inb(base_port + UART8250_LSR) & UART8250_LSR_TEMT)); }
@@ -44,7 +44,7 @@
static unsigned char uart8250_rx_byte(unsigned int base_port) { - unsigned long int i = SINGLE_CHAR_TIMEOUT; + unsigned long i = SINGLE_CHAR_TIMEOUT; while (i && !uart8250_can_rx_byte(base_port)) i--;
diff --git a/src/drivers/uart/uart8250mem.c b/src/drivers/uart/uart8250mem.c index 19677a8..fcf031e 100644 --- a/src/drivers/uart/uart8250mem.c +++ b/src/drivers/uart/uart8250mem.c @@ -46,7 +46,7 @@
static void uart8250_mem_tx_byte(void *base, unsigned char data) { - unsigned long int i = SINGLE_CHAR_TIMEOUT; + unsigned long i = SINGLE_CHAR_TIMEOUT; while (i-- && !uart8250_mem_can_tx_byte(base)) udelay(1); uart8250_write(base, UART8250_TBR, data); @@ -54,7 +54,7 @@
static void uart8250_mem_tx_flush(void *base) { - unsigned long int i = FIFO_TIMEOUT; + unsigned long i = FIFO_TIMEOUT; while (i-- && !(uart8250_read(base, UART8250_LSR) & UART8250_LSR_TEMT)) udelay(1); } @@ -66,7 +66,7 @@
static unsigned char uart8250_mem_rx_byte(void *base) { - unsigned long int i = SINGLE_CHAR_TIMEOUT; + unsigned long i = SINGLE_CHAR_TIMEOUT; while (i && !uart8250_mem_can_rx_byte(base)) { udelay(1); i--; diff --git a/src/lib/ubsan.c b/src/lib/ubsan.c index 1037b1b..894214ca 100644 --- a/src/lib/ubsan.c +++ b/src/lib/ubsan.c @@ -40,8 +40,8 @@ if (!location || !location->filename) location = &unknown_location; printk(BIOS_ERR, "%s %s:%lu:%lu\n", violation, location->filename, - (unsigned long int)location->line, - (unsigned long int)location->column); + (unsigned long)location->line, + (unsigned long)location->column); die("ubsan: unrecoverable error.\n"); }
diff --git a/util/lint/checkpatch.pl b/util/lint/checkpatch.pl index 8756f46..03b6851 100755 --- a/util/lint/checkpatch.pl +++ b/util/lint/checkpatch.pl @@ -4248,6 +4248,15 @@ $herecurr); }
+# check for initialized const char arrays that should be static const + if ($line =~ /^+\s*const\s+(char|unsigned\s+char|_*u8|(?:[us]_)?int8_t)\s+\w+\s*[\s*(?:\w+\s*)?]\s*=\s*"/) { + if (WARN("STATIC_CONST_CHAR_ARRAY", + "const array should probably be static const\n" . $herecurr) && + $fix) { + $fixed[$fixlinenr] =~ s/(^.\s*)const\b/${1}static const/; + } + } + # check for static char foo[] = "bar" declarations. if ($line =~ /\bstatic\s+char\s+(\w+)\s*[\s*]\s*=\s*"/) { WARN("STATIC_CONST_CHAR_ARRAY",