From ae8dd20d77385ed9822d17345c68ee54362cdfb2 Mon Sep 17 00:00:00 2001 From: Bill Richardson Date: Mon, 27 Feb 2012 15:04:37 -0800 Subject: [PATCH] Make all warnings into errors. Also fix a couple places where that makes it fail. BUG=none TEST=none Change-Id: I3b434b4bfa547a579193aac67c1a9d440a2c4e51 --- Makefile.toolchain | 2 +- chip/lm4/flash.c | 17 ++++++++--------- common/flash_commands.c | 6 +++--- include/flash.h | 4 ++-- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/Makefile.toolchain b/Makefile.toolchain index 90a3ca4990..89977f5c78 100644 --- a/Makefile.toolchain +++ b/Makefile.toolchain @@ -17,7 +17,7 @@ OBJDUMP=$(CROSS_COMPILE)objdump BUILDCC?=gcc HOSTCC?=$(HOST_CROSS_COMPILE)gcc -CFLAGS_WARN=-Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ +CFLAGS_WARN=-Wall -Werror -Wundef -Wstrict-prototypes -Wno-trigraphs \ -fno-strict-aliasing -fno-common \ -Werror-implicit-function-declaration -Wno-format-security \ -fno-delete-null-pointer-checks -Wdeclaration-after-statement \ diff --git a/chip/lm4/flash.c b/chip/lm4/flash.c index 43f5d5923b..9d7d33f2ed 100644 --- a/chip/lm4/flash.c +++ b/chip/lm4/flash.c @@ -188,7 +188,7 @@ static int find_last_wp_block(void) return -1; } -static int get_wp_range(int *start, int *nblock) +static int get_wp_range(uint32_t *start, uint32_t *nblock) { int start_blk, end_blk; @@ -204,8 +204,8 @@ static int get_wp_range(int *start, int *nblock) /* TODO: Sanity check the shadow value? */ end_blk = find_last_wp_block(); - *nblock = end_blk - start_blk + 1; - *start = start_blk; + *nblock = (uint32_t)(end_blk - start_blk + 1); + *start = (uint32_t)start_blk; return EC_SUCCESS; } @@ -225,9 +225,9 @@ static int set_wp_range(int start, int nblock) return EC_SUCCESS; } -int flash_get_write_protect_range(int *offset, int *size) +int flash_get_write_protect_range(uint32_t *offset, uint32_t *size) { - int start, nblock; + uint32_t start, nblock; int rv; rv = get_wp_range(&start, &nblock); @@ -239,13 +239,12 @@ int flash_get_write_protect_range(int *offset, int *size) return EC_SUCCESS; } -int flash_set_write_protect_range(int offset, int size) +int flash_set_write_protect_range(uint32_t offset, uint32_t size) { int start, nblock; int rv; - if ((offset < 0) || (size < 0) || ((offset + size) > - (LM4_FLASH_FSIZE * FLASH_PROTECT_BYTES))) + if ((offset + size) > (LM4_FLASH_FSIZE * FLASH_PROTECT_BYTES)) return EC_ERROR_UNKNOWN; /* Invalid range */ rv = flash_get_write_protect_status(); @@ -272,7 +271,7 @@ int flash_set_write_protect_range(int offset, int size) int flash_get_write_protect_status(void) { - int start, nblock; + uint32_t start, nblock; int rv; rv = get_wp_range(&start, &nblock); diff --git a/common/flash_commands.c b/common/flash_commands.c index 000be73e20..6da536b40c 100644 --- a/common/flash_commands.c +++ b/common/flash_commands.c @@ -151,7 +151,7 @@ DECLARE_CONSOLE_COMMAND(flashwp, command_flash_wp); static int command_flash_wp_range(int argc, char **argv) { - int offset, size; + uint32_t offset, size; char *endptr; int rv; @@ -167,12 +167,12 @@ static int command_flash_wp_range(int argc, char **argv) LM4_FLASH_FMPPE0, LM4_FLASH_FMPPE1, LM4_FLASH_FMPPE2, LM4_FLASH_FMPPE3); } else { - offset = strtoi(argv[1], &endptr, 0); + offset = (uint32_t)strtoi(argv[1], &endptr, 0); if (*endptr) { uart_printf("Invalid offset \"%s\"\n", argv[1]); return EC_ERROR_UNKNOWN; } - size = strtoi(argv[2], &endptr, 0); + size = (uint32_t)strtoi(argv[2], &endptr, 0); if (*endptr) { uart_printf("Invalid size \"%s\"\n", argv[2]); return EC_ERROR_UNKNOWN; diff --git a/include/flash.h b/include/flash.h index 38944e43cb..8b965d0147 100644 --- a/include/flash.h +++ b/include/flash.h @@ -68,8 +68,8 @@ int flash_erase(int offset, int size); * the write protect range is also locked, and may not be subsequently * altered until after a cold boot with the write protect pin * deasserted. */ -int flash_get_write_protect_range(int *offset, int *size); -int flash_set_write_protect_range(int offset, int size); +int flash_get_write_protect_range(uint32_t *offset, uint32_t *size); +int flash_set_write_protect_range(uint32_t offset, uint32_t size); /* The write protect range has been stored into the chip registers * this boot. The flash is write protected and the range cannot be