From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 7RiDH+iMhGoZEy8AWB0awg (envelope-from ) for ; Tue, 18 Aug 2026 12:48:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1787071720; bh=MVHqXiObpFgwnv6xBqLp/ZHL97UQHQaV/wpT6+BVYeo=; h=Date:Subject:To:Cc:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=UfYcF6VyHlaw2rCLXhnWT7FjldA8OTL3vKBMpki8xhPWfzhZ9mBhrg17rq7PckxM5 m+u4WbixfQUuO3FnTdHZI9JqaY1NChbv55L5ioMUvSKuPOSU1mZw/wAVQY6CT48gtJ a6/g0brbZ3+hVnpqRIpXpnAuXY5bslW9y9M3aDvU= Received: by simark.ca (Postfix, from userid 112) id 74D8C1E033; Tue, 18 Aug 2026 12:48:40 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=k6oX9lpq; dkim-atps=neutral Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id F14421E033 for ; Tue, 18 Aug 2026 12:48:39 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7A4C04BA9001 for ; Tue, 18 Aug 2026 16:48:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7A4C04BA9001 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=k6oX9lpq Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id AA8C34BA23EA; Tue, 18 Aug 2026 16:48:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AA8C34BA23EA Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark.ca ARC-Filter: OpenARC Filter v1.0.0 sourceware.org AA8C34BA23EA Authentication-Results: sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1787071696; cv=none; b=WaAqQLZ7zB32i9B6WO9Xsi/K8FFiLhtT5H2k0oeoJR9/5OoPDRXjfRLcvD1pxI/9m6q33X5UtwOEOcusYWn+7kzH1dRqUqS6FZiJ5A323w1IoJ3G1s+ouk0MPeRLL2Zl7duwFNhx3uttfw6iR/Wgx5l86y6ecKuK3Cpy9PP6K9Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1787071696; c=relaxed/simple; bh=MVHqXiObpFgwnv6xBqLp/ZHL97UQHQaV/wpT6+BVYeo=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=Z2WlWJRkAWWBHB9a76JLWpMwYFJqCzrYhVgIlTisZMzZW5BzvxUMCXNI0PlxxgYAqS4cW0gWICoa5nVJN0X6JIrx4SrR4F/C9AAw0VJMHlcwWCLGpLc9dbsN3CdFM+urvEsTf00te4yAvyNf3izd4f+5wsHihqFr4FdEIZbo6Cw= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=k6oX9lpq DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AA8C34BA23EA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1787071695; bh=MVHqXiObpFgwnv6xBqLp/ZHL97UQHQaV/wpT6+BVYeo=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=k6oX9lpqIqxYTpwSRmOByjm8zpP5dzApUdzYcaz6eN1ufG4ndSghaPUV0YBZV20ha 15ucXGdDia100EkmTFdWd9X4wdCrxssf7USH5kI9in4oLv5LMI1LDA12E/4n81+7TD JGCy1Qt14ACn2h6VNMbsYhVOqYmYF574GP4pOXKo= Received: by simark.ca (Postfix) id C01FF1E033; Tue, 18 Aug 2026 12:48:14 -0400 (EDT) Message-ID: <686e0627-038b-46df-a0ff-6a0d65b2e5dd@simark.ca> Date: Tue, 18 Aug 2026 12:48:14 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 03/13] opcodes/z80: remove use of sprintf To: Jan Beulich , Simon Marchi Cc: gdb-patches@sourceware.org, binutils@sourceware.org References: <20260817151646.152571-1-simon.marchi@efficios.com> <20260817151646.152571-4-simon.marchi@efficios.com> <94f0421e-2159-4483-b536-2473fa65ef4d@suse.com> Content-Language: fr From: Simon Marchi In-Reply-To: <94f0421e-2159-4483-b536-2473fa65ef4d@suse.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org On 8/18/26 2:40 AM, Jan Beulich wrote: > On 17.08.2026 17:16, Simon Marchi wrote: >> --- a/opcodes/z80-dis.c >> +++ b/opcodes/z80-dis.c >> @@ -768,11 +768,55 @@ pref_ind (struct buffer *buf, disassemble_info *info, const char *txt) >> static int >> print_insn_z80_buf (struct buffer *buf, disassemble_info *info); >> >> +struct sized_buf >> +{ >> + char *buf; >> + size_t size; >> +}; >> + >> +/* An fprintf_ftype implementation writing to STREAM, which must point to a >> + struct sized_buf. */ >> + >> +static int ATTRIBUTE_PRINTF_2 >> +sized_buf_printf (void *stream, const char *format, ...) >> +{ >> + va_list ap; >> + int ret; >> + struct sized_buf *sbuf = (struct sized_buf *) stream; > > We're in the (slow going) process of removing such unnecessary casts, in the > interest of getting the amount of casts down in general. Please drop this one > as well as ... Ah sorry, C++ habit. > >> + va_start (ap, format); >> + ret = vsnprintf (sbuf->buf, sbuf->size, format, ap); >> + va_end (ap); >> + >> + return ret; >> +} >> + >> +/* Same as sized_buf_printf, but as an fprintf_styled_ftype implementation. >> + The style is ignored for now. */ >> + >> +static int ATTRIBUTE_PRINTF_3 >> +sized_buf_styled_printf (void *stream, >> + enum disassembler_style style ATTRIBUTE_UNUSED, >> + const char *format, ...) >> +{ >> + va_list ap; >> + int ret; >> + struct sized_buf *sbuf = (struct sized_buf *) stream; > > ... the one here. Fixed. >> + va_start (ap, format); >> + ret = vsnprintf (sbuf->buf, sbuf->size, format, ap); >> + va_end (ap); >> + >> + return ret; >> +} >> + >> static int >> suffix (struct buffer *buf, disassemble_info *info, const char *txt) >> { >> char mybuf[TXTSIZ*4]; >> + struct sized_buf sbuf = { mybuf, sizeof (mybuf) }; > > Please use ARRAY_SIZE() here. sizeof() happens to be correct for char[], but > wouldn't be correct for e.g. wchar_t[]. Fixed. > Okay with these adjustments. Thanks, pushed with those changes. Simon