Hi Alex, > -----Original Message----- > From: Gcc-patches <gcc-patches-boun...@gcc.gnu.org> On Behalf Of Alex > Butler > Sent: 09 June 2020 22:55 > To: gcc-patches@gcc.gnu.org > Subject: [PATCH][GCC][AArch64]: Replace sprintf call with snprintf in > aarch64.md > > Replaced for consistency with the rest of the aarch64 backend. > > Testing done: > Cross-compiled and regression tested on aarch64-none-elf, no issues. > > --- > gcc/ChangeLog: > > 2020-04-08 Alex Butler <alex.but...@arm.com> > > * config/aarch64/aarch64.md (cb<optab><mode>1): Replace > sprintf with snprintf > > --- > aarch64.md | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/gcc/config/aarch64/aarch64.md > b/gcc/config/aarch64/aarch64.md > index > c7c4d1dd519af6c9df03ba74e7b6ade5f122b4d8..94247cf019e1701843d3a77b352c0b8 > 1dec4fbff 100644 > --- a/gcc/config/aarch64/aarch64.md > +++ b/gcc/config/aarch64/aarch64.md > @@ -953,7 +953,7 @@ > char buf[64]; > uint64_t val = ((uint64_t) 1) > << (GET_MODE_SIZE (<MODE>mode) * BITS_PER_UNIT - 1); > - sprintf (buf, "tst\t%%<w>0, %" PRId64, val); > + snprintf (buf, 64, "tst\t%%<w>0, %" PRId64, val); > output_asm_insn (buf, operands); > return "<bcond>\t%l1"; > }
The move to snprintf() seems good, but why not use sizeof(buf) as the second argument such that this remains correct even if the buffer size changes? Thanks, Alex