[PATCH] Fix printf hex mixed formats
Andrew Burgess
andrew.burgess@embecosm.com
Thu Oct 22 12:36:25 GMT 2020
h65;5803;1c* Dr. David Alan Gilbert via Binutils <binutils@sourceware.org> [2020-10-20 16:56:16 +0100]:
> The regexp '0x%[0-9]*l*[ud]' found me a bunch of printf format
> strings which printed 0x but then formatted a decimal number.
>
> Please review and merge,
>
> Dave
>
> bfd/ChangeLog:
>
> 2020-10-20 Dr. David Alan Gilbert <dgilbert@redhat.com>
>
> * po/es.po: Fix printf format
>
> binutils/Changelog:
>
> 2020-10-20 Dr. David Alan Gilbert <dgilbert@redhat.com>
>
> * windmc.c: Fix printf format
>
> gas/ChangeLog:
>
> 2020-10-20 Dr. David Alan Gilbert <dgilbert@redhat.com>
>
> * config/tc-arc.c: Fix printf format
>
> opcodes/ChangeLog:
>
> 2020-10-20 Dr. David Alan Gilbert <dgilbert@redhat.com>
>
> * po/es.po: Fix printf format
>
> sim/ChangeLog:
>
> 2020-10-20 Dr. David Alan Gilbert <dgilbert@redhat.com>
>
> * arm/armos.c: Fix printf format
> * ppc/emul_netbsd.c: Fix printf format
David,
Thanks for doing this. Changes to sim/ should be posted to the
gdb-patches@sourceware.org mailing list for review.
For future changes it's worth noting that (sadly) the sim/ directory
has many ChangeLog files split by target, so these entries should be
in sim/arm/ChangeLog and sim/ppc/ChangeLog. I'll fix up these
entries.
Thanks,
Andrew
> --
> Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
> From dff64a59438773d20ab0c589056b91cee623506a Mon Sep 17 00:00:00 2001
> From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> Date: Mon, 19 Oct 2020 18:49:18 +0100
> Subject: [PATCH] Fix printf hex mixed formats
>
> There are a bunch of a different mismatches where printf formaters
> use '0x' before a '%d' or '%u' qualifier.
>
> For po's fix them to match the msgid strings.
>
> tc-arc.c: A 0x%d for a pr_debug length, switch to %d since it feels right
> for a length.
>
> armos.c: This had the weird typo '0x%ulx', flip to 0x%lx with the same
> cast as SWIwrite.
>
> emul_netbsd.c: This was using 0x%ld for signal bitmasks; 0x%lx feels
> right.
>
> windmc.c: This had a bunch of format strings of the form '0x%lu' that
> I think should all be %lu.
>
> These were found with the regexp '0x%[0-9]*l*[ud]'
> ---
> bfd/po/es.po | 2 +-
> binutils/windmc.c | 8 ++++----
> gas/config/tc-arc.c | 2 +-
> opcodes/po/es.po | 2 +-
> sim/arm/armos.c | 4 ++--
> sim/ppc/emul_netbsd.c | 2 +-
> 6 files changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/bfd/po/es.po b/bfd/po/es.po
> index 1fcfd01ac2..5532b5de65 100644
> --- a/bfd/po/es.po
> +++ b/bfd/po/es.po
> @@ -567,7 +567,7 @@ msgstr "%B: aviso: lectura de segmento de números de línea fallada"
> #: coffcode.h:4641 coffcode.h:4655
> #, c-format
> msgid "%B: warning: illegal symbol index 0x%lx in line number entry %d"
> -msgstr "%B: aviso: índice simbólico 0x%ld ilegal en las entradas del número de línea %d"
> +msgstr "%B: aviso: índice simbólico 0x%lx ilegal en las entradas del número de línea %d"
>
> #: coffcode.h:4669
> #, c-format
> diff --git a/binutils/windmc.c b/binutils/windmc.c
> index 3b9d2aa48f..97a43c1143 100644
> --- a/binutils/windmc.c
> +++ b/binutils/windmc.c
> @@ -377,7 +377,7 @@ write_header_define (FILE *fp, const unichar *sym_name, rc_uint_type vid, const
> if (nl != NULL)
> {
> if (mcset_out_values_are_decimal)
> - fprintf (fp, "//\n// MessageId: 0x%lu\n//\n", (unsigned long) vid);
> + fprintf (fp, "//\n// MessageId: %lu\n//\n", (unsigned long) vid);
> else
> fprintf (fp, "//\n// MessageId: 0x%lx\n//\n", (unsigned long) vid);
> }
> @@ -392,7 +392,7 @@ write_header_define (FILE *fp, const unichar *sym_name, rc_uint_type vid, const
> (tdef ? "(" : ""), (tdef ? tdef : ""), (tdef ? ")" : ""),
> (unsigned long) vid);
> else
> - fprintf (fp, "#define %s %s%s%s 0x%lu\n\n", sym,
> + fprintf (fp, "#define %s %s%s%s %lu\n\n", sym,
> (tdef ? "(" : ""), (tdef ? tdef : ""), (tdef ? ")" : ""),
> (unsigned long) vid);
> }
> @@ -872,7 +872,7 @@ write_header (FILE *fp)
> fprintf (fp, "#define %s 0x%lx\n", convert_unicode_to_ACP (key->sval),
> (unsigned long) key->nval);
> else
> - fprintf (fp, "#define %s 0x%lu\n", convert_unicode_to_ACP (key->sval),
> + fprintf (fp, "#define %s %lu\n", convert_unicode_to_ACP (key->sval),
> (unsigned long) key->nval);
> }
> }
> @@ -892,7 +892,7 @@ write_header (FILE *fp)
> fprintf (fp, "#define %s 0x%lx\n", convert_unicode_to_ACP (key->sval),
> (unsigned long) key->nval);
> else
> - fprintf (fp, "#define %s 0x%lu\n", convert_unicode_to_ACP (key->sval),
> + fprintf (fp, "#define %s %lu\n", convert_unicode_to_ACP (key->sval),
> (unsigned long) key->nval);
> }
> }
> diff --git a/gas/config/tc-arc.c b/gas/config/tc-arc.c
> index bafa2a5eec..9a8725e773 100644
> --- a/gas/config/tc-arc.c
> +++ b/gas/config/tc-arc.c
> @@ -1485,7 +1485,7 @@ emit_insn0 (struct arc_insn *insn, char *where, bfd_boolean relax)
> size_t total_len;
>
> pr_debug ("Emit insn : 0x%llx\n", insn->insn);
> - pr_debug ("\tLength : 0x%d\n", insn->len);
> + pr_debug ("\tLength : %d\n", insn->len);
> pr_debug ("\tLong imm: 0x%lx\n", insn->limm);
>
> /* Write out the instruction. */
> diff --git a/opcodes/po/es.po b/opcodes/po/es.po
> index 7f67ca0c9b..0a41e6cf48 100644
> --- a/opcodes/po/es.po
> +++ b/opcodes/po/es.po
> @@ -747,7 +747,7 @@ msgstr "operando fuera de rango (%ld no está entre %ld y %lu)"
> #: xstormy16-ibld.c:185
> #, c-format
> msgid "operand out of range (0x%lx not between 0 and 0x%lx)"
> -msgstr "operando fuera de rango (0x%lu no está entre 0 y %lx)"
> +msgstr "operando fuera de rango (0x%lx no está entre 0 y 0x%lx)"
>
> #: epiphany-ibld.c:879 fr30-ibld.c:734 frv-ibld.c:860 ip2k-ibld.c:611
> #: iq2000-ibld.c:717 lm32-ibld.c:638 m32c-ibld.c:1735 m32r-ibld.c:669
> diff --git a/sim/arm/armos.c b/sim/arm/armos.c
> index 76c449b73d..2ce7051a44 100644
> --- a/sim/arm/armos.c
> +++ b/sim/arm/armos.c
> @@ -293,8 +293,8 @@ SWIread (ARMul_State * state, ARMword f, ARMword ptr, ARMword len)
> {
> sim_callback->printf_filtered
> (sim_callback,
> - "sim: Unable to read 0x%ulx bytes - out of memory\n",
> - len);
> + "sim: Unable to read 0x%lx bytes - out of memory\n",
> + (long)len);
> return;
> }
>
> diff --git a/sim/ppc/emul_netbsd.c b/sim/ppc/emul_netbsd.c
> index 61ff70d27d..0bda20e164 100644
> --- a/sim/ppc/emul_netbsd.c
> +++ b/sim/ppc/emul_netbsd.c
> @@ -650,7 +650,7 @@ do_sigprocmask(os_emul_data *emul,
> #endif
>
> if (WITH_TRACE && ppc_trace[trace_os_emul])
> - printf_filtered ("%ld, 0x%ld, 0x%ld", (long)how, (long)set, (long)oset);
> + printf_filtered ("%ld, 0x%lx, 0x%lx", (long)how, (long)set, (long)oset);
>
> emul_write_status(processor, 0, 0);
> cpu_registers(processor)->gpr[4] = set;
> --
> 2.28.0
>
More information about the Binutils
mailing list