* [PATCH] ARM: Fix build warning in do_alignment.
@ 2012-09-04 8:01 Chanho Min
0 siblings, 0 replies; 4+ messages in thread
From: Chanho Min @ 2012-09-04 8:01 UTC (permalink / raw)
To: linux-arm-kernel
Fix the following build warning:
arch/arm/mm/alignment.c: In function 'do_alignment':
arch/arm/mm/alignment.c:327:15: warning: 'offset.un' may be used uninitialized in this function [-Wuninitialized]
arch/arm/mm/alignment.c:749:21: note: 'offset.un' was declared here
Signed-off-by: Chanho Min <chanho.min@lge.com>
---
arch/arm/mm/alignment.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c
index 9107231..f83b38c 100644
--- a/arch/arm/mm/alignment.c
+++ b/arch/arm/mm/alignment.c
@@ -746,7 +746,7 @@ do_alignment_t32_to_handler(unsigned long *pinstr, struct pt_regs *regs,
static int
do_alignment(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
{
- union offset_union offset;
+ union offset_union offset = {0};
unsigned long instr = 0, instrptr;
int (*handler)(unsigned long addr, unsigned long instr, struct pt_regs *regs);
unsigned int type;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] ARM: Fix build warning in do_alignment.
@ 2012-09-10 3:25 Chanho Min
2012-09-10 8:40 ` Russell King - ARM Linux
0 siblings, 1 reply; 4+ messages in thread
From: Chanho Min @ 2012-09-10 3:25 UTC (permalink / raw)
To: linux-arm-kernel
Fix the following build warning:
arch/arm/mm/alignment.c: In function 'do_alignment':
arch/arm/mm/alignment.c:327:15: warning: 'offset.un' may be used
uninitialized in this function [-Wuninitialized]
arch/arm/mm/alignment.c:749:21: note: 'offset.un' was declared here
Signed-off-by: Chanho Min <chanho.min@lge.com>
---
arch/arm/mm/alignment.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c
index 9107231..f83b38c 100644
--- a/arch/arm/mm/alignment.c
+++ b/arch/arm/mm/alignment.c
@@ -746,7 +746,7 @@ do_alignment_t32_to_handler(unsigned long *pinstr,
struct pt_regs *regs,
static int
do_alignment(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
{
- union offset_union offset;
+ union offset_union offset = {0};
unsigned long instr = 0, instrptr;
int (*handler)(unsigned long addr, unsigned long instr, struct pt_regs *regs);
unsigned int type;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] ARM: Fix build warning in do_alignment.
2012-09-10 3:25 Chanho Min
@ 2012-09-10 8:40 ` Russell King - ARM Linux
2012-09-11 1:53 ` Chanho Min
0 siblings, 1 reply; 4+ messages in thread
From: Russell King - ARM Linux @ 2012-09-10 8:40 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, Sep 10, 2012 at 12:25:15PM +0900, Chanho Min wrote:
> Fix the following build warning:
>
> arch/arm/mm/alignment.c: In function 'do_alignment':
> arch/arm/mm/alignment.c:327:15: warning: 'offset.un' may be used
> uninitialized in this function [-Wuninitialized]
> arch/arm/mm/alignment.c:749:21: note: 'offset.un' was declared here
>
> Signed-off-by: Chanho Min <chanho.min@lge.com>
The compiler is being silly - notice that it is saying "may" not "is".
In this case, it will not be uninitialized prior to use.
What it's caused by is do_alignment_t32_to_handler(), and its assignment
through a pointer of this variable. You can see that this is the cause
because the patch below fixes the warning.
It's all about whether gcc can prove that the variable is or is not
assigned. It has one warning for the 'provably not assigned' case, and
another for the 'can't prove that it is always assigned' case.
Anyway, normally we don't fix warnings where the compiler is wrong (but
we encourage the compiler guys to fix the compiler instead.)
arch/arm/mm/alignment.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c
index 6d6790e..5ce7733 100644
--- a/arch/arm/mm/alignment.c
+++ b/arch/arm/mm/alignment.c
@@ -699,7 +699,6 @@ do_alignment_t32_to_handler(unsigned long *pinstr, struct pt_regs *regs,
unsigned long instr = *pinstr;
u16 tinst1 = (instr >> 16) & 0xffff;
u16 tinst2 = instr & 0xffff;
- poffset->un = 0;
switch (tinst1 & 0xffe0) {
/* A6.3.5 Load/Store multiple */
@@ -854,9 +853,10 @@ do_alignment(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
break;
case 0x08000000: /* ldm or stm, or thumb-2 32bit instruction */
- if (thumb2_32b)
+ if (thumb2_32b) {
+ offset.un = 0;
handler = do_alignment_t32_to_handler(&instr, regs, &offset);
- else
+ } else
handler = do_alignment_ldmstm;
break;
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] ARM: Fix build warning in do_alignment.
2012-09-10 8:40 ` Russell King - ARM Linux
@ 2012-09-11 1:53 ` Chanho Min
0 siblings, 0 replies; 4+ messages in thread
From: Chanho Min @ 2012-09-11 1:53 UTC (permalink / raw)
To: linux-arm-kernel
> What it's caused by is do_alignment_t32_to_handler(), and its assignment
> through a pointer of this variable. You can see that this is the cause
> because the patch below fixes the warning.
We couldn't fix the warning with your patch. the patch below fixes it instead.
IMHO, gcc can't seems to know that do_alignment_ldmstm never returns TYPE_LDST.
So It just warn that do_alignment_finish_ldst is called with the
uninitialized value.
I know gcc is not smart enough to see all the reasons. So, It is optional.
Also, I'm not sure these optional warning should be fixed.
Anyway, this is the last build warning in our whole source when using gcc-4.6.3
Thanks
Chanho,
diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c
index 9107231..978db1f 100644
--- a/arch/arm/mm/alignment.c
+++ b/arch/arm/mm/alignment.c
@@ -856,8 +856,10 @@ do_alignment(unsigned long addr, unsigned int
fsr, struct pt_regs *regs)
case 0x08000000: /* ldm or stm, or thumb-2 32bit instruction */
if (thumb2_32b)
handler = do_alignment_t32_to_handler(&instr, regs, &offset);
- else
+ else {
+ offset.un = 0;
handler = do_alignment_ldmstm;
+ }
break;
default:
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-09-11 1:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-04 8:01 [PATCH] ARM: Fix build warning in do_alignment Chanho Min
-- strict thread matches above, loose matches on Subject: below --
2012-09-10 3:25 Chanho Min
2012-09-10 8:40 ` Russell King - ARM Linux
2012-09-11 1:53 ` Chanho Min
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).