* [Qemu-devel] [PATCH] microblaze: fix build on Ubuntu Hardy
@ 2010-04-08 22:22 Thomas Monjalon
2010-04-08 23:48 ` Paul Brook
2010-04-09 6:42 ` [Qemu-devel] " Paolo Bonzini
0 siblings, 2 replies; 6+ messages in thread
From: Thomas Monjalon @ 2010-04-08 22:22 UTC (permalink / raw)
To: qemu-devel
From: Thomas Monjalon <thomas@monjalon.net>
Using GCC-4.2.4-1ubuntu4, there were 3 warnings.
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
microblaze-dis.c | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/microblaze-dis.c b/microblaze-dis.c
index b26572f..698ea7b 100644
--- a/microblaze-dis.c
+++ b/microblaze-dis.c
@@ -789,7 +789,6 @@ read_insn_microblaze (bfd_vma memaddr,
int
print_insn_microblaze (bfd_vma memaddr, struct disassemble_info * info)
{
- fprintf_ftype fprintf = info->fprintf_func;
void * stream = info->stream;
unsigned long inst, prev_inst;
struct op_code_struct * op, *pop;
@@ -826,7 +825,7 @@ print_insn_microblaze (bfd_vma memaddr, struct disassemble_info * info)
prev_insn_vma = curr_insn_vma;
if (op->name == 0) {
- fprintf (stream, ".short 0x%04x", inst);
+ fprintf (stream, ".short 0x%04lx", inst);
}
else
{
@@ -959,7 +958,7 @@ print_insn_microblaze (bfd_vma memaddr, struct disassemble_info * info)
break;
default:
/* if the disassembler lags the instruction set */
- fprintf (stream, "\tundecoded operands, inst is 0x%04x", inst);
+ fprintf (stream, "\tundecoded operands, inst is 0x%04lx", inst);
break;
}
}
--
1.7.0.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] microblaze: fix build on Ubuntu Hardy
2010-04-08 22:22 [Qemu-devel] [PATCH] microblaze: fix build on Ubuntu Hardy Thomas Monjalon
@ 2010-04-08 23:48 ` Paul Brook
2010-04-09 6:42 ` [Qemu-devel] " Paolo Bonzini
1 sibling, 0 replies; 6+ messages in thread
From: Paul Brook @ 2010-04-08 23:48 UTC (permalink / raw)
To: qemu-devel
> {
> - fprintf_ftype fprintf = info->fprintf_func;
> void * stream = info->stream;
I'm pretty sure this is not the correct fix.
"Fix a warning" is not sufficient justification for any change. We need to
understand what was wrong with the old code, and why the new code is correct.
Paul
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] Re: [PATCH] microblaze: fix build on Ubuntu Hardy
2010-04-08 22:22 [Qemu-devel] [PATCH] microblaze: fix build on Ubuntu Hardy Thomas Monjalon
2010-04-08 23:48 ` Paul Brook
@ 2010-04-09 6:42 ` Paolo Bonzini
2010-04-09 15:31 ` Thomas Monjalon
2010-04-09 16:21 ` [Qemu-devel] " Thomas Monjalon
1 sibling, 2 replies; 6+ messages in thread
From: Paolo Bonzini @ 2010-04-09 6:42 UTC (permalink / raw)
To: Thomas Monjalon; +Cc: qemu-devel
On 04/09/2010 12:22 AM, Thomas Monjalon wrote:
> From: Thomas Monjalon<thomas@monjalon.net>
>
> Using GCC-4.2.4-1ubuntu4, there were 3 warnings.
The last two are correct, but what was the first error? If it was a
shadowed declaration as it seems to be, the solution is to
s/fprintf/fprintf_func/ throughout print_insn_microblaze (for example).
Paolo
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] Re: [PATCH] microblaze: fix build on Ubuntu Hardy
2010-04-09 6:42 ` [Qemu-devel] " Paolo Bonzini
@ 2010-04-09 15:31 ` Thomas Monjalon
2010-04-09 16:27 ` Paolo Bonzini
2010-04-09 16:21 ` [Qemu-devel] " Thomas Monjalon
1 sibling, 1 reply; 6+ messages in thread
From: Thomas Monjalon @ 2010-04-09 15:31 UTC (permalink / raw)
To: qemu-devel; +Cc: Paolo Bonzini, Paul Brook
Paolo Bonzini wrote:
> On 04/09/2010 12:22 AM, Thomas Monjalon wrote:
> > Using GCC-4.2.4-1ubuntu4, there were 3 warnings.
>
> The last two are correct, but what was the first error? If it was a
> shadowed declaration as it seems to be, the solution is to
> s/fprintf/fprintf_func/ throughout print_insn_microblaze (for example).
Paul, Paolo, you're right.
Nice review !
The error message is:
microblaze-dis.c:792: warning: unused variable 'fprintf'
But the error message is bogus. It is a shadowed declaration.
By adding -Wshadow, the message is:
microblaze-dis.c:792: warning: declaration of 'fprintf' shadows a global
declaration
/usr/include/stdio.h:332: warning: shadowed declaration is here
microblaze-dis.c:792: warning: unused variable 'fprintf'
Since the function fprintf is used, removing this declaration is a wrong fix.
I am going to send a new patch which renames the variable to fprintf_func as
Paolo suggests.
Thanks
--
Thomas
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH] microblaze: fix build on Ubuntu Hardy
2010-04-09 6:42 ` [Qemu-devel] " Paolo Bonzini
2010-04-09 15:31 ` Thomas Monjalon
@ 2010-04-09 16:21 ` Thomas Monjalon
1 sibling, 0 replies; 6+ messages in thread
From: Thomas Monjalon @ 2010-04-09 16:21 UTC (permalink / raw)
To: qemu-devel; +Cc: Paolo Bonzini, Paul Brook
From: Thomas Monjalon <thomas@monjalon.net>
Using GCC-4.2.4-1ubuntu4, there were 3 warnings:
microblaze-dis.c:829: warning: format '%04x' expects type 'unsigned int', but argument 4 has type 'long unsigned int'
microblaze-dis.c:962: warning: format '%04x' expects type 'unsigned int', but argument 4 has type 'long unsigned int'
microblaze-dis.c:792: warning: unused variable 'fprintf'
The third warning is a problem of shadowed declaration. It is fixed by renaming the variable.
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
microblaze-dis.c | 62 +++++++++++++++++++++++++++---------------------------
1 files changed, 31 insertions(+), 31 deletions(-)
diff --git a/microblaze-dis.c b/microblaze-dis.c
index b26572f..7694a43 100644
--- a/microblaze-dis.c
+++ b/microblaze-dis.c
@@ -789,7 +789,7 @@ read_insn_microblaze (bfd_vma memaddr,
int
print_insn_microblaze (bfd_vma memaddr, struct disassemble_info * info)
{
- fprintf_ftype fprintf = info->fprintf_func;
+ fprintf_ftype fprintf_func = info->fprintf_func;
void * stream = info->stream;
unsigned long inst, prev_inst;
struct op_code_struct * op, *pop;
@@ -826,19 +826,19 @@ print_insn_microblaze (bfd_vma memaddr, struct disassemble_info * info)
prev_insn_vma = curr_insn_vma;
if (op->name == 0) {
- fprintf (stream, ".short 0x%04x", inst);
+ fprintf_func (stream, ".short 0x%04lx", inst);
}
else
{
- fprintf (stream, "%s", op->name);
+ fprintf_func (stream, "%s", op->name);
switch (op->inst_type)
{
case INST_TYPE_RD_R1_R2:
- fprintf(stream, "\t%s, %s, %s", get_field_rd(inst), get_field_r1(inst), get_field_r2(inst));
+ fprintf_func(stream, "\t%s, %s, %s", get_field_rd(inst), get_field_r1(inst), get_field_r2(inst));
break;
case INST_TYPE_RD_R1_IMM:
- fprintf(stream, "\t%s, %s, %s", get_field_rd(inst), get_field_r1(inst), get_field_imm(inst));
+ fprintf_func(stream, "\t%s, %s, %s", get_field_rd(inst), get_field_r1(inst), get_field_imm(inst));
if (info->print_address_func && get_int_field_r1(inst) == 0 && info->symbol_at_address_func) {
if (immfound)
immval |= (get_int_field_imm(inst) & 0x0000ffff);
@@ -848,34 +848,34 @@ print_insn_microblaze (bfd_vma memaddr, struct disassemble_info * info)
immval |= 0xFFFF0000;
}
if (immval > 0 && info->symbol_at_address_func(immval, info)) {
- fprintf (stream, "\t// ");
+ fprintf_func (stream, "\t// ");
info->print_address_func (immval, info);
}
}
break;
case INST_TYPE_RD_R1_IMM5:
- fprintf(stream, "\t%s, %s, %s", get_field_rd(inst), get_field_r1(inst), get_field_imm5(inst));
+ fprintf_func(stream, "\t%s, %s, %s", get_field_rd(inst), get_field_r1(inst), get_field_imm5(inst));
break;
case INST_TYPE_RD_RFSL:
- fprintf(stream, "\t%s, %s", get_field_rd(inst), get_field_rfsl(inst));
+ fprintf_func(stream, "\t%s, %s", get_field_rd(inst), get_field_rfsl(inst));
break;
case INST_TYPE_R1_RFSL:
- fprintf(stream, "\t%s, %s", get_field_r1(inst), get_field_rfsl(inst));
+ fprintf_func(stream, "\t%s, %s", get_field_r1(inst), get_field_rfsl(inst));
break;
case INST_TYPE_RD_SPECIAL:
- fprintf(stream, "\t%s, %s", get_field_rd(inst), get_field_special(inst, op));
+ fprintf_func(stream, "\t%s, %s", get_field_rd(inst), get_field_special(inst, op));
break;
case INST_TYPE_SPECIAL_R1:
- fprintf(stream, "\t%s, %s", get_field_special(inst, op), get_field_r1(inst));
+ fprintf_func(stream, "\t%s, %s", get_field_special(inst, op), get_field_r1(inst));
break;
case INST_TYPE_RD_R1:
- fprintf(stream, "\t%s, %s", get_field_rd(inst), get_field_r1(inst));
+ fprintf_func(stream, "\t%s, %s", get_field_rd(inst), get_field_r1(inst));
break;
case INST_TYPE_R1_R2:
- fprintf(stream, "\t%s, %s", get_field_r1(inst), get_field_r2(inst));
+ fprintf_func(stream, "\t%s, %s", get_field_r1(inst), get_field_r2(inst));
break;
case INST_TYPE_R1_IMM:
- fprintf(stream, "\t%s, %s", get_field_r1(inst), get_field_imm(inst));
+ fprintf_func(stream, "\t%s, %s", get_field_r1(inst), get_field_imm(inst));
/* The non-pc relative instructions are returns, which shouldn't
have a label printed */
if (info->print_address_func && op->inst_offset_type == INST_PC_OFFSET && info->symbol_at_address_func) {
@@ -888,16 +888,16 @@ print_insn_microblaze (bfd_vma memaddr, struct disassemble_info * info)
}
immval += memaddr;
if (immval > 0 && info->symbol_at_address_func(immval, info)) {
- fprintf (stream, "\t// ");
+ fprintf_func (stream, "\t// ");
info->print_address_func (immval, info);
} else {
- fprintf (stream, "\t\t// ");
- fprintf (stream, "%x", immval);
+ fprintf_func (stream, "\t\t// ");
+ fprintf_func (stream, "%x", immval);
}
}
break;
case INST_TYPE_RD_IMM:
- fprintf(stream, "\t%s, %s", get_field_rd(inst), get_field_imm(inst));
+ fprintf_func(stream, "\t%s, %s", get_field_rd(inst), get_field_imm(inst));
if (info->print_address_func && info->symbol_at_address_func) {
if (immfound)
immval |= (get_int_field_imm(inst) & 0x0000ffff);
@@ -909,13 +909,13 @@ print_insn_microblaze (bfd_vma memaddr, struct disassemble_info * info)
if (op->inst_offset_type == INST_PC_OFFSET)
immval += (int) memaddr;
if (info->symbol_at_address_func(immval, info)) {
- fprintf (stream, "\t// ");
+ fprintf_func (stream, "\t// ");
info->print_address_func (immval, info);
}
}
break;
case INST_TYPE_IMM:
- fprintf(stream, "\t%s", get_field_imm(inst));
+ fprintf_func(stream, "\t%s", get_field_imm(inst));
if (info->print_address_func && info->symbol_at_address_func && op->instr != imm) {
if (immfound)
immval |= (get_int_field_imm(inst) & 0x0000ffff);
@@ -927,39 +927,39 @@ print_insn_microblaze (bfd_vma memaddr, struct disassemble_info * info)
if (op->inst_offset_type == INST_PC_OFFSET)
immval += (int) memaddr;
if (immval > 0 && info->symbol_at_address_func(immval, info)) {
- fprintf (stream, "\t// ");
+ fprintf_func (stream, "\t// ");
info->print_address_func (immval, info);
} else if (op->inst_offset_type == INST_PC_OFFSET) {
- fprintf (stream, "\t\t// ");
- fprintf (stream, "%x", immval);
+ fprintf_func (stream, "\t\t// ");
+ fprintf_func (stream, "%x", immval);
}
}
break;
case INST_TYPE_RD_R2:
- fprintf(stream, "\t%s, %s", get_field_rd(inst), get_field_r2(inst));
+ fprintf_func(stream, "\t%s, %s", get_field_rd(inst), get_field_r2(inst));
break;
case INST_TYPE_R2:
- fprintf(stream, "\t%s", get_field_r2(inst));
+ fprintf_func(stream, "\t%s", get_field_r2(inst));
break;
case INST_TYPE_R1:
- fprintf(stream, "\t%s", get_field_r1(inst));
+ fprintf_func(stream, "\t%s", get_field_r1(inst));
break;
case INST_TYPE_RD_R1_SPECIAL:
- fprintf(stream, "\t%s, %s", get_field_rd(inst), get_field_r2(inst));
+ fprintf_func(stream, "\t%s, %s", get_field_rd(inst), get_field_r2(inst));
break;
case INST_TYPE_RD_IMM15:
- fprintf(stream, "\t%s, %s", get_field_rd(inst), get_field_imm15(inst));
+ fprintf_func(stream, "\t%s, %s", get_field_rd(inst), get_field_imm15(inst));
break;
/* For tuqula instruction */
case INST_TYPE_RD:
- fprintf(stream, "\t%s", get_field_rd(inst));
+ fprintf_func(stream, "\t%s", get_field_rd(inst));
break;
case INST_TYPE_RFSL:
- fprintf(stream, "\t%s", get_field_rfsl(inst));
+ fprintf_func(stream, "\t%s", get_field_rfsl(inst));
break;
default:
/* if the disassembler lags the instruction set */
- fprintf (stream, "\tundecoded operands, inst is 0x%04x", inst);
+ fprintf_func (stream, "\tundecoded operands, inst is 0x%04lx", inst);
break;
}
}
--
1.7.0.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Qemu-devel] Re: [PATCH] microblaze: fix build on Ubuntu Hardy
2010-04-09 15:31 ` Thomas Monjalon
@ 2010-04-09 16:27 ` Paolo Bonzini
0 siblings, 0 replies; 6+ messages in thread
From: Paolo Bonzini @ 2010-04-09 16:27 UTC (permalink / raw)
To: Thomas Monjalon; +Cc: qemu-devel, Paul Brook
On 04/09/2010 05:31 PM, Thomas Monjalon wrote:
> Paolo Bonzini wrote:
>> On 04/09/2010 12:22 AM, Thomas Monjalon wrote:
>>> Using GCC-4.2.4-1ubuntu4, there were 3 warnings.
>>
>> The last two are correct, but what was the first error? If it was a
>> shadowed declaration as it seems to be, the solution is to
>> s/fprintf/fprintf_func/ throughout print_insn_microblaze (for example).
>
> Paul, Paolo, you're right.
> Nice review !
>
> The error message is:
>
> microblaze-dis.c:792: warning: unused variable 'fprintf'
>
> But the error message is bogus. It is a shadowed declaration.
... which is hidden because FORTIFY_SOURCE changes fprintf to
fprintf_chk. So you're fixing a bug too! :-)
Paolo
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-04-09 16:27 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-08 22:22 [Qemu-devel] [PATCH] microblaze: fix build on Ubuntu Hardy Thomas Monjalon
2010-04-08 23:48 ` Paul Brook
2010-04-09 6:42 ` [Qemu-devel] " Paolo Bonzini
2010-04-09 15:31 ` Thomas Monjalon
2010-04-09 16:27 ` Paolo Bonzini
2010-04-09 16:21 ` [Qemu-devel] " Thomas Monjalon
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).