[Skiboot] [PATCH 1/3] flash: Fix uninitialised variable warning
Joel Stanley
joel at jms.id.au
Thu May 7 16:41:23 AEST 2015
core/flash.c:271:14: error: variable 'flash' is used uninitialized whenever 'for' loop exits because its condition is false
[-Werror,-Wsometimes-uninitialized]
for (i = 0; i < ARRAY_SIZE(flashes); i++) {
^~~~~~~~~~~~~~~~~~~~~~~
core/flash.c:284:7: note: uninitialized use occurs here
if (!flash) {
^~~~~
core/flash.c:271:14: note: remove the condition if it is always true
for (i = 0; i < ARRAY_SIZE(flashes); i++) {
^~~~~~~~~~~~~~~~~~~~~~~
core/flash.c:257:21: note: initialize the variable 'flash' to silence this warning
struct flash *flash;
^
= NULL
Signed-off-by: Joel Stanley <joel at jms.id.au>
---
core/flash.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/core/flash.c b/core/flash.c
index 7d32c8d..3c14bf2 100644
--- a/core/flash.c
+++ b/core/flash.c
@@ -254,7 +254,7 @@ int flash_register(struct flash_chip *chip, bool is_system_flash)
uint32_t size, block_size;
struct ffs_handle *ffs;
struct dt_node *node;
- struct flash *flash;
+ struct flash *flash = NULL;
const char *name;
unsigned int i;
int rc;
--
2.1.4
More information about the Skiboot
mailing list