From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by sourceware.org (Postfix) with ESMTPS id D8E0B3858D39; Mon, 1 Aug 2022 13:32:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D8E0B3858D39 Received: by mail-pj1-x1031.google.com with SMTP id q7-20020a17090a7a8700b001f300db8677so12009947pjf.5; Mon, 01 Aug 2022 06:32:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=KmRsoAAwGwBLXETiqSeC8KCDiNznURdxNQN6o1x5tRY=; b=TBfpKwsJXuYQg3ln0bpokwzfYHJGZbxroh9ZsL/VVyB+m381RaLI5HkyT3XMs16Pse UnZIXyldWnuePT/qR9nG21oQ6FN/ecu9ppMtKjnC9SWCzqrV9QB8mFes8uapgNm7ZyvQ 7iVYTyECNZlqBTIBlQjyLTfuor3mnC6aMT6lwbSu1UqSHJ8VG1oXXXEkS3E4yW0HVKId CSc/4GqofsqvqerXkCASRqj04RHHXaXIR+YBDicQ3zJDghOdsQfqq3eUf1c9m2hSU6CZ H575BDloCFU9wJcZQvUHeIaExIeJ5I1++XsWaNIIreCK8U90R2mKKivvhPusm/Dn+YgW 51Ug== X-Gm-Message-State: ACgBeo34V5vWovFrXGxf1faiuxAaifnQkVIUZPk5UdF6R/3J0zZ8Mh00 lMpQ+VhpcPr04yAKkrnjY1KTqIS9BQ8= X-Google-Smtp-Source: AA6agR5Z2OfUUP3cazWUL62fKo1DsKFX3kIdEj+2CThity0kI6V3Y5ixnCr49D96C8exYCHJzEYmOA== X-Received: by 2002:a17:90b:1d0b:b0:1f5:72f:652c with SMTP id on11-20020a17090b1d0b00b001f5072f652cmr4087619pjb.38.1659360756596; Mon, 01 Aug 2022 06:32:36 -0700 (PDT) Received: from squeak.grove.modra.org ([2406:3400:51d:8cc0:a191:bba5:dc6e:aa52]) by smtp.gmail.com with ESMTPSA id a4-20020a170902ecc400b0016d6963cb12sm9698255plh.304.2022.08.01.06.32.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Aug 2022 06:32:36 -0700 (PDT) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id 9E5461140177; Mon, 1 Aug 2022 23:02:33 +0930 (ACST) Date: Mon, 1 Aug 2022 23:02:33 +0930 From: Alan Modra To: Jan Beulich Cc: binutils@sourceware.org, gdb-patches@sourceware.org Subject: Re: Get rid of fprintf_vma and sprintf_vma Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-3028.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Aug 2022 13:32:39 -0000 On Mon, Aug 01, 2022 at 11:01:57AM +0200, Jan Beulich wrote: > On 01.08.2022 06:33, Alan Modra via Binutils wrote: > > --- a/gas/config/tc-i386.c > > +++ b/gas/config/tc-i386.c > > @@ -2377,15 +2377,8 @@ offset_in_range (offsetT val, int size) > > } > > > > if ((val & ~mask) != 0 && (-val & ~mask) != 0) > > - { > > - char val_buf[128]; > > - char masked_buf[128]; > > - > > - /* Coded this way in order to ease translation. */ > > - sprintf_vma (val_buf, val); > > - sprintf_vma (masked_buf, val & mask); > > - as_warn (_("0x%s shortened to 0x%s"), val_buf, masked_buf); > > - } > > + as_warn (_("0x%" PRIx64 " shortened to 0x%" PRIx64), > > + (uint64_t) val, (uint64_t) (val & mask)); > > > > return val & mask; > > } > > @@ -4913,12 +4906,8 @@ md_assemble (char *line) > > i.types[j].bitfield.disp32 = 0; > > if (i.types[j].bitfield.baseindex) > > { > > - char number_buf[128]; > > - > > - /* Coded this way in order to allow for ease of translation. */ > > - sprintf_vma (number_buf, exp->X_add_number); > > - as_bad (_("0x%s out of range of signed 32bit displacement"), > > - number_buf); > > + as_bad (_("0x%" PRIx64 " out of range of signed 32bit displacement"), > > + (uint64_t) exp->X_add_number); > > return; > > } > > } > > Just as a general remark / question, seeing these changes: Wouldn't > it be slightly better to use the # modifier in cases like these? It's > one byte less of literal string space and results in zero to be > printed as plain "0" (no 0x prefix)? Yes, that would be nicer. I do have a nagging suspicion that some compilers complain about unknown format specifier if you write "%#" PRIx64. Maybe that was with "%#" BFD_VMA_FMT "x", I can't remember exactly where I saw the warning. Or possibly it was some random development version of gcc I happened to be using, in which case it's not a problem. -- Alan Modra Australia Development Lab, IBM