From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by sourceware.org (Postfix) with ESMTPS id 33BFF3858D35 for ; Tue, 23 May 2023 18:11:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 33BFF3858D35 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-64d4e45971bso49350b3a.2 for ; Tue, 23 May 2023 11:11:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684865512; x=1687457512; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=85mBqR/fULPZhSsnKBfaFxtKEo5P7edKiKLvK126bHA=; b=LiRbFYMdSwcFEpiB3i+yoga8u6iWBfp6bDgxXopsWFMVckz/MZs6hmj3+ng8PcEOFA ZT6chqQjVLqfAS7/mtSVZ7TVwAAnvkCwl86j6kQW4xvz7FmZg+gnymgW+IW3Ku+3/Kvg l4wpuE5F8Yg0+mHY2Pywqu4OdIrMYtgX7Fh20LRzqylGCC0Z9+Exf0/m/LI8aqkBoW2A /V3C57OOP/QtaTj8M7MafELh2nsXMd0udqrHoP7R3Imq8uyzSAxoH281VV/YQPNYIBuN 0BpHnUKzbSmzp/do9n9ytTzdgq5AbQ0/ul9xZOfmC8abI0HoopS2EXuVI/uzjx4YcgzY RcQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684865512; x=1687457512; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=85mBqR/fULPZhSsnKBfaFxtKEo5P7edKiKLvK126bHA=; b=TfL6QLZX6mqireJYoZvQJZOpE4v9Mz5oGWwPy+v6tapnKYBpTUpM6C4L3s2G7uHUjG 604eXdRy8sJ9LJAQ7yhqiitrhTRVMGVlgU0+p4NJ4ibovMZN1CroRXVFo0N3sq/QJ0Ej 6sJCeL20NtZtIJVn4742yLiJZ5ElQc4XZalFuPMbcTz7UhtH63rRYsOqTQGQl7h9Psyi Zt4ghLSBPHbbr/1ebdIWEMLi2AGgU0rVgjm665RKZfhOo6sPueGQxQINCQoxlgSwhpve KO1XzwJ3cvE604CXGnNy6Ea4akxjsgiH36Vya9nzmtp+p32NUwZX3V8IgOz5ZejIFtEP hrbA== X-Gm-Message-State: AC+VfDx/rDmFqiTlksMHWxjaILsynU5v4fRP3E1AqWvEpEUn+i00kUYc Rd7ZEW9tC2noMocgqDag4no= X-Google-Smtp-Source: ACHHUZ43Uy94+wtm0wNs08uSBNI8GPMMeCdLmzMyiELWf3ZQwx6pO19NrBTz8I9bmXaoINfADUZsnQ== X-Received: by 2002:a05:6a21:2d8c:b0:10a:e177:9e73 with SMTP id ty12-20020a056a212d8c00b0010ae1779e73mr10238781pzb.46.1684865511696; Tue, 23 May 2023 11:11:51 -0700 (PDT) Received: from ?IPV6:2601:681:8d00:265::f0a? ([2601:681:8d00:265::f0a]) by smtp.gmail.com with ESMTPSA id k25-20020a63ff19000000b00530914c3bc1sm6265199pgi.21.2023.05.23.11.11.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 23 May 2023 11:11:51 -0700 (PDT) Message-ID: Date: Tue, 23 May 2023 12:11:49 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 Subject: Re: [patch] mcore: Fix sprintf length warning Content-Language: en-US To: Jan-Benedict Glaw , Nick Clifton , gcc-patches@gcc.gnu.org References: <20230522235841.inxggcczfaatu6ct@lug-owl.de> From: Jeff Law In-Reply-To: <20230522235841.inxggcczfaatu6ct@lug-owl.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,KAM_ASCII_DIVIDERS,KAM_LOTSOFHASH,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 5/22/23 17:58, Jan-Benedict Glaw wrote: > 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 overflow > 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/toolchain-build/gcc' > [...] > /usr/lib/gcc-snapshot/bin/g++ -fno-PIE -c -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -Wconditionally-supported -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Werror -fno-common -DHAVE_CONFIG_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 ./.deps/mcore.TPo ../../gcc/gcc/config/mcore/mcore.cc > ../../gcc/gcc/config/mcore/mcore.cc: In function 'const char* output_inline_const(machine_mode, rtx_def**)': > ../../gcc/gcc/config/mcore/mcore.cc:1264:24: error: ' > ixw ' directive writing 6 bytes into a region of size between 1 and 256 [-Werror=format-overflow=] > 1264 | sprintf (buf, "%s\n\tixw\t%s,%s\t// %ld 0x%lx", load_op, dst_fmt, dst_fmt, value, value); > | ^~~~~~~~~ > ../../gcc/gcc/config/mcore/mcore.cc:1264:21: note: using the range [0, 18446744073709551615] for directive argument > 1264 | sprintf (buf, "%s\n\tixw\t%s,%s\t// %ld 0x%lx", load_op, dst_fmt, dst_fmt, value, value); > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > ../../gcc/gcc/config/mcore/mcore.cc:1264:15: note: 'sprintf' output between 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); > | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > ../../gcc/gcc/config/mcore/mcore.cc:1261:24: error: ' > ixh ' directive writing 6 bytes into a region of size between 1 and 256 [-Werror=format-overflow=] > 1261 | sprintf (buf, "%s\n\tixh\t%s,%s\t// %ld 0x%lx", load_op, dst_fmt, dst_fmt, value, value); > | ^~~~~~~~~ > ../../gcc/gcc/config/mcore/mcore.cc:1261:21: note: using the range [0, 18446744073709551615] for directive argument > 1261 | sprintf (buf, "%s\n\tixh\t%s,%s\t// %ld 0x%lx", load_op, dst_fmt, dst_fmt, value, value); > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > ../../gcc/gcc/config/mcore/mcore.cc:1261:15: note: 'sprintf' output between 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); > | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > ../../gcc/gcc/config/mcore/mcore.cc:1258:24: error: ' > lsli ' directive writing 7 bytes into a region of size between 1 and 256 [-Werror=format-overflow=] > 1258 | sprintf (buf, "%s\n\tlsli\t%s,%%2\t// %ld 0x%lx", load_op, dst_fmt, value, value); > | ^~~~~~~~~~ > ../../gcc/gcc/config/mcore/mcore.cc:1258:21: note: using the range [0, 18446744073709551615] for directive argument > 1258 | sprintf (buf, "%s\n\tlsli\t%s,%%2\t// %ld 0x%lx", load_op, dst_fmt, value, value); > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > ../../gcc/gcc/config/mcore/mcore.cc:1258:15: note: 'sprintf' output between 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, dst_fmt, value, value); > | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > ../../gcc/gcc/config/mcore/mcore.cc:1255:24: error: ' > rotli ' directive writing 8 bytes into a region of size between 1 and 256 [-Werror=format-overflow=] > 1255 | sprintf (buf, "%s\n\trotli\t%s,%%2\t// %ld 0x%lx", load_op, dst_fmt, value, value); > | ^~~~~~~~~~~ > ../../gcc/gcc/config/mcore/mcore.cc:1255:21: note: using the range [0, 18446744073709551615] for directive argument > 1255 | sprintf (buf, "%s\n\trotli\t%s,%%2\t// %ld 0x%lx", load_op, dst_fmt, value, value); > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > ../../gcc/gcc/config/mcore/mcore.cc:1255:15: note: 'sprintf' output between 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, dst_fmt, value, value); > | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > ../../gcc/gcc/config/mcore/mcore.cc:1252:24: error: ' > bclri ' directive writing 8 bytes into a region of size between 1 and 256 [-Werror=format-overflow=] > 1252 | sprintf (buf, "%s\n\tbclri\t%s,%%Q2\t// %ld 0x%lx", load_op, dst_fmt, value, value); > | ^~~~~~~~~~~ > ../../gcc/gcc/config/mcore/mcore.cc:1252:21: note: using the range [0, 18446744073709551615] for directive argument > 1252 | sprintf (buf, "%s\n\tbclri\t%s,%%Q2\t// %ld 0x%lx", load_op, dst_fmt, value, value); > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > ../../gcc/gcc/config/mcore/mcore.cc:1252:15: note: 'sprintf' output between 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); > | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > ../../gcc/gcc/config/mcore/mcore.cc:1249:24: error: ' > bseti ' directive writing 8 bytes into a region of size between 1 and 256 [-Werror=format-overflow=] > 1249 | sprintf (buf, "%s\n\tbseti\t%s,%%P2\t// %ld 0x%lx", load_op, dst_fmt, value, value); > | ^~~~~~~~~~~ > ../../gcc/gcc/config/mcore/mcore.cc:1249:21: note: using the range [0, 18446744073709551615] for directive argument > 1249 | sprintf (buf, "%s\n\tbseti\t%s,%%P2\t// %ld 0x%lx", load_op, dst_fmt, value, value); > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > ../../gcc/gcc/config/mcore/mcore.cc:1249:15: note: 'sprintf' output between 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); > | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > ../../gcc/gcc/config/mcore/mcore.cc:1246:24: error: ' > rsubi ' directive writing 8 bytes into a region of size between 1 and 256 [-Werror=format-overflow=] > 1246 | sprintf (buf, "%s\n\trsubi\t%s,%%2\t// %ld 0x%lx", load_op, dst_fmt, value, value); > | ^~~~~~~~~~~ > ../../gcc/gcc/config/mcore/mcore.cc:1246:21: note: using the range [0, 18446744073709551615] for directive argument > 1246 | sprintf (buf, "%s\n\trsubi\t%s,%%2\t// %ld 0x%lx", load_op, dst_fmt, value, value); > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > ../../gcc/gcc/config/mcore/mcore.cc:1246:15: note: 'sprintf' output between 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, dst_fmt, value, value); > | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > ../../gcc/gcc/config/mcore/mcore.cc:1242:24: error: ' > subi ' directive writing 7 bytes into a region of size between 1 and 256 [-Werror=format-overflow=] > 1242 | sprintf (buf, "%s\n\tsubi\t%s,%%2\t// %ld 0x%lx", load_op, dst_fmt, value, value); > | ^~~~~~~~~~ > ../../gcc/gcc/config/mcore/mcore.cc:1242:21: note: using the range [0, 18446744073709551615] for directive argument > 1242 | sprintf (buf, "%s\n\tsubi\t%s,%%2\t// %ld 0x%lx", load_op, dst_fmt, value, value); > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > ../../gcc/gcc/config/mcore/mcore.cc:1242:15: note: 'sprintf' output between 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, dst_fmt, value, value); > | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > ../../gcc/gcc/config/mcore/mcore.cc:1239:24: error: ' > addi ' directive writing 7 bytes into a region of size between 1 and 256 [-Werror=format-overflow=] > 1239 | sprintf (buf, "%s\n\taddi\t%s,%%2\t// %ld 0x%lx", load_op, dst_fmt, value, value); > | ^~~~~~~~~~ > ../../gcc/gcc/config/mcore/mcore.cc:1239:21: note: using the range [0, 18446744073709551615] for directive argument > 1239 | sprintf (buf, "%s\n\taddi\t%s,%%2\t// %ld 0x%lx", load_op, dst_fmt, value, value); > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > ../../gcc/gcc/config/mcore/mcore.cc:1239:15: note: 'sprintf' output between 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, dst_fmt, value, value); > | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > ../../gcc/gcc/config/mcore/mcore.cc:1236:24: error: ' > not ' directive writing 6 bytes into a region of size between 1 and 256 [-Werror=format-overflow=] > 1236 | sprintf (buf, "%s\n\tnot\t%s\t// %ld 0x%lx", load_op, dst_fmt, value, value); > | ^~~~~~~~~ > ../../gcc/gcc/config/mcore/mcore.cc:1236:21: note: using the range [0, 18446744073709551615] for directive argument > 1236 | sprintf (buf, "%s\n\tnot\t%s\t// %ld 0x%lx", load_op, dst_fmt, value, value); > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > ../../gcc/gcc/config/mcore/mcore.cc:1236:15: note: 'sprintf' output between 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. 128 is probably still unnecessarily long, but OK. jeff