From patchwork Thu Apr 11 10:15:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 787950 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp150035wrm; Thu, 11 Apr 2024 03:21:23 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUwrdn4Wpqf9N1sYbC8GNClZvtmYD1/NrYDgSWv8SQ707suQuaTcQRt+moTiEWSIqWg/nN+L8A+kPArz6qOrWEb X-Google-Smtp-Source: AGHT+IHZHRcfF8j2WYMXrgCKsgSWkUmD9PIxL60guIBPD5FOZZV8Aa0GhuWviVJELcHfb/J+CaJn X-Received: by 2002:a05:622a:513:b0:431:3f48:732e with SMTP id l19-20020a05622a051300b004313f48732emr4956570qtx.65.1712830883353; Thu, 11 Apr 2024 03:21:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712830883; cv=none; d=google.com; s=arc-20160816; b=PrVIHEbLZKufQ+nDIGWXib/zH4EHbkMPUGuhGvMhVX0vUpLH3Ybc5IGey7+x+ShKot CqLf7in5cDIHj1Yb3rlwchIoVDRBLWu/UHBoM1LGGmT2P8kyxDyeBjo287JSsCFN27Pq xFzi1RddFio+WJuU4VTNaK1qTFbVBv8PT3LVY1cJHjlOJxwW11+rKZazqbzJDxx5pSHi gIcHnf4du2yGKqUwtNBlawbQlokIq4glsNBYN4rjBMCnjnncJpdIzXmu1iZRFS3toGkF bUeQgIJVMt7+Cuq4kDq/9fANynrGNicHO8i+EBHowsIz8tyFFKNr74D1M0bRclY2/ikD 3/fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=PowLaTwCiK0zblbMYsUQoyhFkR48l8ASgwvzYVcEv18=; fh=sUmKl6kuK1QEm1H6mIwPRtJgzX8TTCQJruBb8zwn0+E=; b=aQnH2Us3DqiKKX3H68aUzHJEEFOOi3iHL9UNso7TF+QlGz3A77Obk6U37y5CM8Cf0Q dKGRshskQ4xnhjMW+7pRZzdqzuypZHq5Kl7R2Lu73OaqSfJ24B3g1frOl8m2D3wpL5Ke VfdenbKVHw+9dA/VFKf5/mwfnyeUKm52VRu5UIijO+BvOPSxzRyNaSTHZkAej06lTYtx P8pO9vwjEH18SzHnSzY/SkneuTqnf69FNhoBd86mrZTzwDxvKRgwdSyXtcJDoSOyTvDB 78+UmYQPdHLNQOGhK26SIq4OFLg9ghsqB0zLEaZpSek+d0s89W8LngVHbBMMgjtr2PoD e5Bg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VQa6Q7Rz; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v3-20020ac85783000000b0043472fb26d8si1195357qta.615.2024.04.11.03.21.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 11 Apr 2024 03:21:23 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VQa6Q7Rz; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rurUx-0006ID-PE; Thu, 11 Apr 2024 06:17:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rurUD-0005Jf-DS for qemu-devel@nongnu.org; Thu, 11 Apr 2024 06:16:54 -0400 Received: from mail-lj1-x22a.google.com ([2a00:1450:4864:20::22a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rurUA-0007aR-Ni for qemu-devel@nongnu.org; Thu, 11 Apr 2024 06:16:53 -0400 Received: by mail-lj1-x22a.google.com with SMTP id 38308e7fff4ca-2d895138ce6so50936091fa.0 for ; Thu, 11 Apr 2024 03:16:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712830608; x=1713435408; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PowLaTwCiK0zblbMYsUQoyhFkR48l8ASgwvzYVcEv18=; b=VQa6Q7RzqhcSjCOYkiD1cPtRDt4kLEAS6oqku4CVnZ3aiZwy6jHfERmvlZQFSKRtX4 i5E+M4jYt1TtciZdzKSdxVw3QjANQRr6sLJWj8562zU2H0XLwIICqPKjixx5o+GrYu3a +9dNr6FLz/cMsboMgv/W75nmxIOigddZY+HqxMH9I8B0bre04zy9ct/dPxR3oPrW8HHU sAZ1LB/aNw5Xz+d5N8kM+wEhAhqdTu5Bt/GQoN3UupAgYaexDMl9Fobmj5It42c/P7tT yfm2XPyTef0Vivhlp+QnlRoFIKKTvKGxmbj1j/Z0vl5yyNYOlEDTRJaa71ekKnEtPKjJ pGeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712830608; x=1713435408; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PowLaTwCiK0zblbMYsUQoyhFkR48l8ASgwvzYVcEv18=; b=XCGd8m5t+Lxh23PRrt51VriTD2fwCdg2nmorL1eoVqjzLfg/F80NdOzaiZgjyB0B7x RAZcWX7paTnN9eRfeSjY+2HgiHzKB+Gq5SsFcuycbodjg/v7mh6Fjm7q5mhqHwX/sUjh F1y3H2oT7m98SmxNMaAcLLhIZlsJEta+Jzc0khWkMEfJL8KFS/gyvo2d33/3L8fUtePF knQCh0Y5VrUk/LjZN3Gjx3PMMoGaXu+PprvjoGfPzCJKzIlwXnNavjkVBvzEBwpqL7Sa uTMACF+1l5T/aXrqTRMZxJHe+1C7aMVP0kTp0r3UIr04jB3rbszgpOXXC+1+tyAdhOQt RaQQ== X-Gm-Message-State: AOJu0YzlMEY4pkuoet6qbvKz0VxX4FcWdqSMOyy1YOR0CFjTU9ZyIsC6 f9yniDRyLQnEnWv+zCh+o067o3hESsXKMuoDLcMrlLQ2q+rgWT2Ju0p4cuwaEysF88s0W8UUSk9 pbYk= X-Received: by 2002:a2e:bc11:0:b0:2d8:901f:7f50 with SMTP id b17-20020a2ebc11000000b002d8901f7f50mr4317602ljf.9.1712830608025; Thu, 11 Apr 2024 03:16:48 -0700 (PDT) Received: from localhost.localdomain (137.red-88-29-174.dynamicip.rima-tde.net. [88.29.174.137]) by smtp.gmail.com with ESMTPSA id fm6-20020a05600c0c0600b004156afd6843sm5076156wmb.18.2024.04.11.03.16.46 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 11 Apr 2024 03:16:47 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-block@nongnu.org, qemu-ppc@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v2 09/13] util/hexdump: Replace sprintf() by g_string_append_printf() Date: Thu, 11 Apr 2024 12:15:45 +0200 Message-ID: <20240411101550.99392-10-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240411101550.99392-1-philmd@linaro.org> References: <20240411101550.99392-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::22a; envelope-from=philmd@linaro.org; helo=mail-lj1-x22a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org sprintf() is deprecated on Darwin since macOS 13.0 / XCode 14.1, resulting in painful developper experience. Replace sprintf() by GString API in order to avoid: [426/1310] Compiling C object libqemuutil.a.p/util_hexdump.c.o util/hexdump.c:35:21: warning: 'sprintf' is deprecated: This function is provided for compatibility reasons only. Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead. [-Wdeprecated-declarations] line += sprintf(line, " %02x", (unsigned char)buf[b + i]); ^ util/hexdump.c:37:21: warning: 'sprintf' is deprecated: line += sprintf(line, " "); ^ 2 warnings generated. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- util/hexdump.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/util/hexdump.c b/util/hexdump.c index b6f70e93bb..2ec1171de3 100644 --- a/util/hexdump.c +++ b/util/hexdump.c @@ -19,7 +19,7 @@ char *qemu_hexdump_line(const void *bufptr, unsigned offset, unsigned int len, bool ascii) { - char linebuf[QEMU_HEXDUMP_LINE_BYTES], *line = linebuf; + g_autoptr(GString) gs = g_string_sized_new(QEMU_HEXDUMP_LINE_BYTES); const char *buf = bufptr; int i, c; @@ -27,30 +27,29 @@ char *qemu_hexdump_line(const void *bufptr, unsigned offset, len = QEMU_HEXDUMP_LINE_BYTES; } - line += snprintf(line, 6, "%04x:", offset); + g_string_append_printf(gs, "%04x:", offset); for (i = 0; i < QEMU_HEXDUMP_LINE_BYTES; i++) { if ((i % 4) == 0) { - *line++ = ' '; + g_string_append_c(gs, ' '); } if (i < len) { - line += sprintf(line, " %02x", (unsigned char)buf[offset + i]); + g_string_append_printf(gs, " %02x", (unsigned char)buf[offset + i]); } else { - line += sprintf(line, " "); + g_string_append(gs, " "); } } if (ascii) { - *line++ = ' '; + g_string_append_c(gs, ' '); for (i = 0; i < len; i++) { c = buf[offset + i]; if (c < ' ' || c > '~') { c = '.'; } - *line++ = c; + g_string_append_c(gs, c); } } - *line = '\0'; - return g_strdup(linebuf); + return g_strdup(gs->str); } void qemu_hexdump(FILE *fp, const char *prefix,