This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: GDB multi-build failure in lm32-opc.c file
The easiest was finally to add an
if (num_macros >= 1)
before the memset call.
When num_macros is zero, the call gets
optimized out, and thus no warning is issued.
It turned out to be necessary for 3 files.
I had one more warning in tic54x-dis.c file
about a call to sprintf with only two arguments.
Not sure the fix is the right one there...
This is the simplest changes I found to be able to complete
a multi-build on i386 Ubuntu.
Could you check these in under the obvious rule?
Pierre Muller
GDB pascal language maintainer.
Index: opcodes/lm32-opc.c
===================================================================
RCS file: /cvs/src/src/opcodes/lm32-opc.c,v
retrieving revision 1.1
diff -u -p -r1.1 lm32-opc.c
--- opcodes/lm32-opc.c 23 Dec 2008 19:10:25 -0000 1.1
+++ opcodes/lm32-opc.c 14 Feb 2009 16:26:20 -0000
@@ -844,7 +844,8 @@ lm32_cgen_init_opcode_table (CGEN_CPU_DE
const CGEN_OPCODE *oc = & lm32_cgen_macro_insn_opcode_table[0];
CGEN_INSN *insns = xmalloc (num_macros * sizeof (CGEN_INSN));
- memset (insns, 0, num_macros * sizeof (CGEN_INSN));
+ if (num_macros >= 1)
+ memset (insns, 0, num_macros * sizeof (CGEN_INSN));
for (i = 0; i < num_macros; ++i)
{
insns[i].base = &ib[i];
Index: opcodes/mt-opc.c
===================================================================
RCS file: /cvs/src/src/opcodes/mt-opc.c,v
retrieving revision 1.3
diff -u -p -r1.3 mt-opc.c
--- opcodes/mt-opc.c 5 Jul 2007 09:49:02 -0000 1.3
+++ opcodes/mt-opc.c 14 Feb 2009 16:26:20 -0000
@@ -914,8 +914,8 @@ mt_cgen_init_opcode_table (CGEN_CPU_DESC
const CGEN_IBASE *ib = & mt_cgen_macro_insn_table[0];
const CGEN_OPCODE *oc = & mt_cgen_macro_insn_opcode_table[0];
CGEN_INSN *insns = xmalloc (num_macros * sizeof (CGEN_INSN));
-
- memset (insns, 0, num_macros * sizeof (CGEN_INSN));
+ if (num_macros >= 1)
+ memset (insns, 0, num_macros * sizeof (CGEN_INSN));
for (i = 0; i < num_macros; ++i)
{
insns[i].base = &ib[i];
Index: opcodes/tic54x-dis.c
===================================================================
RCS file: /cvs/src/src/opcodes/tic54x-dis.c,v
retrieving revision 1.10
diff -u -p -r1.10 tic54x-dis.c
--- opcodes/tic54x-dis.c 5 Jul 2007 09:49:02 -0000 1.10
+++ opcodes/tic54x-dis.c 14 Feb 2009 16:26:21 -0000
@@ -380,7 +380,7 @@ print_instruction (info, memaddr, opcode
case OP_CC3:
{
const char *code[] = { "eq", "lt", "gt", "neq" };
- sprintf (operand[i], code[CC3 (opcode)]);
+ sprintf (operand[i], "%s", code[CC3 (opcode)]);
info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
break;
}
Index: opcodes/xc16x-opc.c
===================================================================
RCS file: /cvs/src/src/opcodes/xc16x-opc.c,v
retrieving revision 1.2
diff -u -p -r1.2 xc16x-opc.c
--- opcodes/xc16x-opc.c 5 Jul 2007 09:49:02 -0000 1.2
+++ opcodes/xc16x-opc.c 14 Feb 2009 16:26:22 -0000
@@ -3041,7 +3041,8 @@ xc16x_cgen_init_opcode_table (CGEN_CPU_D
const CGEN_OPCODE *oc = & xc16x_cgen_macro_insn_opcode_table[0];
CGEN_INSN *insns = xmalloc (num_macros * sizeof (CGEN_INSN));
- memset (insns, 0, num_macros * sizeof (CGEN_INSN));
+ if (num_macros >= 1)
+ memset (insns, 0, num_macros * sizeof (CGEN_INSN));
for (i = 0; i < num_macros; ++i)
{
insns[i].base = &ib[i];
Pierre Muller wrote:
lm32-opc.o
cc1: warnings being treated as errors
In function ?memset?,
inlined from ?lm32_cgen_init_opcode_table? at
../../src/opcodes/lm32-opc.c:847:
/usr/include/bits/string3.h:82: error: call to ?__warn_memset_zero_len?
declared with attribute warning: memset used with constant zero length
parameter; this could be due to transposed parameters
make[3]: *** [lm32-opc.lo] Error 1
Seems to suggest that CGEN_INSN type is
still opaque and thus of unknown size...
Nah, otherwise you'd get an error about trying to use an incomplete
definition; sizeof() wouldn't just return zero. So looking at that line in
lm32-opc.c,
837 void
838 lm32_cgen_init_opcode_table (CGEN_CPU_DESC cd)
839 {
840 int i;
841 int num_macros = (sizeof (lm32_cgen_macro_insn_table) /
842 sizeof (lm32_cgen_macro_insn_table[0]));
843 const CGEN_IBASE *ib = & lm32_cgen_macro_insn_table[0];
844 const CGEN_OPCODE *oc = & lm32_cgen_macro_insn_opcode_table[0];
845 CGEN_INSN *insns = xmalloc (num_macros * sizeof (CGEN_INSN));
846
847 memset (insns, 0, num_macros * sizeof (CGEN_INSN));
it must be the case that num_macros is zero. And indeed:
742 static const CGEN_IBASE lm32_cgen_macro_insn_table[] =
743 {
744 };
I would guess something went wrong when it got autogenerated, or
conceivably
it's supposed to be empty but the warning on zero-size memset is
new? LM32 is
a very recent port, only added in December. As a workaround, you could
probably add a single dummy entry just to get it to compile, as long as you
don't try debugging any LM32 executables you should be ok. Something as
simple as an empty default initialiser:
742 static const CGEN_IBASE lm32_cgen_macro_insn_table[] =
743 {
{ }
744 };
ought to do the trick.
cheers,
DaveK