[U-Boot] [PATCH] arm, ubifs: fix gcc5.x compiler warning

Heiko Schocher hs at denx.de
Mon Nov 30 08:47:42 CET 2015


compiling U-Boot for openrd_base_defconfig with
gcc 5.x shows the following warning:

  CC      fs/ubifs/super.o
In file included from fs/ubifs/ubifs.h:35:0,
                 from fs/ubifs/super.c:37:
fs/ubifs/super.c: In function 'atomic_inc':
./arch/arm/include/asm/atomic.h:55:2: warning: 'flags' is used uninitialized in this function [-Wuninitialized]
  local_irq_save(flags);
  ^
fs/ubifs/super.c: In function 'atomic_dec':
./arch/arm/include/asm/atomic.h:64:2: warning: 'flags' is used uninitialized in this function [-Wuninitialized]
  local_irq_save(flags);
  ^
  CC      fs/ubifs/sb.o
[...]
  CC      fs/ubifs/lpt.o
In file included from include/linux/bitops.h:123:0,
                 from include/common.h:20,
                 from include/ubi_uboot.h:17,
                 from fs/ubifs/ubifs.h:37,
                 from fs/ubifs/lpt.c:35:
fs/ubifs/lpt.c: In function 'test_and_set_bit':
./arch/arm/include/asm/bitops.h:57:2: warning: 'flags' is used uninitialized in this function [-Wuninitialized]
  local_irq_save(flags);
  ^
  CC      fs/ubifs/lpt_commit.o
In file included from include/linux/bitops.h:123:0,
                 from include/common.h:20,
                 from include/ubi_uboot.h:17,
                 from fs/ubifs/ubifs.h:37,
                 from fs/ubifs/lpt_commit.c:26:
fs/ubifs/lpt_commit.c: In function 'test_and_set_bit':
./arch/arm/include/asm/bitops.h:57:2: warning: 'flags' is used uninitialized in this function [-Wuninitialized]
  local_irq_save(flags);
  ^
  CC      fs/ubifs/scan.o
  CC      fs/ubifs/lprops.o
  CC      fs/ubifs/tnc.o
In file included from include/linux/bitops.h:123:0,
                 from include/common.h:20,
                 from include/ubi_uboot.h:17,
                 from fs/ubifs/ubifs.h:37,
                 from fs/ubifs/tnc.c:30:
fs/ubifs/tnc.c: In function 'test_and_set_bit':
./arch/arm/include/asm/bitops.h:57:2: warning: 'flags' is used uninitialized in this function [-Wuninitialized]
  local_irq_save(flags);
  ^
  CC      fs/ubifs/tnc_misc.o

Fix it.

Signed-off-by: Heiko Schocher <hs at denx.de>
---

 arch/arm/include/asm/atomic.h | 14 +++++++-------
 arch/arm/include/asm/bitops.h |  4 ++--
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/arch/arm/include/asm/atomic.h b/arch/arm/include/asm/atomic.h
index 34c07fe..9b79506 100644
--- a/arch/arm/include/asm/atomic.h
+++ b/arch/arm/include/asm/atomic.h
@@ -32,7 +32,7 @@ typedef struct { volatile int counter; } atomic_t;
 
 static inline void atomic_add(int i, volatile atomic_t *v)
 {
-	unsigned long flags;
+	unsigned long flags = 0;
 
 	local_irq_save(flags);
 	v->counter += i;
@@ -41,7 +41,7 @@ static inline void atomic_add(int i, volatile atomic_t *v)
 
 static inline void atomic_sub(int i, volatile atomic_t *v)
 {
-	unsigned long flags;
+	unsigned long flags = 0;
 
 	local_irq_save(flags);
 	v->counter -= i;
@@ -50,7 +50,7 @@ static inline void atomic_sub(int i, volatile atomic_t *v)
 
 static inline void atomic_inc(volatile atomic_t *v)
 {
-	unsigned long flags;
+	unsigned long flags = 0;
 
 	local_irq_save(flags);
 	v->counter += 1;
@@ -59,7 +59,7 @@ static inline void atomic_inc(volatile atomic_t *v)
 
 static inline void atomic_dec(volatile atomic_t *v)
 {
-	unsigned long flags;
+	unsigned long flags = 0;
 
 	local_irq_save(flags);
 	v->counter -= 1;
@@ -68,7 +68,7 @@ static inline void atomic_dec(volatile atomic_t *v)
 
 static inline int atomic_dec_and_test(volatile atomic_t *v)
 {
-	unsigned long flags;
+	unsigned long flags = 0;
 	int val;
 
 	local_irq_save(flags);
@@ -81,7 +81,7 @@ static inline int atomic_dec_and_test(volatile atomic_t *v)
 
 static inline int atomic_add_negative(int i, volatile atomic_t *v)
 {
-	unsigned long flags;
+	unsigned long flags = 0;
 	int val;
 
 	local_irq_save(flags);
@@ -94,7 +94,7 @@ static inline int atomic_add_negative(int i, volatile atomic_t *v)
 
 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
 {
-	unsigned long flags;
+	unsigned long flags = 0;
 
 	local_irq_save(flags);
 	*addr &= ~mask;
diff --git a/arch/arm/include/asm/bitops.h b/arch/arm/include/asm/bitops.h
index d479a38..f33efeb 100644
--- a/arch/arm/include/asm/bitops.h
+++ b/arch/arm/include/asm/bitops.h
@@ -51,7 +51,7 @@ static inline int __test_and_set_bit(int nr, volatile void *addr)
 
 static inline int test_and_set_bit(int nr, volatile void * addr)
 {
-	unsigned long flags;
+	unsigned long flags = 0;
 	int out;
 
 	local_irq_save(flags);
@@ -73,7 +73,7 @@ static inline int __test_and_clear_bit(int nr, volatile void *addr)
 
 static inline int test_and_clear_bit(int nr, volatile void * addr)
 {
-	unsigned long flags;
+	unsigned long flags = 0;
 	int out;
 
 	local_irq_save(flags);
-- 
2.1.0



More information about the U-Boot mailing list