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
Pierre Muller wrote:
>
> 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.
Does that still work at -O0?
> 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...
> 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]);
Yeh, that looks good to me. The compiler's presumably worrying about some
kind of potential for a format-string vulnerability. Although the strings
pointed to by the code[] array are const, the pointers aren't, so effectively
the strings could in theory be manipulated. Replacing the decl with "const
char * const code[]" might fix it too, but who knows maybe some day
somebody'll decide to generate the whole array algorithmically at runtime, so
best to code defensively.
> Could you check these in under the obvious rule?
I'd prefer to ask approval from a formal maintainer for anything much more
complex than "pruntf"->"printf" sort of typo fixes if you don't mind. PING
maintainers?
cheers,
DaveK