From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lug-owl.de (lug-owl.de [188.68.32.151]) by sourceware.org (Postfix) with ESMTPS id 23BCD3858D1E for ; Mon, 22 May 2023 23:58:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 23BCD3858D1E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=lug-owl.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=lug-owl.de Received: by lug-owl.de (Postfix, from userid 1001) id 475D142047; Tue, 23 May 2023 01:58:41 +0200 (CEST) Date: Tue, 23 May 2023 01:58:41 +0200 From: Jan-Benedict Glaw To: Nick Clifton , gcc-patches@gcc.gnu.org Subject: [patch] mcore: Fix sprintf length warning Message-ID: <20230522235841.inxggcczfaatu6ct@lug-owl.de> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="5cjrfzx2zvspsmly" Content-Disposition: inline X-Operating-System: Linux chamaeleon 5.14.0-0.bpo.2-amd64 X-gpg-fingerprint: 250D 3BCF 7127 0D8C A444 A961 1DBD 5E75 8399 E1BB X-gpg-key: wwwkeys.de.pgp.net X-Echelon-Enable: howto poison arsenous mail psychological biological nuclear warfare test the bombastical terror of flooding the spy listeners explosion sex drugs and rock'n'roll X-TKUeV: howto poison arsenous mail psychological biological nuclear warfare test the bombastical terror of flooding the spy listeners explosion sex drugs and rock'n'roll X-message-flag: Please send plain text messages only. Do not send HTML emails. Thank you. User-Agent: NeoMutt/20170113 (1.7.2) X-Spam-Status: No, score=-9.3 required=5.0 tests=BAYES_00,GIT_PATCH_0,KAM_ASCII_DIVIDERS,KAM_DMARC_STATUS,KAM_LOTSOFHASH,SPF_HELO_PASS,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: --5cjrfzx2zvspsmly Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi! One of the supplied argument strings is unneccesarily long (c-sky, using basically the same code, fixed it to a shorter length) and this fixes overf= low warnings, as GCC fails to deduce that the full 256 bytes for load_op[] are not used at all. make[1]: Entering directory '/var/lib/laminar/run/gcc-mcore-elf/38/toolchai= n-build/gcc' [...] /usr/lib/gcc-snapshot/bin/g++ -fno-PIE -c -g -O2 -DIN_GCC -DCROSS_DIR= ECTORY_STRUCTURE -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -= W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribu= te -Wconditionally-supported -Woverloaded-virtual -pedantic -Wno-long-long = -Wno-variadic-macros -Wno-overlength-strings -Werror -fno-common -DHAVE_CO= NFIG_H -I. -I. -I../../gcc/gcc -I../../gcc/gcc/. -I../../gcc/gcc/../include= -I../../gcc/gcc/../libcpp/include -I../../gcc/gcc/../libcody -I../../gcc= /gcc/../libdecnumber -I../../gcc/gcc/../libdecnumber/dpd -I../libdecnumber = -I../../gcc/gcc/../libbacktrace -o mcore.o -MT mcore.o -MMD -MP -MF ./.de= ps/mcore.TPo ../../gcc/gcc/config/mcore/mcore.cc =2E./../gcc/gcc/config/mcore/mcore.cc: In function 'const char* output_inli= ne_const(machine_mode, rtx_def**)': =2E./../gcc/gcc/config/mcore/mcore.cc:1264:24: error: ' ixw ' directive writing 6 bytes into a region of size between 1 and 256 [-= Werror=3Dformat-overflow=3D] 1264 | sprintf (buf, "%s\n\tixw\t%s,%s\t// %ld 0x%lx", load_op, dst_= fmt, dst_fmt, value, value); | ^~~~~~~~~ =2E./../gcc/gcc/config/mcore/mcore.cc:1264:21: note: using the range [0, 18= 446744073709551615] for directive argument 1264 | sprintf (buf, "%s\n\tixw\t%s,%s\t// %ld 0x%lx", load_op, dst_= fmt, dst_fmt, value, value); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ =2E./../gcc/gcc/config/mcore/mcore.cc:1264:15: note: 'sprintf' output betwe= en 21 and 310 bytes into a destination of size 256 1264 | sprintf (buf, "%s\n\tixw\t%s,%s\t// %ld 0x%lx", load_op, dst_= fmt, dst_fmt, value, value); | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~= ~~~~~~~~~~~~~~~~~~~~~~~~~~~ =2E./../gcc/gcc/config/mcore/mcore.cc:1261:24: error: ' ixh ' directive writing 6 bytes into a region of size between 1 and 256 [-= Werror=3Dformat-overflow=3D] 1261 | sprintf (buf, "%s\n\tixh\t%s,%s\t// %ld 0x%lx", load_op, dst_= fmt, dst_fmt, value, value); | ^~~~~~~~~ =2E./../gcc/gcc/config/mcore/mcore.cc:1261:21: note: using the range [0, 18= 446744073709551615] for directive argument 1261 | sprintf (buf, "%s\n\tixh\t%s,%s\t// %ld 0x%lx", load_op, dst_= fmt, dst_fmt, value, value); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ =2E./../gcc/gcc/config/mcore/mcore.cc:1261:15: note: 'sprintf' output betwe= en 21 and 310 bytes into a destination of size 256 1261 | sprintf (buf, "%s\n\tixh\t%s,%s\t// %ld 0x%lx", load_op, dst_= fmt, dst_fmt, value, value); | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~= ~~~~~~~~~~~~~~~~~~~~~~~~~~~ =2E./../gcc/gcc/config/mcore/mcore.cc:1258:24: error: ' lsli ' directive writing 7 bytes into a region of size between 1 and 256 [= -Werror=3Dformat-overflow=3D] 1258 | sprintf (buf, "%s\n\tlsli\t%s,%%2\t// %ld 0x%lx", load_op, ds= t_fmt, value, value); | ^~~~~~~~~~ =2E./../gcc/gcc/config/mcore/mcore.cc:1258:21: note: using the range [0, 18= 446744073709551615] for directive argument 1258 | sprintf (buf, "%s\n\tlsli\t%s,%%2\t// %ld 0x%lx", load_op, ds= t_fmt, value, value); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ =2E./../gcc/gcc/config/mcore/mcore.cc:1258:15: note: 'sprintf' output betwe= en 22 and 311 bytes into a destination of size 256 1258 | sprintf (buf, "%s\n\tlsli\t%s,%%2\t// %ld 0x%lx", load_op, ds= t_fmt, value, value); | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~= ~~~~~~~~~~~~~~~~~~~~ =2E./../gcc/gcc/config/mcore/mcore.cc:1255:24: error: ' rotli ' directive writing 8 bytes into a region of size between 1 and 256 = [-Werror=3Dformat-overflow=3D] 1255 | sprintf (buf, "%s\n\trotli\t%s,%%2\t// %ld 0x%lx", load_op, d= st_fmt, value, value); | ^~~~~~~~~~~ =2E./../gcc/gcc/config/mcore/mcore.cc:1255:21: note: using the range [0, 18= 446744073709551615] for directive argument 1255 | sprintf (buf, "%s\n\trotli\t%s,%%2\t// %ld 0x%lx", load_op, d= st_fmt, value, value); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ =2E./../gcc/gcc/config/mcore/mcore.cc:1255:15: note: 'sprintf' output betwe= en 23 and 312 bytes into a destination of size 256 1255 | sprintf (buf, "%s\n\trotli\t%s,%%2\t// %ld 0x%lx", load_op, d= st_fmt, value, value); | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~= ~~~~~~~~~~~~~~~~~~~~~ =2E./../gcc/gcc/config/mcore/mcore.cc:1252:24: error: ' bclri ' directive writing 8 bytes into a region of size between 1 and 256 = [-Werror=3Dformat-overflow=3D] 1252 | sprintf (buf, "%s\n\tbclri\t%s,%%Q2\t// %ld 0x%lx", load_op, = dst_fmt, value, value); | ^~~~~~~~~~~ =2E./../gcc/gcc/config/mcore/mcore.cc:1252:21: note: using the range [0, 18= 446744073709551615] for directive argument 1252 | sprintf (buf, "%s\n\tbclri\t%s,%%Q2\t// %ld 0x%lx", load_op, = dst_fmt, value, value); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ =2E./../gcc/gcc/config/mcore/mcore.cc:1252:15: note: 'sprintf' output betwe= en 24 and 313 bytes into a destination of size 256 1252 | sprintf (buf, "%s\n\tbclri\t%s,%%Q2\t// %ld 0x%lx", load_op, = dst_fmt, value, value); | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~= ~~~~~~~~~~~~~~~~~~~~~~ =2E./../gcc/gcc/config/mcore/mcore.cc:1249:24: error: ' bseti ' directive writing 8 bytes into a region of size between 1 and 256 = [-Werror=3Dformat-overflow=3D] 1249 | sprintf (buf, "%s\n\tbseti\t%s,%%P2\t// %ld 0x%lx", load_op, = dst_fmt, value, value); | ^~~~~~~~~~~ =2E./../gcc/gcc/config/mcore/mcore.cc:1249:21: note: using the range [0, 18= 446744073709551615] for directive argument 1249 | sprintf (buf, "%s\n\tbseti\t%s,%%P2\t// %ld 0x%lx", load_op, = dst_fmt, value, value); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ =2E./../gcc/gcc/config/mcore/mcore.cc:1249:15: note: 'sprintf' output betwe= en 24 and 313 bytes into a destination of size 256 1249 | sprintf (buf, "%s\n\tbseti\t%s,%%P2\t// %ld 0x%lx", load_op, = dst_fmt, value, value); | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~= ~~~~~~~~~~~~~~~~~~~~~~ =2E./../gcc/gcc/config/mcore/mcore.cc:1246:24: error: ' rsubi ' directive writing 8 bytes into a region of size between 1 and 256 = [-Werror=3Dformat-overflow=3D] 1246 | sprintf (buf, "%s\n\trsubi\t%s,%%2\t// %ld 0x%lx", load_op, d= st_fmt, value, value); | ^~~~~~~~~~~ =2E./../gcc/gcc/config/mcore/mcore.cc:1246:21: note: using the range [0, 18= 446744073709551615] for directive argument 1246 | sprintf (buf, "%s\n\trsubi\t%s,%%2\t// %ld 0x%lx", load_op, d= st_fmt, value, value); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ =2E./../gcc/gcc/config/mcore/mcore.cc:1246:15: note: 'sprintf' output betwe= en 23 and 312 bytes into a destination of size 256 1246 | sprintf (buf, "%s\n\trsubi\t%s,%%2\t// %ld 0x%lx", load_op, d= st_fmt, value, value); | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~= ~~~~~~~~~~~~~~~~~~~~~ =2E./../gcc/gcc/config/mcore/mcore.cc:1242:24: error: ' subi ' directive writing 7 bytes into a region of size between 1 and 256 [= -Werror=3Dformat-overflow=3D] 1242 | sprintf (buf, "%s\n\tsubi\t%s,%%2\t// %ld 0x%lx", load_op, ds= t_fmt, value, value); | ^~~~~~~~~~ =2E./../gcc/gcc/config/mcore/mcore.cc:1242:21: note: using the range [0, 18= 446744073709551615] for directive argument 1242 | sprintf (buf, "%s\n\tsubi\t%s,%%2\t// %ld 0x%lx", load_op, ds= t_fmt, value, value); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ =2E./../gcc/gcc/config/mcore/mcore.cc:1242:15: note: 'sprintf' output betwe= en 22 and 311 bytes into a destination of size 256 1242 | sprintf (buf, "%s\n\tsubi\t%s,%%2\t// %ld 0x%lx", load_op, ds= t_fmt, value, value); | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~= ~~~~~~~~~~~~~~~~~~~~ =2E./../gcc/gcc/config/mcore/mcore.cc:1239:24: error: ' addi ' directive writing 7 bytes into a region of size between 1 and 256 [= -Werror=3Dformat-overflow=3D] 1239 | sprintf (buf, "%s\n\taddi\t%s,%%2\t// %ld 0x%lx", load_op, ds= t_fmt, value, value); | ^~~~~~~~~~ =2E./../gcc/gcc/config/mcore/mcore.cc:1239:21: note: using the range [0, 18= 446744073709551615] for directive argument 1239 | sprintf (buf, "%s\n\taddi\t%s,%%2\t// %ld 0x%lx", load_op, ds= t_fmt, value, value); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ =2E./../gcc/gcc/config/mcore/mcore.cc:1239:15: note: 'sprintf' output betwe= en 22 and 311 bytes into a destination of size 256 1239 | sprintf (buf, "%s\n\taddi\t%s,%%2\t// %ld 0x%lx", load_op, ds= t_fmt, value, value); | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~= ~~~~~~~~~~~~~~~~~~~~ =2E./../gcc/gcc/config/mcore/mcore.cc:1236:24: error: ' not ' directive writing 6 bytes into a region of size between 1 and 256 [-= Werror=3Dformat-overflow=3D] 1236 | sprintf (buf, "%s\n\tnot\t%s\t// %ld 0x%lx", load_op, dst_fmt= , value, value); | ^~~~~~~~~ =2E./../gcc/gcc/config/mcore/mcore.cc:1236:21: note: using the range [0, 18= 446744073709551615] for directive argument 1236 | sprintf (buf, "%s\n\tnot\t%s\t// %ld 0x%lx", load_op, dst_fmt= , value, value); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ =2E./../gcc/gcc/config/mcore/mcore.cc:1236:15: note: 'sprintf' output betwe= en 18 and 307 bytes into a destination of size 256 1236 | sprintf (buf, "%s\n\tnot\t%s\t// %ld 0x%lx", load_op, dst_fmt= , value, value); | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~= ~~~~~~~~~~~~~~~ cc1plus: all warnings being treated as errors make[1]: *** [Makefile:2461: mcore.o] Error 1 gcc/ChangeLog: * config/mcore/mcore.cc (output_inline_const) Make buffer smaller to silence overflow warnings later on. diff --git a/gcc/config/mcore/mcore.cc b/gcc/config/mcore/mcore.cc index 92e7f960f75..e933b03cdff 100644 --- a/gcc/config/mcore/mcore.cc +++ b/gcc/config/mcore/mcore.cc @@ -1182,7 +1182,7 @@ output_inline_const (machine_mode mode, rtx operands[= ]) int trick_no; rtx out_operands[3]; char buf[256]; - char load_op[256]; + char load_op[128]; const char *dst_fmt; HOST_WIDE_INT value; Ok? Thanks, Jan-Benedict --=20 --5cjrfzx2zvspsmly Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQQlDTvPcScNjKREqWEdvV51g5nhuwUCZGwBqgAKCRAdvV51g5nh u3SfAJ4rHPJyN0MlSSFcFQeq0YbfIW/w4QCfRaeJ32RyArlmORAdHv00Fboteus= =+Bh8 -----END PGP SIGNATURE----- --5cjrfzx2zvspsmly--