From patchwork Thu Apr 11 10:15:37 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: 787939 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp148843wrm; Thu, 11 Apr 2024 03:17:31 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUnZGPj9ZvUrkSfb4g+41Jk8viyOPnlBr8M0OzaOR95iy/5w4+aRlPA3mwNtmtOYzog3Qcq+pG2r7gkLV7i2oK/ X-Google-Smtp-Source: AGHT+IHfBGiKyO3MkZYiGyNVvddEjm1esrdqLUjn82I6lI8aya6C8HqzDmocMJx+jQsljOS6YoYO X-Received: by 2002:ad4:5be5:0:b0:69b:1cd0:e5d8 with SMTP id k5-20020ad45be5000000b0069b1cd0e5d8mr4237885qvc.22.1712830651698; Thu, 11 Apr 2024 03:17:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712830651; cv=none; d=google.com; s=arc-20160816; b=shCkG4df3KClPXwFMp9163Lk9P8iXEk1dh5Ad1aAlUb4Tu4++x17V6GOO95y/ljeXt Fgmeq7Y3u8BTUx0yBZ9eXu24TFuaOrF1nZAvJGlO5UcyQ093nk7EiSXgR1znllZs8BgO FoNcYfpL/RJqtInaim87hirDz7OYkMTqc4WiY7G7TTRx+mI9YKkJQukTVtbZGlzJwD0E YAcd2l5fD9P2MMP3t5Vg8R8zxSv7ppXraqM5QsP8wiFpehtgihd4+Bh05Tpb+HvjtSBE 3X144UodSuVqw8KJem+FlEdgrxgSgpBC9v4fsGOkZ//RqibyN+kTcCdiu7ygrZ3fEWnZ CsRA== 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=yioT4noxDvhbuL7egM0nA5pMTUC57Trd6rEmG3sDLks=; fh=nrO9NFjS9xx3FpRrmsadTA4JiiIct2qNO2tpnCWPNVk=; b=rfqm/Lx2KfyPkteZvN4KTZwBDdy6sE87/7BuEG2XZ5E32miynPnCjUF4kQr04iYhlZ 6+Jvqq/2ADdGU8FtqsT0dxERnGnYM7yXch1seB4hC48Sd5EC2gd9FLTnVtW1FVyJCftL bh9lk6UNGrP9iTjo6nt4OQILbbs6GIPd4T9IxmqYP9ziq2GkN2Uj/cjzKSPy8yt+xHRM SEH9KZitcyJvabVBEfvCPZeGbmnWS+TxIzZT432OdPEM3GmX9q4kQlNwU+9j41V/Jo2H Z0+/4ze0/XSGovoj8lB+Dkt0zzJR3u6eJpNoMUCnHSqJiK9vWUV5tldNMi/GDeVxONNd jiRw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RXlA8Nqf; 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 o16-20020a0cfa90000000b0069b3c259088si1146273qvn.567.2024.04.11.03.17.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 11 Apr 2024 03:17:31 -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=RXlA8Nqf; 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 1rurTn-00052h-1o; Thu, 11 Apr 2024 06:16:29 -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 1rurTV-0004xS-Up for qemu-devel@nongnu.org; Thu, 11 Apr 2024 06:16:12 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rurTO-0007SS-3s for qemu-devel@nongnu.org; Thu, 11 Apr 2024 06:16:09 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-41650ee55ffso30708675e9.0 for ; Thu, 11 Apr 2024 03:16:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712830559; x=1713435359; 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=yioT4noxDvhbuL7egM0nA5pMTUC57Trd6rEmG3sDLks=; b=RXlA8NqfCIRGixF6bIle6C3AdW0BdiJshvhBe5wRA2l3C552fBE9NNQL/nKckc1gAK zunU+pnppiCl1TCioE9iP3M5U/kgM4FEky0qnrFsOM3lWKNJMfoz6fffkpCzK9H7nCnk OuUpM3rbjfkjxsOACd8jYbIzhMBPaF/Mm8IixiKqjZxu3F6hECQ771mWzFvyKWfqa+2D wy8s+by1GIC/FkvQO2/1fZ78QvYRIMoBhBS+SkP0BuFuzHtwYgTyWweoQrwFNoYa8w5D TNXurcnEGIgrHTtexlgWmVx/A1Lf8Y7+RaaPCCq8BVa8CEyXMwrEbUMplz1d4QAt1L46 paFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712830559; x=1713435359; 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=yioT4noxDvhbuL7egM0nA5pMTUC57Trd6rEmG3sDLks=; b=o9eSYhudTVUO1gOaSACeq7YFsWa6Dg/VbPpPK7u0Hd0y/V4mghuA+ltSgbFIGlRGrh weab9g3rs5pBbnpa00Gg5SSlE+/4jwld1CCeKnwNOswHKFc5lxvqV/Sl8FD0DswWEMnB SabpzkFYjq/XflOpvOKQSpFRmsH74jw772S+fjhEHW2FHa/9U8yA9THj3yR9jZjdXbTR c5Oui/IuJ6wV5buh8Hxa85uM4B7UaWHn2rtC5giVs0Tvgu4pGxOB+o7BDOoMD3BdWT6c EEjwXGDXyck4qnG5t6WXbqJ8C9ebNvKXuLUlwqX89JZHpJEfVOM7orJXxVev8fC4KmxS OAKg== X-Gm-Message-State: AOJu0YznFsjwYcvB16z+VhEUrYCarvD//Dsl08sK/CAMA7l0Z+wHYJZg VHSy8rjPH+Op6ARpIkww1/7L78P9yLuclmoWKSf+yIQNJMkUvc6/knItonsSzRlUsj4U36QrbR4 u8RI= X-Received: by 2002:a05:600c:1d8b:b0:417:e090:4772 with SMTP id p11-20020a05600c1d8b00b00417e0904772mr654387wms.34.1712830558952; Thu, 11 Apr 2024 03:15:58 -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 u14-20020a05600c19ce00b004162bac1393sm1848952wmq.43.2024.04.11.03.15.57 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 11 Apr 2024 03:15:58 -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?= , Gerd Hoffmann , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Subject: [PATCH v2 01/13] ui/console-vc: Replace sprintf() by snprintf() Date: Thu, 11 Apr 2024 12:15:37 +0200 Message-ID: <20240411101550.99392-2-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::335; envelope-from=philmd@linaro.org; helo=mail-wm1-x335.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 snprintf() in order to avoid: [702/1310] Compiling C object libcommon.fa.p/ui_console-vc.c.o ui/console-vc.c:824: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] sprintf(response, "\033[%d;%dR", ^ 1 warning generated. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Marc-André Lureau Reviewed-by: Richard Henderson --- ui/console-vc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/console-vc.c b/ui/console-vc.c index 899fa11c94..847d5fb174 100644 --- a/ui/console-vc.c +++ b/ui/console-vc.c @@ -821,7 +821,7 @@ static void vc_putchar(VCChardev *vc, int ch) break; case 6: /* report cursor position */ - sprintf(response, "\033[%d;%dR", + snprintf(response, sizeof(response), "\033[%d;%dR", (s->y_base + s->y) % s->total_height + 1, s->x + 1); vc_respond_str(vc, response); From patchwork Thu Apr 11 10:15:38 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: 787938 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp148840wrm; Thu, 11 Apr 2024 03:17:31 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWL6LqPvwRopJvqzZg6RmQ4KjN4BZDwR6Rfbiqi37mtqcfurVHY3u0GFCQmv2qSAa5ZIzLcfMjeTGpMykE4EXnJ X-Google-Smtp-Source: AGHT+IE2rBKJUb/GzObJIy/wOU5rBdeovhLMTZSNLELu28HvarPMx/gsZkHbuMsV9R33jtIzwUqQ X-Received: by 2002:a37:e116:0:b0:78d:6845:58b9 with SMTP id c22-20020a37e116000000b0078d684558b9mr4891194qkm.22.1712830651462; Thu, 11 Apr 2024 03:17:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712830651; cv=none; d=google.com; s=arc-20160816; b=eFt4PE3XAlmUxY4y9JsPfIDdijTAyQv3t/cTMvoxMEH/G/NEG/tdFaoLIvGfXBa5+x oBFFHv1FJ3cSMXXlRP4hx7YBVqKrncarqvqIzj65W1PSF2PcJDfiPSDgjFgiiiw4PvQ8 4wqO2zyxrzOdHnUfyjOAFYUBWSLxc0XGMbp0MyTUm2gQyCro7RhUx1d2HymsF7B9iFUm ruevJA1fTILMDg4gia0iWKwU6oTNxnaV+CjuGLd1Efh0BcP2mZzIyTkf/ke4GPLsxuWO EH/rWL+8E4D6XO7r8SgT6Clxwjx/J13DsjZwBVZhm75hYkgZo0vd3aleGmDTmue3w0Zc 5DAA== 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=PBk/zsqMq62UHC2ppX+I9WzKRA310LNthTyLJkfCC3Y=; fh=/PllDMSTyjCYvesj3R6R8arE+9xF73MPrW03ygzeqXk=; b=tZyvjKQ4XIkx/jGpYFLO3PO0ijazo5btr5sLP8dtzAAmj9ARbdN4vGx6fNy+I3ZFuR jnhAr3VxIdksordJTkNqUZf2koP0dNkVZNBosyfNaRRo6bSAxXMiFgzv9adYNFyfAA/a 9oq7Wei/niPghPDIWd7vggy9yAryJoMHMnEcsfS71CWEg6N/zKk2XlzFN8onEfRBnNoV P9sdDuyG3pyAegyzyibXZ/OagclVN3mpbchZokMrbJRYcfdajDrz1Wnt7PvS/e23Vf6C L8eSKFCTKhPBOqr8KWB+FhF59Tv0rGpUyyXpORSSHNW77ld9kjQq/jtreEgrQBHuBaze 0BzQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=npx7zF3F; 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 dt19-20020a05620a479300b0078ec557bdd7si383229qkb.252.2024.04.11.03.17.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 11 Apr 2024 03:17:31 -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=npx7zF3F; 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 1rurU9-0005I3-HO; Thu, 11 Apr 2024 06:16:51 -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 1rurTX-0004zA-8U for qemu-devel@nongnu.org; Thu, 11 Apr 2024 06:16:12 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rurTU-0007Sz-Eq for qemu-devel@nongnu.org; Thu, 11 Apr 2024 06:16:10 -0400 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-346b94fa7ecso486168f8f.3 for ; Thu, 11 Apr 2024 03:16:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712830565; x=1713435365; 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=PBk/zsqMq62UHC2ppX+I9WzKRA310LNthTyLJkfCC3Y=; b=npx7zF3F+rNXSdjpahiHK5yvhRce660+KGKjQ7e3DCDJhppAReTnQaCYzTNIB7Q7MN LLGc8zLgCchOvVrvIdrPFzRRiwiH9BEEbuxwoGTxV2NW4gmn2Nz1sd7oNW9ZNwt3rTZz /58tsgUw6VFSjvuI+HElyIWReWo/KD201MbUogF/Wd+TL82RV/1kAQ5zxCwTpoBYliXJ j/vjrRXPQwnyaL3SKwYHflofOQRvSSbMCANULWrz5g5gbVqnLeVWOLlM+zmc9lMIOpiW j36+zXzv5iIZpLAA3grV+UOb7DfjX7GNc1JT5LU1QJGdE4gQRjLv76gZBbOhaqGwK/Bi iuNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712830565; x=1713435365; 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=PBk/zsqMq62UHC2ppX+I9WzKRA310LNthTyLJkfCC3Y=; b=vMI2TMI5+EmGvgfhB5EinR27EGvTYJUiQHgXObUnhdQcYihHXSkUeCYlEeSdH8bNuh LRZvjwAipz7a1G7rdXTAmgI1y2Seh+yqgwNney0CZE7kHXJZMi4IGZsxdoVBQwsWmq45 9pCNAzN8NqaNoqRvS3zHdfDrYbsXS4WPDnnJ7WzIolEmzs6tbp3UYT45oQ5CsD7fhNR5 n7FlFhc+2FFin094i6yvovlbbTTSHRzF4CepsJU155rK7yE9EBWocIbkPROTcE1arA6Y n908Pe1l281RvucQ80NHWQNY+eOXXNXTefAQ+vUMWhD7O6wxj0hBEUHxyQqq2Mv8aqUa R4jg== X-Gm-Message-State: AOJu0YwE61ZEl0XFmt0D0+gZIpeC8aoUHdCB33ajq0/FKhUA7W9/X2z3 ANK/FsxnX3eiu0lolBoBdF8EUkjcxG/mDLWTTTjDiYH8WUJLrVImU07dWooONDNPH8/56yqQuU+ SMdk= X-Received: by 2002:a5d:62d1:0:b0:33d:73de:cd95 with SMTP id o17-20020a5d62d1000000b0033d73decd95mr4629373wrv.17.1712830564945; Thu, 11 Apr 2024 03:16:04 -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 c6-20020adffb46000000b00346cdf48262sm658277wrs.2.2024.04.11.03.16.03 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 11 Apr 2024 03:16:04 -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?= , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goat?= =?utf-8?q?er?= Subject: [PATCH v2 02/13] hw/vfio/pci: Replace sprintf() by snprintf() Date: Thu, 11 Apr 2024 12:15:38 +0200 Message-ID: <20240411101550.99392-3-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::42e; envelope-from=philmd@linaro.org; helo=mail-wr1-x42e.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. Use snprintf() instead. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- hw/vfio/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 64780d1b79..cc545bcfbe 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -2444,7 +2444,7 @@ bool vfio_pci_host_match(PCIHostDeviceAddress *addr, const char *name) { char tmp[13]; - sprintf(tmp, "%04x:%02x:%02x.%1x", addr->domain, + snprintf(tmp, sizeof(tmp), "%04x:%02x:%02x.%1x", addr->domain, addr->bus, addr->slot, addr->function); return (strcmp(tmp, name) == 0); From patchwork Thu Apr 11 10:15:39 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: 787941 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp148951wrm; Thu, 11 Apr 2024 03:17:51 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXReZQT2yXZHehVSK0za6CsEQ+smYlAd8qcuoQKCteQas8cO9OTWf8izmmbKZ80cTKl1OFdpd+TaFjt3YhY4nKh X-Google-Smtp-Source: AGHT+IE0IysyUtePqvxZMUFxTHqGN/3BOlAt5XwyA3ANEKk4jrFEEEG2wkDFEUdlH1XJgzDmtgeK X-Received: by 2002:a05:6830:1204:b0:6ea:2d4e:dbba with SMTP id r4-20020a056830120400b006ea2d4edbbamr5329940otp.32.1712830671281; Thu, 11 Apr 2024 03:17:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712830671; cv=none; d=google.com; s=arc-20160816; b=whyBsQ5y65gxCI0UeS77p+ElTmVxCxxNvrux1QqwXed29wO6WKMKNseQEzm/rKn1dt cxl/hBwAIMGOriAOBz/6iBu+/s85cVSr/7N4r/0igXZW4x7bLrGD6v01T1Hr4Vev83h/ Msx/UjK9APwABbUPYrdzisgivxYGHOmj75yaDtJWQ+711sNRipKsB9vk1akPKVeZK4zL qM+aj9M2ykdc3qrimhI08IyH2A9fVJd0xrRFtyayEXu42gx61ajhb4Krc5E7Ty/SHIbf dpKfYd03qyx5XmmDC39g/6e7KFDEI+oOeHITix1TJNxwv3oDzpdsmmBd3QVAMYsFUVEd YiGA== 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=QTZuvbhwa5X7Gp0Pq7iX7voFgVp72I/Sgdu/HzqQ/kE=; fh=wcZhdQTQDei7o5frrq1qhU7sXHgTSgo1R5cwECyWQsc=; b=O8OqfCscy1nWrjHII44e15Xz99nvxXVDyfney4NqlbB/Fu6bNiAAz1wfryIrLtD8X8 FfMqGQz4Cvsmbq7fyHBshv5231RB1I0YYHcoVwmZ0xNBX5FGwU1geVTMcd50GNn2xEMq GsH6m4FeiUvYcQuDZe2Ybm2iQ8TO+3BekOHewMvZT3mWAeiIVIo9KyoBUilmFHJvos2f odxBdXSqBJ9ZYi5roS7FIuO9nSNG2lKqTiOfbKyoHYJakNe7f/Uo5ildtITJc2ex4vod AWC07NG4ukrrpUi64jFSsVKmQGEAKeMPwwXSn1cD+sUGWMvMw/ejQC4wz5uglP3xxC/N a4hw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SyxAlnpc; 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 x9-20020ae9e649000000b0078ec5576443si378390qkl.270.2024.04.11.03.17.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 11 Apr 2024 03:17:51 -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=SyxAlnpc; 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 1rurUp-0005mk-QX; Thu, 11 Apr 2024 06:17:32 -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 1rurTr-0005BY-2N for qemu-devel@nongnu.org; Thu, 11 Apr 2024 06:16:31 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rurTZ-0007Th-PT for qemu-devel@nongnu.org; Thu, 11 Apr 2024 06:16:30 -0400 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-343cfa6faf0so5804443f8f.0 for ; Thu, 11 Apr 2024 03:16:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712830571; x=1713435371; 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=QTZuvbhwa5X7Gp0Pq7iX7voFgVp72I/Sgdu/HzqQ/kE=; b=SyxAlnpcHcmxHRlyMKPfeDAkI7unqlP9K9hr3Dq/s7++WcvWO6HwFqNjkTpoHNoyca sea9ZyywPJvBbLgg+NdsyKec/R0TjcRjgBzfjUKpoDpiCV8Ljc18fPDtnTClDTEpjOxD fKij8LwKT77i3LiIWh87hXQvFsIASOJLZJkWGjsWNHurNstiF/D0E63l6iDz0/oZLGEX NXKSJPHE0HIvu/pemHuJ7TTWBtZgsGY+ygWj6FgwUKokHvNQUnhMxrg0hGd9T1Xw/cnn Z6u9w1580PUk2S/Aq9eN7NXrJajekSXTJ3pwInNXdNcwaRpxTq2Owba94VLUa/Sk16gW D/fQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712830571; x=1713435371; 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=QTZuvbhwa5X7Gp0Pq7iX7voFgVp72I/Sgdu/HzqQ/kE=; b=Examy/6egY86+8sgql39r1ovjDBrzp4ocUhBdBnGPsCixul+lzdYUMOepiHuhAQfPa IlkK4CSJjNBFhykaReYGX95suCkKudXzLqVP6TTNTKvu+BCCJvZhgXJ+jXA4VeeggO7V x2EJCQnWFLqhnbGkkPiGsittu0509Mwtzejl+ss6cJNyupAHjGLwRoJe0AjZ+ur83sfm n5AgXr0kYOTJ6lmj2TMSkOT4L0LeohNyAR6lo6gdzQqiqGnn0v97iVby5P65i7Ab6i+q p+duo7Vaeurl++OgcYhruS7LFc7NKZtqVhvJ63gtFZ/dWO9wYiatoAtPIkEOZuKl5m6W ar/w== X-Gm-Message-State: AOJu0YwyRsako0kgx0DFDToiTWpBAJUrJrs63H+XHise6MOgFlveQNkW C1Yha7oPCrf3uxVL9ylP/X9dW4hgiiY/SMzZOxItUOJLPUdde3+0QQnVQ7O6eiVAVTiAQ2zaaRK 7LaA= X-Received: by 2002:a5d:518b:0:b0:346:354b:b5b3 with SMTP id k11-20020a5d518b000000b00346354bb5b3mr4284657wrv.23.1712830571087; Thu, 11 Apr 2024 03:16:11 -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 c6-20020adffb46000000b00346cdf48262sm658460wrs.2.2024.04.11.03.16.09 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 11 Apr 2024 03:16:10 -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?= , Nicholas Piggin , Daniel Henrique Barboza , David Gibson , Harsh Prateek Bora Subject: [PATCH v2 03/13] hw/ppc/spapr: Replace sprintf() by snprintf() Date: Thu, 11 Apr 2024 12:15:39 +0200 Message-ID: <20240411101550.99392-4-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::436; envelope-from=philmd@linaro.org; helo=mail-wr1-x436.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, 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 snprintf() in order to avoid: hw/ppc/spapr.c:385:5: 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] sprintf(mem_name, "memory@%" HWADDR_PRIx, start); ^ 1 warning generated. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Reviewed-by: Harsh Prateek Bora --- hw/ppc/spapr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index e9bc97fee0..9e97992c79 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -382,7 +382,7 @@ static int spapr_dt_memory_node(SpaprMachineState *spapr, void *fdt, int nodeid, mem_reg_property[0] = cpu_to_be64(start); mem_reg_property[1] = cpu_to_be64(size); - sprintf(mem_name, "memory@%" HWADDR_PRIx, start); + snprintf(mem_name, sizeof(mem_name), "memory@%" HWADDR_PRIx, start); off = fdt_add_subnode(fdt, 0, mem_name); _FDT(off); _FDT((fdt_setprop_string(fdt, off, "device_type", "memory"))); From patchwork Thu Apr 11 10:15:40 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: 787940 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp148931wrm; Thu, 11 Apr 2024 03:17:45 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWn1b9J7KHXa4lBk7nP4QumHHUHJlS38JclrDYQlPy+Fv5HajGxUZ1KSLkvaH9e8GsMu/eiNlEwCX2j3zcgE8gJ X-Google-Smtp-Source: AGHT+IGFp8HUq1m3iqS+G3Qsr9WkoXhFjP7pT9Ici6C9SHU28ZavlxSYiXe+hzsMm3axpmiKQE1b X-Received: by 2002:a25:8d0b:0:b0:dcd:aee6:fa9 with SMTP id n11-20020a258d0b000000b00dcdaee60fa9mr5338542ybl.53.1712830665128; Thu, 11 Apr 2024 03:17:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712830665; cv=none; d=google.com; s=arc-20160816; b=TFuujpnScJEeDRjUcuc4dQYzvAxfA/4ZN+ficUmNkey1xAmoZUNmz8p9hdEDDWM0QG hLLsFs57GsjKubbeI5eM/EInC9ux+S2QznwiaFXWopFEPgPUdRBrEjb/LLqe8+nl6+KT AcPMhhXtjxUHXRfClhWKIEKKOdr/N7wRbBeA8oLLPWIFFbx53T+fHwYYrISm4PwtGB2B Mkin4iTYJib8oLIEwPeUKBpdpJFUnp5DqJOPS7Nl1ClVtn6qcaDa2nzzddgR28LD68bk /dPZila3bWLBJ6u/i/Yd2vwg5Eixk4evEnSBqXrw+MU+GVrB8UAOI/Fmo2m6Uhq82EDb kAuQ== 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=4MCcGHhKA7wPhoBY3l6p9Olu+doueLftUh6GAPbrfFo=; fh=pz1yopd/wrdYlGtYXbhy+U1KH6qXkA5iyTnaoXfRYpE=; b=QGy1/F8hq/JmjFQRsfPXD7kqdnQtOn/8RyD/7rh5Rl8sqDLtXKu6YhirWiOOqLALuy 2QkSWnI68rPUo5fJ3U/jZUskGqJhONa1Yt3cBtImzrmMDCqAK4bs+RsYoodrnIYJt5en 6jYbfgyz9Ptp+B+xADD1zeZm014obrU6sxobinYY5czHbgGqWk48pDDMyt4Lv0MtI6sg 8q4Az9jt5caiCqCAdH8KS+BNOhdTpYbUht1S+FJHGR0kGwmSAJcK4bFKdewwvLfSC6KU F9WYcTHrZxAMytL2J5Ioo2hsItKUSx3LetNf8IaN7QqgfoMPPol4mE3ZhxzyGyA4NCxh wuHQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OSb52WSY; 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 x12-20020a0cfe0c000000b00699477fc5b3si1124377qvr.211.2024.04.11.03.17.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 11 Apr 2024 03:17:45 -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=OSb52WSY; 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 1rurUK-0005JV-1d; Thu, 11 Apr 2024 06:17:07 -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 1rurTp-00058u-5a for qemu-devel@nongnu.org; Thu, 11 Apr 2024 06:16:31 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rurTg-0007UT-1O for qemu-devel@nongnu.org; Thu, 11 Apr 2024 06:16:28 -0400 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-34665dd7744so1303453f8f.1 for ; Thu, 11 Apr 2024 03:16:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712830577; x=1713435377; 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=4MCcGHhKA7wPhoBY3l6p9Olu+doueLftUh6GAPbrfFo=; b=OSb52WSY0B2mZTlTPa51sMidfmq+eaI6IArXxnW6ZQBxwoqvhQP5jryhgCXSXQc8PL p/lBeOKhVGgbQRll8N0Fb3EiunFeqMiXsOnxGrIkeyDGji2xjyc6oAQ/CGJJ5eRCADNA u2XxT1q4+lFAx68Hfp5tQ4MqgwvRjh1OIVGiRXVAXc5xzs6xyw1IJBaBiQ8h3zlvjlSw L6hJr3dwWdIHfs4/GTloxSeJS/LWOkTIjadIxUtAhQvHpjfGSSiT1rMAVe7Eu1lxs4uS 07wGXhtecaogZBZkVFridO2JiUWf0KYI+EXexT/CcUytBuqttjzDuVntNEXCY6nAiFQ5 7a6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712830577; x=1713435377; 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=4MCcGHhKA7wPhoBY3l6p9Olu+doueLftUh6GAPbrfFo=; b=CW8L/GFP99C/gWgff8wOX5SNkYfoMIaJroOJVHNkeCosRxDGJ6jsxKVJlrS+ndlXkV 7zer7J5FmxTl/rb+9fbkWweeoQOWSuMcikgCOdEx6qCWssrhW0yBCrjCKEoSMzjy8po4 aIQQMndp9Kd4ThIevojyE2ii8b2JsayR/pbb3tR1VsZFPTXjZmI6dHOLsXd+uEb+cJbs SSNGa/HKVqB6peVlXI/3yT1zQbHOQPEicCng61434fFcXbvM5ZRMZe16cWM1AVr4HHNs p7hHG86vAXjFe3BpIYNkXYXZ8JYgE/gaLN5WG6sJpPmLhLPnpujwAC7HsnGTzvmExDkh UACQ== X-Gm-Message-State: AOJu0YwwIPQsOi2874+4V3TjT/a38LP3PYs3FjcSLYHRX+KsUo/dIPzl TnIUZ9DSTS/0zT02pknOHj+2GiuJqcu+indGDX1JxemwbSOFM1usFi4YuWNBHKu7M8BgQnpJoMl zrEE= X-Received: by 2002:adf:e702:0:b0:346:305c:d34a with SMTP id c2-20020adfe702000000b00346305cd34amr3676036wrm.20.1712830577088; Thu, 11 Apr 2024 03:16:17 -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 dl5-20020a0560000b8500b00345fb949c28sm1404822wrb.100.2024.04.11.03.16.15 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 11 Apr 2024 03:16:16 -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?= , Aurelien Jarno , Jiaxun Yang Subject: [PATCH v2 04/13] hw/mips/malta: Add re-usable rng_seed_hex_new() method Date: Thu, 11 Apr 2024 12:15:40 +0200 Message-ID: <20240411101550.99392-5-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::436; envelope-from=philmd@linaro.org; helo=mail-wr1-x436.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 Extract common code from reinitialize_rng_seed() and load_kernel() to rng_seed_hex_new(). Signed-off-by: Philippe Mathieu-Daudé --- hw/mips/malta.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/hw/mips/malta.c b/hw/mips/malta.c index af74008c82..9fc6a7d313 100644 --- a/hw/mips/malta.c +++ b/hw/mips/malta.c @@ -850,15 +850,24 @@ static void G_GNUC_PRINTF(3, 4) prom_set(uint32_t *prom_buf, int index, va_end(ap); } -static void reinitialize_rng_seed(void *opaque) +static char *rng_seed_hex_new(void) { - char *rng_seed_hex = opaque; uint8_t rng_seed[32]; + char rng_seed_hex[sizeof(rng_seed) * 2 + 1]; qemu_guest_getrandom_nofail(rng_seed, sizeof(rng_seed)); for (size_t i = 0; i < sizeof(rng_seed); ++i) { sprintf(rng_seed_hex + i * 2, "%02x", rng_seed[i]); } + + return g_strdup(rng_seed_hex); +} + +static void reinitialize_rng_seed(void *opaque) +{ + g_autofree char *rng_seed_hex = rng_seed_hex_new(); + + strcpy(opaque, rng_seed_hex); } /* Kernel */ @@ -870,8 +879,7 @@ static uint64_t load_kernel(void) uint32_t *prom_buf; long prom_size; int prom_index = 0; - uint8_t rng_seed[32]; - char rng_seed_hex[sizeof(rng_seed) * 2 + 1]; + g_autofree char *rng_seed_hex = rng_seed_hex_new(); size_t rng_seed_prom_offset; kernel_size = load_elf(loaderparams.kernel_filename, NULL, @@ -946,10 +954,6 @@ static uint64_t load_kernel(void) prom_set(prom_buf, prom_index++, "modetty0"); prom_set(prom_buf, prom_index++, "38400n8r"); - qemu_guest_getrandom_nofail(rng_seed, sizeof(rng_seed)); - for (size_t i = 0; i < sizeof(rng_seed); ++i) { - sprintf(rng_seed_hex + i * 2, "%02x", rng_seed[i]); - } prom_set(prom_buf, prom_index++, "rngseed"); rng_seed_prom_offset = prom_index * ENVP_ENTRY_SIZE + sizeof(uint32_t) * ENVP_NB_ENTRIES; From patchwork Thu Apr 11 10:15:41 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: 787947 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp149200wrm; Thu, 11 Apr 2024 03:18:35 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVghD72VtQaRWaVAszX+g/zcD8z8nat7MRioks1JsR4qYKdyJF82mRBVwMSlYpllCUr0NpiN3a8rBz9Og5V/LK9 X-Google-Smtp-Source: AGHT+IEaMCH2Rb1RsIVlwfNQCcg3RuNQM8oE8SXNEJnfbcElxKptRBTKPn4O0TdZwyIE+Do52ZLw X-Received: by 2002:a05:622a:19a3:b0:432:b84a:826e with SMTP id u35-20020a05622a19a300b00432b84a826emr5153589qtc.35.1712830715189; Thu, 11 Apr 2024 03:18:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712830715; cv=none; d=google.com; s=arc-20160816; b=lxY309GajLdM/5iw0t5Lpqj2LtVwhWMrL90qXGMKwwlKerYKiNKAPu6gVR2idcqHmi 6Z45YzI6FuRf3NABOMxAS6KxQVamIOSC90hmoiOqaPCTajrlyz2mmDFJrQv0pJuLRBMd HLr7qWtXxT1ZSeLSl7f5coZHGgKL848cPhdm7d+hiZA8EAzoedW3vwNeZXrVax68I/4m Vky1guLo5KMKafIXrYLxGV5P+DEpyl6Q+762VAfxb06mbz1ns8JkoZ1q5y9iCv3uJGY0 mSVAGYoS30NlAk51UTXSw1Jr5hwCAzpncFzWz5FaSCspD+R1i/bit9Vh/MGkjMx0ORoE IwnA== 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=TngF+9Flkc8Ihe+8OkjidPkiP1940GOGXxohU6xSHFo=; fh=pz1yopd/wrdYlGtYXbhy+U1KH6qXkA5iyTnaoXfRYpE=; b=BdCwtRTUT3LG9jM3H8LDUbIu/ZVqNK57oeOqSpocooeL37DvmYfnfHwhyBCfIST7vh 365aMmtzsAnzNJHiEk+chnRnpodf604R8QfGHuxAO0oLIHjoiflqSIkeNDOt0KIJYmRb /zLP6M0S/arYhqQ6LizweFuzeeVxrzNY9XwjFnWRzlL7qo6jAcDgMnh3j2D2f8STUZ4o WNPFaN0pFcoyVnrS18857n11FnHW3/f6lKeesL9qlrI+fSmF5Gj5SAy6lwTsCgtTPZ9B saKnFDgS+thym1cR92yomSWncAX1aaaslQSKZy1gSBOpM3fJUPiuypcQq4IlMIfx+LkW +bCw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Bvd2d0jI; 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 a21-20020a05622a02d500b004343f236d85si1157603qtx.702.2024.04.11.03.18.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 11 Apr 2024 03:18:35 -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=Bvd2d0jI; 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 1rurUw-0006BR-0p; Thu, 11 Apr 2024 06:17:38 -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 1rurTr-0005Bk-Vm for qemu-devel@nongnu.org; Thu, 11 Apr 2024 06:16:32 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rurTm-0007V9-5E for qemu-devel@nongnu.org; Thu, 11 Apr 2024 06:16:31 -0400 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-343c891bca5so4897311f8f.2 for ; Thu, 11 Apr 2024 03:16:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712830583; x=1713435383; 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=TngF+9Flkc8Ihe+8OkjidPkiP1940GOGXxohU6xSHFo=; b=Bvd2d0jIKuuWpq3aXGxTREH3PuavjFdc9GOPgWMGu230MvDukKBJnYPFDudeQfhCYR uVCxh2Vje6zy6Iaopn1Zo7dFHUkPQzYMlbOJ0c1jbM9MDtWj33M845foy3XFlqYlDeu8 IxAaGgIhPesPMiWNRpyaz8a2XapDd1/EEZzt1RBSnJCNnvj6koX/iv5o5DHc0pf1fPPt Q9QTOoRe8U5dh614w26Vu+CmJvVQdUGRodYO83WIHkBje/yHetopp3B96CM7J7LRKDCG nIrNQBkDJmfvTTFOzN7qvsATe/jK04HwoZIwUceriia9qHF2JMjNvOruqg65Cn5rRajA VwaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712830583; x=1713435383; 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=TngF+9Flkc8Ihe+8OkjidPkiP1940GOGXxohU6xSHFo=; b=RFM3yINGsKeR0DT0SHPcNowVj+hDUOE1COg6OwSH04qC9/GfLJfyzUs0Pol1Qbdtbd lQOHYX1V9kJjM1xd9LeNXYTSL8C4i8Lk0UlttdpOV7vo/4Ga/oPixDxcL9NR4ocdZD3z X+eAFRRG490IP7w8fiuqkPopJJ0KkkjiayGkH/LGhH2FSC9PjbVdgh53Tq4LQWiPXL1H sZZ4L9yDvtS/gXTs4ga5Qb/ea56vo2pIuFpdAQPfPjP51rLd/o0H7bBtWycErcygBYrv xmZ3vf6fysp2dJXN/iSx4XBqt6ClqWmsvFGDwJr2LEYQsVHF+b/Y3nKVF21NWRBmd9XE 6THQ== X-Gm-Message-State: AOJu0YwU9TUqowG3KMY9r7hszvwNLYmH77xFzNmV+O6c4eQWoxA/9wa3 5SiQ2CUOG3VS8deQQPVFEnXC734YlxJQDMMftcVA69FaPn+T83d2RzlvfBoadepXfMJ8fYLVWZx GwCg= X-Received: by 2002:a5d:644b:0:b0:341:66c2:3dbb with SMTP id d11-20020a5d644b000000b0034166c23dbbmr3737072wrw.30.1712830583121; Thu, 11 Apr 2024 03:16:23 -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 u7-20020adfeb47000000b0033ec9ddc638sm1413671wrn.31.2024.04.11.03.16.21 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 11 Apr 2024 03:16:22 -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?= , Aurelien Jarno , Jiaxun Yang Subject: [PATCH v2 05/13] hw/mips/malta: Replace sprintf() by snprintf() Date: Thu, 11 Apr 2024 12:15:41 +0200 Message-ID: <20240411101550.99392-6-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::429; envelope-from=philmd@linaro.org; helo=mail-wr1-x429.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 snprintf() in order to avoid: [120/169] Compiling C object libcommon.fa.p/system_qtest.c.o hw/mips/malta.c:860:9: warning: 'sprintf' is deprecated: sprintf(rng_seed_hex + i * 2, "%02x", rng_seed[i]); ^ 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] Signed-off-by: Philippe Mathieu-Daudé --- hw/mips/malta.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/mips/malta.c b/hw/mips/malta.c index 9fc6a7d313..5d33aa5123 100644 --- a/hw/mips/malta.c +++ b/hw/mips/malta.c @@ -857,7 +857,8 @@ static char *rng_seed_hex_new(void) qemu_guest_getrandom_nofail(rng_seed, sizeof(rng_seed)); for (size_t i = 0; i < sizeof(rng_seed); ++i) { - sprintf(rng_seed_hex + i * 2, "%02x", rng_seed[i]); + snprintf(rng_seed_hex + i * 2, sizeof(rng_seed_hex) - i * 2, + "%02x", rng_seed[i]); } return g_strdup(rng_seed_hex); From patchwork Thu Apr 11 10:15:42 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: 787949 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp149998wrm; Thu, 11 Apr 2024 03:21:12 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWAQ4Xrfo5EkNPU/l5RXx0pf0/ujBfCyc0xfPYo0Sk0rehNi0qPgFcQVlcvWJtE51pOMXP+uo3l9qxm6sXCj+L2 X-Google-Smtp-Source: AGHT+IGhhRve4lcPh3XB9BpWXhRXingN3YaIlixR6Vvp8fB00xDriEVK+So0ypcr0wbUWWWYKOBI X-Received: by 2002:a05:6214:2d04:b0:69b:432c:3004 with SMTP id mz4-20020a0562142d0400b0069b432c3004mr3681149qvb.11.1712830872566; Thu, 11 Apr 2024 03:21:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712830872; cv=none; d=google.com; s=arc-20160816; b=bw8+nl0mjvQCQR6QgPZyw/OPePyubFxSInOR8eSPPxqcCBcRnE3lh87DhZntK5Rn1t xBzKtJcy8M3RyJfvZWmcDAFgWjHR4xi809S8gwXHKP7k4Ml7XHXvoIXP6BQJxKP4whVO F3M6FnrpO7bjs6qXmos7Y0WwKzlmr+e+Fjh8TxbXmY1sJ2i7C6sZskw/CndIOoQ9RZ04 ZBo6Jh0l5nLxFOKpI8H9VShbRfCG2/o9rwxsaD/DEeWLYtAUjXQHR/PKlWnxkamDULt3 o8Di+VveelfGz8VRwGe7kS3moTA+Bf6zpinztD72787VdP3jXwVuCHBuX68rQ7Y5SDkz 9bHw== 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=0NkZbdhuZimuvYHJRoYOcJ4m476kCV6CLgO0HzeNjj0=; fh=26SfYfEj+utkPiFaGsK8WBn3XLLjCJh8H8HBQX0FJ24=; b=qHu4wQYgMHGk5RFBZUF889RAJPGrOnie6nw4ld46j9zC7u05T0sUC1QYOHWUvdmmxV V+7gu4A5pvyxF9PhgIRuSMF9NHvsWaCCT2ZvuNpfEBOYQ6qak8FSeiYfXiCCf5+6D8Dp ggqO0iQICE93ZhdYkMQ4eWF1GmDYqtGqfow2krs0B8TLK4pw5NBfq0oOlu/NQnM2EdnL inUxTaH1cLueFVu1AOQ4z/L6NdwSr7vzMnaP7BsJz5NZ4qWAq9XYukaSaIxTjHiGRNfF OtTQNSohOb6fVOGDI+PluP3kk342nUpas1Xa7POgw+Kj1/0dx657Z70GUEhkJ/iAKL9x N9jw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="wQxCVpM/"; 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 de15-20020ad4584f000000b0069932d2b5e3si1127775qvb.398.2024.04.11.03.21.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 11 Apr 2024 03:21:12 -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="wQxCVpM/"; 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 1rurUt-00065h-D9; Thu, 11 Apr 2024 06:17:35 -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 1rurU1-0005GF-Iz for qemu-devel@nongnu.org; Thu, 11 Apr 2024 06:16:42 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rurTu-0007W7-KM for qemu-devel@nongnu.org; Thu, 11 Apr 2024 06:16:40 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-416c3aca500so14249375e9.3 for ; Thu, 11 Apr 2024 03:16:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712830590; x=1713435390; 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=0NkZbdhuZimuvYHJRoYOcJ4m476kCV6CLgO0HzeNjj0=; b=wQxCVpM/tsYxZblIZozkm4q1DN38xsPQGDxCvZ/LWsfnrjZmLFdc3Bmz/InSAlBuOl WSSOlBHgqsCdTq9J0gd3/6+X6eHdDbvRT18KtjJQQhtrThT+VTCkKevSEfLTRhSiwLf0 26vece0JrNTX0aFxfO4ZX7IH1qD8e3KLW8VhwNCTtRwlpQCUjpXF6ampdmJwgPR9RWRf 2FsX0Aus4ZAHSERlEUuuEEJba1NGrjYtFfH7qAwpx5v3WmGI+QIM/GeLgJ4cYavRazTR 5JariKb09vxVvWzJZZ5INsijJjHfmeJZmq5XY0DnF7q7di9mYRnkqIuGnO9NgWxUhLSD AyJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712830590; x=1713435390; 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=0NkZbdhuZimuvYHJRoYOcJ4m476kCV6CLgO0HzeNjj0=; b=jfAsnxbrtzpLwS2DqPCH7QX1Cf/2532cNCe/AjoNEzoFXuStEYrmHjObvwbIFmhOcO 2bBAvwSbIMlKDvS2Z1aT77BWHUdeU1z0GlGsn+Q504JVimSt5m69+HM5AXjS3DoIPGdS M8hPNv/WUHVwsJVT2vYcmSDC7v0JopQcByR9wNIJ40klFLPxEkdA4OU8w++z7dD//fPi f8/1+YzMWeNY9lBy9i1n56hlWm+1ZTx2bETnF5KUojWB6w7gJ25vjsmxDfcGkLlA2cPK z5eoMLw/xLn/2SDa7GFWMBTNchz6mg9Mi9wsh4O+jlAlfQAgQsa+FS1GOk2bAJ3HVzrD WtYg== X-Gm-Message-State: AOJu0YyYrQ7bDMUzRuCdZ1n+b/kC3G/I7jofM5+kd6vYPab6863Xa+st 6PpElPFGnkSGb0UTeN9qjn+pDb0c4N4FLJyThEapalWf9QCU0PnO8BAFbJxdZ0+eK+pbmXMo6e1 /Hnc= X-Received: by 2002:a05:600c:468f:b0:417:d75f:fb4 with SMTP id p15-20020a05600c468f00b00417d75f0fb4mr1182890wmo.10.1712830590481; Thu, 11 Apr 2024 03:16:30 -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 i7-20020a05600c354700b00416aca5ff66sm5046906wmq.19.2024.04.11.03.16.29 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 11 Apr 2024 03:16:30 -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?= , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PATCH v2 06/13] system/qtest: Replace sprintf() by g_string_append_printf() Date: Thu, 11 Apr 2024 12:15:42 +0200 Message-ID: <20240411101550.99392-7-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::335; envelope-from=philmd@linaro.org; helo=mail-wm1-x335.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, T_SPF_TEMPERROR=0.01 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 uses in order to avoid: [120/169] Compiling C object libcommon.fa.p/system_qtest.c.o system/qtest.c:623:13: 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] sprintf(&enc[i * 2], "%02x", data[i]); ^ 1 warning generated. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Thomas Huth Reviewed-by: Richard Henderson --- system/qtest.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/system/qtest.c b/system/qtest.c index 6da58b3874..22bf1a33dc 100644 --- a/system/qtest.c +++ b/system/qtest.c @@ -601,9 +601,9 @@ static void qtest_process_command(CharBackend *chr, gchar **words) qtest_send_prefix(chr); qtest_sendf(chr, "OK 0x%016" PRIx64 "\n", value); } else if (strcmp(words[0], "read") == 0) { + g_autoptr(GString) enc = g_string_new(""); uint64_t addr, len, i; uint8_t *data; - char *enc; int ret; g_assert(words[1] && words[2]); @@ -618,16 +618,14 @@ static void qtest_process_command(CharBackend *chr, gchar **words) address_space_read(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED, data, len); - enc = g_malloc(2 * len + 1); for (i = 0; i < len; i++) { - sprintf(&enc[i * 2], "%02x", data[i]); + g_string_append_printf(enc, "%02x", data[i]); } qtest_send_prefix(chr); - qtest_sendf(chr, "OK 0x%s\n", enc); + qtest_sendf(chr, "OK 0x%s\n", enc->str); g_free(data); - g_free(enc); } else if (strcmp(words[0], "b64read") == 0) { uint64_t addr, len; uint8_t *data; From patchwork Thu Apr 11 10:15:43 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: 787948 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp149974wrm; Thu, 11 Apr 2024 03:21:09 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXHjifcEhG1Vk0fsAaJIzrlahD2ZS5GNi9Ntp4WKT6b9/D4gyZF6A88ujy6PDPY7ORtDQsVfBNA0BCqD1deDYQo X-Google-Smtp-Source: AGHT+IEP4vsk3LIKZIUaeylLNRyPs/M6crd3HALRkZ2pX0rtXfEpY2Ncznc/IodaG9t9CBbE5UfN X-Received: by 2002:a05:620a:172a:b0:78d:4fee:62d7 with SMTP id az42-20020a05620a172a00b0078d4fee62d7mr7037493qkb.9.1712830869040; Thu, 11 Apr 2024 03:21:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712830869; cv=none; d=google.com; s=arc-20160816; b=Cfnk57p/iT0mV2l0MSUUy87M6anO6lf2G3WK0/lsKrXf1sTem1jJXm7Z1lrtpZu2Cl VbDWyUbqBitUg9/r1w3A7nUFEZjT94dHDm6RngOD3EZ1/G2Qe08oqnrhWorm3neTg2Hn lGKsuN6TQGecOFmHFb8RYX4dSUKWwken+semLNEMhfHqOdKKsWjc2kLll0Dwj1/v8vL4 m+20BDAIFCHghk2w/eGac+lmG7ab9v8IFK0tkoggK2j24vasbnLfqxawaoQH6srdXruZ NoUuxR/mZD6FFn5uAJ2Q+dB7sTmnL1oQU92qCk5ie3ZhXTqaKrpVDN6wcI8QusCNF2/x aZFA== 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=F1NpFpUrBWuL7lYE+0KLDn2ZH8pFKE5VoepA/3Vy6uc=; fh=wiz1UHo9SeP7cKsyv7qV5qfZpy+eOFaJKdMduwsqX+g=; b=rsnONjtO2jnudaizA2cTwFYPLOVPjD/KgO5eE5OxNB07+at4qMlVXtRyAMiyVc4XKL TSeLJ3FpCB1eiVwEDhXKEQAjzGtD8HjjCAq43UzudAXCxNRfg7ALzzzfrEP16MdMZfMe sC1hixybtcUu65ukBL6BwzSuM+cifsUosve44Y9wJmhPmEWKu/Jq0TpOzOhEB2A4arNH sPQMrTe3pYMN/jRTvWgbzHDDS89o7Adcy1hMBjz45CO2dtdnEJ5lfBxdKoE4+MRYmOMk jJ5Pv4tFOvnKO1C8lfznsB7kOUhpyEQpJhN0fp2Ql7uqGK3bwB36+mdMx6EcdTNEIkxi 8H/w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bqWxbHYm; 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 dt46-20020a05620a47ae00b0078ec4858ad7si485990qkb.670.2024.04.11.03.21.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 11 Apr 2024 03:21:09 -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=bqWxbHYm; 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 1rurUt-00065k-EZ; Thu, 11 Apr 2024 06:17:35 -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 1rurU8-0005Ig-GL for qemu-devel@nongnu.org; Thu, 11 Apr 2024 06:16:49 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rurTz-0007X5-JE for qemu-devel@nongnu.org; Thu, 11 Apr 2024 06:16:48 -0400 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-343f62d8124so4196147f8f.2 for ; Thu, 11 Apr 2024 03:16:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712830596; x=1713435396; 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=F1NpFpUrBWuL7lYE+0KLDn2ZH8pFKE5VoepA/3Vy6uc=; b=bqWxbHYmOd1JWL1B1rM2r0OISujofCgTs0ans5zEtEhsPecQWJIKbbMRPRK2F2pRdl VwmcwGkGMw8LJTs/WoUfc9A9KgtBoeMifr6GaRJVmdK5toE2UsjbUkowam/3nTXUvTw2 MK2Jy+eWMMahZi9f32Ataaq87sGEN60EzyJssIdlt0vfjzJa2wQtfM3tHeUY1wXBmfRG R4j0NIqf5Vt8UhyKFCYRqlxy9kZGnIMTDHfVFMlXe98H0pfAYr72huj/L5wAmzykiyxL ky8FCdKOd4+AWXoUKWcA35GHwZWUQGromgyxsUtEHYsH84hzOTHS+dQ+X0HKAJlXXDDh sirQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712830596; x=1713435396; 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=F1NpFpUrBWuL7lYE+0KLDn2ZH8pFKE5VoepA/3Vy6uc=; b=XPsda1wrZn7tHQKIwdYD3cymh5oTosWEUPbCGHQPrgxJAdD6LUtYi/Z1AGC15WcAzz LnIdwn9ies/NfpvEPzU8w4mY6eBllBgJmbze+nfGVUIcJHwRn26OglOJZdOrPBWIP/D/ PZGQoCmNLHkwtgS3KnyTE0It/zGaF0ULE0C0N6CfSz3E+xqUlG+wap6U+q2dRIXWeKFh GOCF950CxBjhvkC/V2pVFWP9VvYLauZMhB67fAkabFJlNpsPI4vssshCmjxAC1pmoBuK Usgo6bxeCIXJmTRWVaMgAW5mZa6ZNOQR6GFPdowXbKZtMCgdUZc1D1yXHpfQ0mQWtqWX m1Jw== X-Gm-Message-State: AOJu0YzZ1zHi4DgpM0hgM6Ur56Hb5OFZ90ymvjPNePykE+/hko5jYkEb RsYzJArhCsunALJVGQ6gsbz+uqzV45J1D/dsJ2MqDi3YUur8Vgke6c1QRn8eRNVP034JjOgTZIM f6rk= X-Received: by 2002:a5d:5609:0:b0:346:9903:d10f with SMTP id l9-20020a5d5609000000b003469903d10fmr1969474wrv.12.1712830596342; Thu, 11 Apr 2024 03:16:36 -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 bl40-20020adfe268000000b00346d886f3d8sm318488wrb.16.2024.04.11.03.16.35 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 11 Apr 2024 03:16:35 -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?= , "Michael S. Tsirkin" Subject: [PATCH v2 07/13] util/hexdump: Rename @offset argument in qemu_hexdump_line() Date: Thu, 11 Apr 2024 12:15:43 +0200 Message-ID: <20240411101550.99392-8-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::433; envelope-from=philmd@linaro.org; helo=mail-wr1-x433.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 @offset argument is more descriptive than @b. Inverse @bufptr <-> @offset arguments order. Document qemu_hexdump_line(). Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- include/qemu/cutils.h | 11 +++++++++-- hw/virtio/vhost-vdpa.c | 8 ++++---- util/hexdump.c | 16 ++++++++-------- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/include/qemu/cutils.h b/include/qemu/cutils.h index 92c927a6a3..70ca4b876b 100644 --- a/include/qemu/cutils.h +++ b/include/qemu/cutils.h @@ -252,12 +252,19 @@ static inline const char *yes_no(bool b) */ int parse_debug_env(const char *name, int max, int initial); -/* +/** + * qemu_hexdump_line: + * @line: Buffer to be filled by the hexadecimal/ASCII dump + * @bufptr: Buffer to dump + * @offset: Offset within @bufptr to start the dump + * @len: Length of the bytes do dump + * @ascii: Replace non-ASCII characters by the dot symbol + * * Hexdump a line of a byte buffer into a hexadecimal/ASCII buffer */ #define QEMU_HEXDUMP_LINE_BYTES 16 /* Number of bytes to dump */ #define QEMU_HEXDUMP_LINE_LEN 75 /* Number of characters in line */ -void qemu_hexdump_line(char *line, unsigned int b, const void *bufptr, +void qemu_hexdump_line(char *line, const void *bufptr, unsigned offset, unsigned int len, bool ascii); /* diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index e827b9175f..cf7cfa3f16 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -941,12 +941,12 @@ static int vhost_vdpa_set_config_call(struct vhost_dev *dev, static void vhost_vdpa_dump_config(struct vhost_dev *dev, const uint8_t *config, uint32_t config_len) { - int b, len; + int ofs, len; char line[QEMU_HEXDUMP_LINE_LEN]; - for (b = 0; b < config_len; b += 16) { - len = config_len - b; - qemu_hexdump_line(line, b, config, len, false); + for (ofs = 0; ofs < config_len; ofs += 16) { + len = config_len - ofs; + qemu_hexdump_line(line, config, ofs, len, false); trace_vhost_vdpa_dump_config(dev, line); } } diff --git a/util/hexdump.c b/util/hexdump.c index 9921114b3c..469083d8c0 100644 --- a/util/hexdump.c +++ b/util/hexdump.c @@ -16,7 +16,7 @@ #include "qemu/osdep.h" #include "qemu/cutils.h" -void qemu_hexdump_line(char *line, unsigned int b, const void *bufptr, +void qemu_hexdump_line(char *line, const void *bufptr, unsigned offset, unsigned int len, bool ascii) { const char *buf = bufptr; @@ -26,13 +26,13 @@ void qemu_hexdump_line(char *line, unsigned int b, const void *bufptr, len = QEMU_HEXDUMP_LINE_BYTES; } - line += snprintf(line, 6, "%04x:", b); + line += snprintf(line, 6, "%04x:", offset); for (i = 0; i < QEMU_HEXDUMP_LINE_BYTES; i++) { if ((i % 4) == 0) { *line++ = ' '; } if (i < len) { - line += sprintf(line, " %02x", (unsigned char)buf[b + i]); + line += sprintf(line, " %02x", (unsigned char)buf[offset + i]); } else { line += sprintf(line, " "); } @@ -40,7 +40,7 @@ void qemu_hexdump_line(char *line, unsigned int b, const void *bufptr, if (ascii) { *line++ = ' '; for (i = 0; i < len; i++) { - c = buf[b + i]; + c = buf[offset + i]; if (c < ' ' || c > '~') { c = '.'; } @@ -53,12 +53,12 @@ void qemu_hexdump_line(char *line, unsigned int b, const void *bufptr, void qemu_hexdump(FILE *fp, const char *prefix, const void *bufptr, size_t size) { - unsigned int b, len; + unsigned int ofs, len; char line[QEMU_HEXDUMP_LINE_LEN]; - for (b = 0; b < size; b += QEMU_HEXDUMP_LINE_BYTES) { - len = size - b; - qemu_hexdump_line(line, b, bufptr, len, true); + for (ofs = 0; ofs < size; ofs += QEMU_HEXDUMP_LINE_BYTES) { + len = size - ofs; + qemu_hexdump_line(line, bufptr, ofs, len, true); fprintf(fp, "%s: %s\n", prefix, line); } From patchwork Thu Apr 11 10:15:44 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: 787951 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp150036wrm; Thu, 11 Apr 2024 03:21:23 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVMoW0Pn0gK6IwjuKK3XNQ/WiFvHA462WQJRH5z1nmA1KVrMsmMTNl3KyLyAuvR+eFGCZt7k8G7anhWFlMJojuu X-Google-Smtp-Source: AGHT+IEvxa3cD+utB1G5XE57kzSoggmuIQHowJAS3ekCwYUMb3gGtNE6SMNqUsQDoLDgcBNGDu2W X-Received: by 2002:a05:622a:492:b0:431:2a50:e15 with SMTP id p18-20020a05622a049200b004312a500e15mr5660162qtx.39.1712830883540; 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=Xjz7owLJtFvbaaI3CUuTdTSY/In49UHZScHrDx6D/EJhNh5LZdiRBrvwKBThd6y13K Le5ycNywiTbngZXUtdB4/Gn6ayDbuvPB1gpPqjP3EvrlhsPehnFj5ko9J9KkcytHMNLu 7Aztl0WQuddDjV9r+RJv4cr7ntQE8JOtChJD2atl8SLp/lwu7yd4RWyDOm+cwUhuOr/y YmCrI9IMYyfM75c/hZVzqVICxU5nY8rSfBQLsKAkMcS1rUxxQtjG88S9Q5uFkA6ofIFz PHs8KOGTfoevUBBDN04mjsKzfuK+e1qZWeZiQN+zRiItP2pmjbiP5waJnzWeFSei0cxI 3QNw== 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=iYu1kmJUzwiQNwtOT3Hu+HqZtkyD9XR4Mu5bcSA+DO0=; fh=wiz1UHo9SeP7cKsyv7qV5qfZpy+eOFaJKdMduwsqX+g=; b=C6T7hzdk5pIoYXLNkEwkoFOWS1N9dsCmbARhfa6l2Y3vNCgax9pjx62U0pakLsn1q6 DTC4dSTaGQABMWrXrAH7pklb7mj7sBmSJzElrtJfkoinuGSre8jWeULnJ8L3XjA0QVbI WS2nbQuEnJojWmyjxEP6iJHzGtJTbotp0OYBptlHzM2YHtgy07U98gtJrBAou0AJMiCN 9WEwHfNUdR9dsMZ3tQGF78nHwnsCxdekVMSj0DSg3m15Qcdy4NL0JPgHRy7CdTJFYRqS +Uk6CUzu5aaoTkrs2FnrjKQImaLDg4Azkmk/G3qKTg5OmSp1722Bu3GY+RE7U/oP8Q+B WNGg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="U6k/BHCw"; 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 a15-20020a05622a02cf00b0043663accfb4si919115qtx.426.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="U6k/BHCw"; 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 1rurUv-00067E-Mx; Thu, 11 Apr 2024 06:17:37 -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 1rurU6-0005Hg-Bk for qemu-devel@nongnu.org; Thu, 11 Apr 2024 06:16:47 -0400 Received: from mail-lj1-x231.google.com ([2a00:1450:4864:20::231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rurU4-0007Xu-FJ for qemu-devel@nongnu.org; Thu, 11 Apr 2024 06:16:46 -0400 Received: by mail-lj1-x231.google.com with SMTP id 38308e7fff4ca-2d700beb6beso82827231fa.2 for ; Thu, 11 Apr 2024 03:16:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712830602; x=1713435402; 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=iYu1kmJUzwiQNwtOT3Hu+HqZtkyD9XR4Mu5bcSA+DO0=; b=U6k/BHCwgJFABigzB8R+bTpGMo28cYY+vNyrudGuDwq1DJYL2lhXDfgjt3muytAsxA vP+xn1te8pMdZ6luDwKbW5odiXZYp8i3Faubm9B9z0Nncgf/b6/72c3I0nr5mkQtEaAP iPADb5sEiJmcuZgoDKuCW0ieFql3hZzaWA+LlZljQpSbih+fAzT+grI7AncvMdHePOdc +28tTx2bHK9S5lhrUXN9VtBdttNbZibdWQELUcrvRhpak0jn5G7nw82GJqiDHdetu9lY MK0LvgZQ9s9Icmkf+raAusEUmFnFeWdbFK6AMlefBCrU9rClOT9Es4CgciEWeWqdnNgD InRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712830602; x=1713435402; 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=iYu1kmJUzwiQNwtOT3Hu+HqZtkyD9XR4Mu5bcSA+DO0=; b=cCO5JvbOkDBEXCo56d7DQN6o97lUmvuiMdblLfj10RvD4mLvyqp5DLsB7bnXzkybVi F6onU1Tue8mk6fvi3IBgYn/C9jPxzACbhzED1kxG7OnLa7ksHkM98zcx7q0zohTv2QTz 6jPSp1TwPhorrQgSL+cg3kw28OIbH3+T6tyOJTVLhd5LR+8xAPFreizGkIFj7bswkSaT PpZ/gKfmUb4iCoZUz5BVpO8OnZyX3SCXT+HPW2ri0zSm218tudl09ev5TsvBDnuxt/Rf o4mzqPWjRS6KGf3PDDO0+tu4phgLlwFCF4ho0rlrm52Es+PTkEuHc2NqiGNvXU6TWxNx ttRg== X-Gm-Message-State: AOJu0YyTt7i0b1uy5g+5n5na/Iyf7YtVgy0m/VRT6cM1JnUfxtQ3N21R Zlhheqj2z3etP5D7DEOIapoNMjo7X9k49PBHDPtZljMrEMYK1+0XA8i5Lq+t5A941VUH6Q1feeF +EWk= X-Received: by 2002:a2e:9219:0:b0:2d8:d23a:f440 with SMTP id k25-20020a2e9219000000b002d8d23af440mr2454866ljg.6.1712830602221; Thu, 11 Apr 2024 03:16:42 -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 p5-20020a05600c1d8500b00417e227f40bsm740594wms.3.2024.04.11.03.16.40 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 11 Apr 2024 03:16:41 -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?= , "Michael S. Tsirkin" Subject: [PATCH v2 08/13] util/hexdump: Have qemu_hexdump_line() return heap allocated buffer Date: Thu, 11 Apr 2024 12:15:44 +0200 Message-ID: <20240411101550.99392-9-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::231; envelope-from=philmd@linaro.org; helo=mail-lj1-x231.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 Signed-off-by: Philippe Mathieu-Daudé --- include/qemu/cutils.h | 10 +++++++--- hw/virtio/vhost-vdpa.c | 5 +++-- util/hexdump.c | 12 ++++++++---- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/include/qemu/cutils.h b/include/qemu/cutils.h index 70ca4b876b..e8d6b86098 100644 --- a/include/qemu/cutils.h +++ b/include/qemu/cutils.h @@ -254,18 +254,22 @@ int parse_debug_env(const char *name, int max, int initial); /** * qemu_hexdump_line: - * @line: Buffer to be filled by the hexadecimal/ASCII dump * @bufptr: Buffer to dump * @offset: Offset within @bufptr to start the dump * @len: Length of the bytes do dump * @ascii: Replace non-ASCII characters by the dot symbol * * Hexdump a line of a byte buffer into a hexadecimal/ASCII buffer + * + * The caller must use g_free() to free the returned data when it is + * no longer required. + * + * Returns: Hexadecimal/ASCII dump */ #define QEMU_HEXDUMP_LINE_BYTES 16 /* Number of bytes to dump */ #define QEMU_HEXDUMP_LINE_LEN 75 /* Number of characters in line */ -void qemu_hexdump_line(char *line, const void *bufptr, unsigned offset, - unsigned int len, bool ascii); +char *qemu_hexdump_line(const void *bufptr, unsigned offset, + unsigned int len, bool ascii); /* * Hexdump a buffer to a file. An optional string prefix is added to every line diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index cf7cfa3f16..e61af86d9d 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -942,12 +942,13 @@ static void vhost_vdpa_dump_config(struct vhost_dev *dev, const uint8_t *config, uint32_t config_len) { int ofs, len; - char line[QEMU_HEXDUMP_LINE_LEN]; + char *line; for (ofs = 0; ofs < config_len; ofs += 16) { len = config_len - ofs; - qemu_hexdump_line(line, config, ofs, len, false); + line = qemu_hexdump_line(config, ofs, len, false); trace_vhost_vdpa_dump_config(dev, line); + g_free(line); } } diff --git a/util/hexdump.c b/util/hexdump.c index 469083d8c0..b6f70e93bb 100644 --- a/util/hexdump.c +++ b/util/hexdump.c @@ -16,9 +16,10 @@ #include "qemu/osdep.h" #include "qemu/cutils.h" -void qemu_hexdump_line(char *line, const void *bufptr, unsigned offset, - unsigned int len, bool ascii) +char *qemu_hexdump_line(const void *bufptr, unsigned offset, + unsigned int len, bool ascii) { + char linebuf[QEMU_HEXDUMP_LINE_BYTES], *line = linebuf; const char *buf = bufptr; int i, c; @@ -48,18 +49,21 @@ void qemu_hexdump_line(char *line, const void *bufptr, unsigned offset, } } *line = '\0'; + + return g_strdup(linebuf); } void qemu_hexdump(FILE *fp, const char *prefix, const void *bufptr, size_t size) { unsigned int ofs, len; - char line[QEMU_HEXDUMP_LINE_LEN]; + char *line; for (ofs = 0; ofs < size; ofs += QEMU_HEXDUMP_LINE_BYTES) { len = size - ofs; - qemu_hexdump_line(line, bufptr, ofs, len, true); + line = qemu_hexdump_line(bufptr, ofs, len, true); fprintf(fp, "%s: %s\n", prefix, line); + g_free(line); } } 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, From patchwork Thu Apr 11 10:15:46 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: 787945 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp149155wrm; Thu, 11 Apr 2024 03:18:27 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVLWN7JXZZFNZE76oKwdDwzdXjl5I1Qw0ID3A1hbdXKyCyIQ0I+l/ZiOD6cnwhSqTG5xS+N1LRSZQaqn70vFYNf X-Google-Smtp-Source: AGHT+IEOO3m6OWeCUjlNQ94g/qwiynOANwsplXiBlHwBZILmkqhyRzuzhKsuU+7Di02nAt7CyTqH X-Received: by 2002:a05:6214:27e8:b0:699:49d9:1498 with SMTP id jt8-20020a05621427e800b0069949d91498mr5901424qvb.30.1712830706775; Thu, 11 Apr 2024 03:18:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712830706; cv=none; d=google.com; s=arc-20160816; b=d1FSxDxpxf3em9GAZLlrOhy9uU1g02dO2sGk2NePQlKbCPTN8MTr8czUMihLpRUulE 4gYVK1ZRAzObWsecAyVzhtXI8TFrl8ZveOTio5Ok2v+OtYOqyV303OhjJzo7bKPnENTg m+utqWAr0Pr0sYfBpo9Wxf2DlT8wrvzRWeQlByMeBV/NCi/Ado6JatgTNsH3K7N+99Dc BDqc7m1X6tM00AhfWSISqe9TFjGezY92EoYsXbEBFPwcSS63Bm3v640fYxjyWwF4U77v VlemQq0bTOm7VdfSYyA9/KfB3qebfLXLt8/LE/Gn0BpuWeRlIHk7w4qaodsLqrJ6WZON pawA== 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=urm+Npyj3/f/E1cmlvhojimXxZbt++WU9CB9v2xORc4=; fh=uTBiEhTzp1kNucHHGCAS5oGgSgyR51XnqsaO8y3FJzk=; b=v/6zfulJH5A27z54M9Iy7dJGXHNCNsfUa0NbHPeaAUOFN0mKNwdWe8UW1XZhYrhlFl ZrlHKmO4TmhQDyrwFBBbS3s+bZn0yUsDK1C23eUbSCT13HOL7Fpo1P4KiwZ5BrZI6ISi GU9eNSS38pUbC/00ZbxBR/pwGClMnvITXXUbaGgXtdVXWRxIw2vF61lLAE8rEacQKbN6 /M8lY8UodaBVyudIrydAeGncVB+1YsFYGDYhI9WE9AFA2YSE46s+7jyPMevBOgzbVFBv TAHRXgPHPNvC+LcJf+JA2nHVji4EmXUiGxicNnYbbgFWgx94mraam6hRCZC/dvhPxxDM aaCQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OSBc6wG+; 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 f5-20020ad442c5000000b0069b50429ed2si338859qvr.479.2024.04.11.03.18.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 11 Apr 2024 03:18:26 -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=OSBc6wG+; 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 1rurUw-0006CO-6L; Thu, 11 Apr 2024 06:17:38 -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 1rurUK-0005MV-IU for qemu-devel@nongnu.org; Thu, 11 Apr 2024 06:17:06 -0400 Received: from mail-lj1-x234.google.com ([2a00:1450:4864:20::234]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rurUH-0007bF-CO for qemu-devel@nongnu.org; Thu, 11 Apr 2024 06:16:59 -0400 Received: by mail-lj1-x234.google.com with SMTP id 38308e7fff4ca-2d700beb60bso123181411fa.1 for ; Thu, 11 Apr 2024 03:16:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712830614; x=1713435414; 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=urm+Npyj3/f/E1cmlvhojimXxZbt++WU9CB9v2xORc4=; b=OSBc6wG+2rBkcpRghqTREESEvkDIHxU1tiW/aopm0NA7XmJngLRzAOe6LpUUKgrLVU ruuGvQbRRl2zRHczezhHm1a1ncYO6IB1D/U3OMvxdygk6SBCL3D9LvtSACmuj/DFF5d6 qxs+EhjitLV+NfXTjS2+Ra7MX91wYwTe4aqerPZeuPXGlNvEju3eZ0sqb03Qm8vF0tAi PLplMIXcntOsJpZNuzJrhuP6YguSjGggNrQL7ZILHAz25rn1vav7OqHgkTn8ggh/elck U3Xu/lU20+0Lxr4+KB8gFCrhgqtZI4hc7BqSjIWh5rPgWEO+zFKAxtGtpvD4DAxDdgAM NRVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712830614; x=1713435414; 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=urm+Npyj3/f/E1cmlvhojimXxZbt++WU9CB9v2xORc4=; b=cWA88EKt7UudNfaAHl/UjoTP+EjTIUWyG81LtqVnU6XylQ7bsFHixDIlJPv1Tmho6/ Hjp1dy1dD7RPJFTcQWNHBkIYVYTplejJHR/B1+NPAWwpmwgO2WfYad4ZecX/pqzDV1/n y0PLJxseenovKnQLaiiJEWHPkqztZrUFId/eupdf3dJmK2YfDWlnS/+py5SLqdYc+c1v Gy4NhUoagBGwr14hV2UErsQF0NJXp4ZYGzISXTelVTXy25//lJIFxmYIQwE09Ry1iZeY hmCTD1nF5pWfJe/DtCrxwRAZtSpOvNUM+IethXQHbIiDMtnUjf4mRt0+2Hy1ArKK2oIg LsYw== X-Gm-Message-State: AOJu0YxQBl7XLwwPb1wKZQjlrNnGBrzCzKqnm8sXDjNaOFV9rbzgT09Z 0QvJ8advIrvLoTwQOPniSBqQSbMvkmZoUz1YoE4qEHikSO6lsuC170B8bsx3PPiBdF8Qlp+63el Qv+A= X-Received: by 2002:a2e:9317:0:b0:2d8:5fe6:820d with SMTP id e23-20020a2e9317000000b002d85fe6820dmr4355192ljh.11.1712830613862; Thu, 11 Apr 2024 03:16:53 -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 iv11-20020a05600c548b00b0041665b6e111sm5064848wmb.12.2024.04.11.03.16.52 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 11 Apr 2024 03:16:53 -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?= , Paolo Bonzini , Fam Zheng Subject: [PATCH v2 10/13] hw/scsi/scsi-disk: Use qemu_hexdump_line() to avoid sprintf() Date: Thu, 11 Apr 2024 12:15:46 +0200 Message-ID: <20240411101550.99392-11-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::234; envelope-from=philmd@linaro.org; helo=mail-lj1-x234.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. Use qemu_hexdump_line() to avoid sprintf() calls, silencing: [105/169] Compiling C object libcommon.fa.p/hw_scsi_scsi-disk.c.o hw/scsi/scsi-disk.c:2659:14: 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] p += sprintf(p, " 0x%02x", buf[i]); ^ Signed-off-by: Philippe Mathieu-Daudé --- hw/scsi/scsi-disk.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index 4bd7af9d0c..4f914df5c2 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -2648,16 +2648,12 @@ static const SCSIReqOps *const scsi_disk_reqops_dispatch[256] = { static void scsi_disk_new_request_dump(uint32_t lun, uint32_t tag, uint8_t *buf) { - int i; int len = scsi_cdb_length(buf); - char *line_buffer, *p; + char *line_buffer; assert(len > 0 && len <= 16); - line_buffer = g_malloc(len * 5 + 1); - for (i = 0, p = line_buffer; i < len; i++) { - p += sprintf(p, " 0x%02x", buf[i]); - } + line_buffer = qemu_hexdump_line(buf, 0, len, false); trace_scsi_disk_new_request(lun, tag, line_buffer); g_free(line_buffer); From patchwork Thu Apr 11 10:15:47 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: 787942 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp149005wrm; Thu, 11 Apr 2024 03:18:01 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUJM7Q2nM2L9H+NV6gc1Cg9xYs0JSM17mTPea0jxVuCS2FVHmR9grx1Ifo8+WnT1kwuFyTHOihUzMTDeKW7sEzR X-Google-Smtp-Source: AGHT+IGNhhU4+cA940Ek64LBhLBpaXQQudmHd26gFHFvZRNAC0WwTvVwJTgzj2WGtByIB4oZQJQ7 X-Received: by 2002:a05:6214:1d2a:b0:699:a2d:d794 with SMTP id f10-20020a0562141d2a00b006990a2dd794mr4965155qvd.50.1712830681683; Thu, 11 Apr 2024 03:18:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712830681; cv=none; d=google.com; s=arc-20160816; b=ia4o5iPAhAO6bVy3PLROy7fYFh3cy2idE+IWhSaHNHxpTMBKf40I4U6u4forOaDaxs 6lrdiDcjNT6DwFG3KXPU3NZbffWAcp07un0T95qrxmJFDFgI3RWJFc6ErkhJdSbdAZ2R qznwzAc+IFVh1pr0/dLpHhn6VYsG5Ubn2pBvi/e2WbBTz7KqcF/QnP020Vg4cQnxDgjx jG90UZ6y6mARb/9th9f87wbW4/BJNS9MyyfDZxxPsIMJBnDh8xMWDcwIAmaHprWvh1iD Ir2fbQ6z0F8fqN6FxDePZYmKu0iXW/MAJsLpCzi4Kam2vtC1b2i6FnbQDh5hTPsUclMY 9n3g== 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=tmrbaiUVNJN3VwkspX6n0mLGveiY6Yl+m30htubqYrE=; fh=/lTrfBylm71qNkQIW0c1QbQKoBkENvG1bM6spxioYcA=; b=ze6XQk3du7nvQ3TYKSOup6cRjwWEkkNqHmoSJXjRIAhStUaROApsIL0omRPLZH9feY tjNM0QqWriBEgnA0WTiOBSgpDUG2/49cEwmSTv9h/RcszOe8S65SL7D7YqRcxE3Vmx01 GoS1yt0MvaWwgMSO29Bc3ivQAx9LYzhhYUoRd0DBzkjBmAQ/it/y9QELpDsmWBv6joGr kOnHi/2LTEgKM86aScG0Ob2IJnXjAZzcB10HGBszR3Yvzo14vzz7/iRWNb12y0+xJGeG g3TmO2fTZJbQqigomTbPhxreQef2zJaXUQ2LPzmfE3JOK7d9QU6PLoKkB3lNspSSTBlu B2Bw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EyltW+Pi; 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 h15-20020a0ceecf000000b0069b413fbdb3si1220433qvs.148.2024.04.11.03.18.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 11 Apr 2024 03:18:01 -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=EyltW+Pi; 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 1rurV2-0006L0-6i; Thu, 11 Apr 2024 06:17:44 -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 1rurUO-0005Mx-Qe for qemu-devel@nongnu.org; Thu, 11 Apr 2024 06:17:06 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rurUL-0007bt-Fn for qemu-devel@nongnu.org; Thu, 11 Apr 2024 06:17:03 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-4166d6dab3dso30487475e9.0 for ; Thu, 11 Apr 2024 03:17:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712830620; x=1713435420; 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=tmrbaiUVNJN3VwkspX6n0mLGveiY6Yl+m30htubqYrE=; b=EyltW+PiE5hSLlX2UuetygNo05dn8PsOOZbqMiH1mnJsDKwpR6vTwEk/aTNKArABid lCnMz7N6gBeNu0XoypaS5H0ZcqnnGsRMhZUIDGKTjIySrm9fh52YtiTLgkqzNm4PazAq RbsQw2TJLCKcOtbTJA/EuL8IUfK9TEzXr7jK4NHWvBYNrYiVUc6fzoGtGwteRvO7+9xi mXrEaVG5zIswp0+PrLLYwEJ/sWuYSyqi48gkGkcwC7fxCD2H1ye5jSzdSfz283YwtERt 9M7Sb4zn4yhlVEKdOzLsQhEJ9Ace4jHwagOFJBnqP6D+mY9jBYJFb4zjwvo7qRADgpxp cSWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712830620; x=1713435420; 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=tmrbaiUVNJN3VwkspX6n0mLGveiY6Yl+m30htubqYrE=; b=dpUIq0EU2pQ8NhPASAxE/wuL+F6YGEnQlEPYOHwWN6tf6WUjfANqTfiGS67QNKwRCO L9eWT9SyjGVDYUBWQ4CEBCcmf+S1azlOFLg9u+o/FRCnypv+MGxtCouaLUxESglTM+sm 6fFGEg/QX3IzXO52YdbyDqA+n+S0ehdqgNZepFIDzQMKjZJJne8VEW9TcOg8Q8ivnoGb YbLhoYU+p/vXhR8brz6ffsFRZDueb3DOH7hFnBNHIeo/HjvG9fiQWIgiviCXyjQgXOhZ KRzfhzSrdLRY8MjuB1mTWgHOQLdCW9WJqIJN1xcFZlyEgBysXIyL+HRuNGwpw/AeWsSc Lcpw== X-Gm-Message-State: AOJu0Yym+Gp/JKTJwdAMxJJR1rYFzSCIofa4jDZyOx7aCuQprpYufLtI jopbn6EN7WyAlCwFI0ixLyRVkVwytdVVitSrkAOhzPrwTR8pnB9AOBO9R0q1ZygSP7QFm5oO/fl Lq9c= X-Received: by 2002:a05:600c:4e88:b0:414:93df:bef1 with SMTP id f8-20020a05600c4e8800b0041493dfbef1mr3460478wmq.39.1712830619724; Thu, 11 Apr 2024 03:16:59 -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 bi8-20020a05600c3d8800b00417e184dacbsm791877wmb.25.2024.04.11.03.16.58 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 11 Apr 2024 03:16:59 -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?= , John Snow Subject: [PATCH v2 11/13] hw/ide/atapi: Use qemu_hexdump_line() to avoid sprintf() Date: Thu, 11 Apr 2024 12:15:47 +0200 Message-ID: <20240411101550.99392-12-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::329; envelope-from=philmd@linaro.org; helo=mail-wm1-x329.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=ham 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. Use qemu_hexdump_line() to avoid sprintf() calls, silencing: [1367/1604] Compiling C object libcommon.fa.p/backends_tpm_tpm_util.c.o backends/tpm/tpm_util.c:355:18: 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] p += sprintf(p, "\n"); ^ Signed-off-by: Philippe Mathieu-Daudé --- hw/ide/atapi.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/hw/ide/atapi.c b/hw/ide/atapi.c index 73ec373184..27b6aa59fd 100644 --- a/hw/ide/atapi.c +++ b/hw/ide/atapi.c @@ -24,6 +24,7 @@ */ #include "qemu/osdep.h" +#include "qemu/cutils.h" #include "hw/scsi/scsi.h" #include "sysemu/block-backend.h" #include "scsi/constants.h" @@ -1309,12 +1310,7 @@ void ide_atapi_cmd(IDEState *s) trace_ide_atapi_cmd(s, s->io_buffer[0]); if (trace_event_get_state_backends(TRACE_IDE_ATAPI_CMD_PACKET)) { - /* Each pretty-printed byte needs two bytes and a space; */ - char *ppacket = g_malloc(ATAPI_PACKET_SIZE * 3 + 1); - int i; - for (i = 0; i < ATAPI_PACKET_SIZE; i++) { - sprintf(ppacket + (i * 3), "%02x ", buf[i]); - } + char *ppacket = qemu_hexdump_line(buf, 0, ATAPI_PACKET_SIZE, false); trace_ide_atapi_cmd_packet(s, s->lcyl | (s->hcyl << 8), ppacket); g_free(ppacket); } From patchwork Thu Apr 11 10:15:48 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: 787943 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp149099wrm; Thu, 11 Apr 2024 03:18:16 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXeP++mC3mFaRrnZjeC/YPxE3sd0t4j06egs4LOuvmMtMhjABJnAcDhB4s9lrCjG8gI+q38piExCeUW3mJLAfkw X-Google-Smtp-Source: AGHT+IGTYlJg8IQjYse9nF4QYqEdTYLjrNHbxyrfkCTyT9ppUKYwbZEMbTHHDuTAXOQT8MGcz5BR X-Received: by 2002:a05:6871:522c:b0:22a:f96:28b3 with SMTP id ht44-20020a056871522c00b0022a0f9628b3mr5653476oac.53.1712830696268; Thu, 11 Apr 2024 03:18:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712830696; cv=none; d=google.com; s=arc-20160816; b=EzN09bH7FJl9ZblXUT1jtCkkxSADt6SwLGJHFix0mdJxp9shLJN2sDCGVPDGLD5MlE ivDZqHJ0bnsKBljiYm3Mn5HIcTiUyQ/Hn0igY2Gs9MKl8Iff1RhgJGHf7o2m49xRggHw DWSeQB931mb77PHtL5Gh32hslIfE3xuGCju+8ZylHf9qsd5p9CDOhXM7s7pjhqQT3EqE iM6kLb0bJJRUkOU/rX4VilRrzRIXhJlGqhu0a2U+QhMv3hqrBVHGUm6+ubrkWP4tYHD9 UkFrlrKcuyvVqiKRfw3okufQs/N7IGbaFxPLxF9x1yIllzwklWGDWlq50KiWcIn33Wvy gdnw== 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=XpfjBls1Q1Prp7MdrT8xYPE9RcXt49p2EGfNxpQiHmA=; fh=6R82/UGa7ltO3OAcYr6T+sVHeXf1vqtPCIpGPywXKxA=; b=B7vqZucRzRPguBVGAXEWHIZz8WgMn8baeRVos+jAB+0mTnZu6pWm6IRA9ZlDrZFymR aqjPiy/LrP2xVj2NzeDj/yK4xUeNK9Zi3ySDJlrfH7DujY/TAEwt7YTbGnZTSxTK1xXf K4oSfG9Ix6Tpw4OsUwyfMOsvpPOdR7QPIvQ1T/Zs2HLKBQzo0wNWNbpcZHmOB4h4iIdj 6VWNUdcAdongG9cAHTTlP7ehU3eMMXw0Pp0Rl4DYic0eStD1vgclKe2Fdp/dRrIfP4As p4+oDtRN+iAbXLrqcO5BG6FjxJAXlMy1Bki6fvMBo/6edePm4HlrzoMk4cM6eHvQLVEZ AZqw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SBMP4xtG; 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 dh4-20020a05622a4e0400b00434e49e8caasi1110377qtb.32.2024.04.11.03.18.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 11 Apr 2024 03:18:16 -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=SBMP4xtG; 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 1rurV2-0006Mp-Dj; Thu, 11 Apr 2024 06:17:44 -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 1rurUV-0005Ww-Cm for qemu-devel@nongnu.org; Thu, 11 Apr 2024 06:17:18 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rurUS-0007ct-Eq for qemu-devel@nongnu.org; Thu, 11 Apr 2024 06:17:11 -0400 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-33edbc5932bso5751574f8f.3 for ; Thu, 11 Apr 2024 03:17:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712830625; x=1713435425; 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=XpfjBls1Q1Prp7MdrT8xYPE9RcXt49p2EGfNxpQiHmA=; b=SBMP4xtG9G3waBZ60GaxVAKGy0nKpYbbPDfPoyAF/cFANqvvgpAhX1aqMzUYhqtKEU moz9KaKHyFm0FzqC/eInvu3pG8zDKdGyDs1NsUw0UzT5cTcAmcRoAVC1cQHYW+RqOR65 OVE9YtFblhh6CXzHdcjxCXMKAVfv6Dk4h0ucb65NFKxcg9W3irjppCOkeL1wp7nAptMD irXqp8DNH2ly1P/iTPBGH6LYyxENGeB/5hNCuL0/JNUBPiwtfy9RWDVuG50f7lsDRtp2 xcxtFX1ipgrQdNfIDeNw3pyVlMYGDesTBP9MvW6ZIALVL/OoyMXlH1b7F+uCvdPlJa1V d14Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712830625; x=1713435425; 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=XpfjBls1Q1Prp7MdrT8xYPE9RcXt49p2EGfNxpQiHmA=; b=aw6Vv9A83+S+HJ8fBvb2+bA/Kc66oUo+RzaI4xIDVAMk9HjlMeFtfcXgma6J7aG/5W 4yiiYUKfuZ6UV/PwcgiPUm6NEv3igDZqaX8UAo1ryEsTVFjPmmPY4mnwTarsgfU3dzbg IVtxYubiKTqLb9gDGwS5qERxUuCebhZiBs2+H6+Vgr4M+HgON9Akmmg+gYrhqLKPpNUx 2GCw9kYwqnbvViKiEshA2JgczABI4JNWbsTNHEHvvV7BrJw6twEQEbTzUfyxL2SJePGg W5I9LNnxUdZtVAQcvNvEjPgRVOw9Wn3H4RML70YPUw1o1dlnbe2siEsOBUJhBA2fVxMj 5uQA== X-Gm-Message-State: AOJu0YyebH5xCaYd+JGq1cXvoh7w3UayyhSEuiB+2DYdasvd3u0ra840 E8qJfN0Jj30p7okEQzTnIQoNgo1W4iD1vznpZQkO6k4n66+hMF1D4Uv4vtGQZHwY/McNRgZsqJh I6ag= X-Received: by 2002:a5d:4385:0:b0:33e:d448:e48c with SMTP id i5-20020a5d4385000000b0033ed448e48cmr3184277wrq.15.1712830625598; Thu, 11 Apr 2024 03:17:05 -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 i2-20020adfe482000000b00343bd6716b3sm1406416wrm.99.2024.04.11.03.17.04 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 11 Apr 2024 03:17:05 -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?= , Peter Maydell Subject: [PATCH v2 12/13] hw/dma/pl330: Use qemu_hexdump_line() to avoid sprintf() Date: Thu, 11 Apr 2024 12:15:48 +0200 Message-ID: <20240411101550.99392-13-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::42e; envelope-from=philmd@linaro.org; helo=mail-wr1-x42e.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. Use qemu_hexdump_line() to avoid sprintf() calls, silencing: [5/8] Compiling C object libcommon.fa.p/hw_dma_pl330.c.o hw/dma/pl330.c:333:13: 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] sprintf(tmpbuf + strlen(tmpbuf), " %02x", buf[b + i]); ^ Signed-off-by: Philippe Mathieu-Daudé --- hw/dma/pl330.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/hw/dma/pl330.c b/hw/dma/pl330.c index 70a502d245..0435378b7e 100644 --- a/hw/dma/pl330.c +++ b/hw/dma/pl330.c @@ -15,6 +15,7 @@ */ #include "qemu/osdep.h" +#include "qemu/cutils.h" #include "hw/irq.h" #include "hw/qdev-properties.h" #include "hw/sysbus.h" @@ -317,21 +318,14 @@ typedef struct PL330InsnDesc { static void pl330_hexdump(uint8_t *buf, size_t size) { - unsigned int b, i, len; - char tmpbuf[80]; + unsigned int b, len; for (b = 0; b < size; b += 16) { len = size - b; if (len > 16) { len = 16; } - tmpbuf[0] = '\0'; - for (i = 0; i < len; i++) { - if ((i % 4) == 0) { - strcat(tmpbuf, " "); - } - sprintf(tmpbuf + strlen(tmpbuf), " %02x", buf[b + i]); - } + g_autofree char *tmpbuf = qemu_hexdump_line(buf, b, len, false); trace_pl330_hexdump(b, tmpbuf); } } From patchwork Thu Apr 11 10:15:49 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: 787944 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp149133wrm; Thu, 11 Apr 2024 03:18:22 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWCUhurmmRY916iZLKbzKAA+ISSdHqOaU5QEwmZZd7X0Vj6fgvooF9kcTmtR3kGP8Djz3aEjPQJGCrwirMGnUxV X-Google-Smtp-Source: AGHT+IGMbr3yF6+J+T5Gwze7zFCj8gcfPMuJ88bQhscOj9CI+9addk4skGzWmQSWWXuJdJVWGZyf X-Received: by 2002:a05:6102:c8f:b0:479:eb8e:c67c with SMTP id f15-20020a0561020c8f00b00479eb8ec67cmr5354522vst.17.1712830702610; Thu, 11 Apr 2024 03:18:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712830702; cv=none; d=google.com; s=arc-20160816; b=dmRDlb3bOEyqbRP6Rxne2V5AlUO3MvCPHX38ERb8pBR9glBVRpRlRbFlaOaq4KGZMk fwF0kpKXiEIvA+NTxnmsMxhCP/8gfZe8eE6odIIR+u5NFrNE31c0rWCIS/MR4XFpUqQF 4zy/m6rvJhjhjD3KzP2uWgCnJkecUygoIKuB8oot0h46Z5UbsgyqHYVHMlnWMKMuNyoH RUFBWNcttCs6Ro6e22HI6P51Ljg5wLi1XpPGOoSbb+o/Enb84OUwW4zwNiNIxCdKutZD 1FK8epGuo9GQI7JtXto7EOCtoYX+XNpdxJejRK3rd4gKWa67fBBEg6gs08xzUgi2GI1T AmLQ== 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=2cVNgvNeXvdU51bO0Cz/mKYmbc4VssBzSVzGArcUzjU=; fh=AHbr3i1tcHlrTiDgk6bPy9HVXGcqgTW23foO5qK/HdM=; b=dyOi+ibFKxb5o6oea5d7XrXBkJfFskrnqUx6JmmSsZ9i0PlZ1WHxVIO3ZQllfPsBBj hlk95bfy/HYiGd0jHfCQSWFLOAYwqyShnwFmQHHu82YFaMUWhb/rA0Zzb2FAh4CrYDG1 bPuEO3bUgaFS10gA6Nycxgfl1LBuswguSH/AgjfAMEqCb3vB031KoQzIMT1sxF9/+a6q iI5N8U+TsH8fYT1iNZSRPDCFSs5MFApluufJ9ycCY/s6lj84ELu31uphN9rbTsOxB0Fr eb0U5INulzineXLQdVoUgoBcbqJjeOFCTo0tH7AGBX9u6ZNto48Q8cII5AZ1su7qkREV Px8g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=csDD1xx0; 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 s13-20020a05622a178d00b0043642a7a002si1145156qtk.796.2024.04.11.03.18.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 11 Apr 2024 03:18:22 -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=csDD1xx0; 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 1rurVG-0006Uw-CW; Thu, 11 Apr 2024 06:17:58 -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 1rurUa-0005Yh-JV for qemu-devel@nongnu.org; Thu, 11 Apr 2024 06:17:18 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rurUX-0007eN-4D for qemu-devel@nongnu.org; Thu, 11 Apr 2024 06:17:14 -0400 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-343cfa6faf0so5805123f8f.0 for ; Thu, 11 Apr 2024 03:17:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712830631; x=1713435431; 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=2cVNgvNeXvdU51bO0Cz/mKYmbc4VssBzSVzGArcUzjU=; b=csDD1xx0Z0zF6wd1E23GjOvXPx3NEC5RNlBSZDRspr2zmMs+NclJfIRFriPRDXdt4r d8Ji4BQJfWRuQTlQHDHnSrwmuPB2ceiNlUfxc0Oj9D5JmvTixhaRZuDtVVBkIIhEwbYY SeNGX+ieQ1kyML4edBYmFXiSje6yy8GC4iy69WlGzyhchqvSULK3bR5MUdow7evnTZVj qqAN+k5nvmz0WbE8MAT+rsC4d4jmSC3E/qrM1zEAv2bgoNhQUzC9mLQAyIxRWFbcVb+j 4LLhaoq1eMoPiwmE13BAyBt1S+El2JjQZwg1lO9fHlhn3J2SxFdF3GDQjdCoAS6+20J7 cUDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712830631; x=1713435431; 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=2cVNgvNeXvdU51bO0Cz/mKYmbc4VssBzSVzGArcUzjU=; b=FDMtfUYHrkS9FlxSfs43BdtZPSwB2uCuedy+PvljEApIi21mjKZWlYdCszPqTK03jH 5b1tM5TtR/2opTwG21ysEuAuKJd+KIwLvv137ELUlMk79sqdvaffXuvl9BagB7X8zvOZ Olhjofvk8VKjYNCk0WRiXTZboR2FEkurR35gpUShrzqSTeAkuwACD593h2OlV82t7Gnz tafBLdxCFq02xWqeSBKRTVQDRCmLH1ZP8LUh4mN5xRz0kJTPlJK6h0l7UGmKf8Bt3uMq +UNGFBH6YYaXEotwxQVOMUdaBxKoXGmQcczdnJxPt5Jn8MDgAwTufm0ZhZyzxaXasGqV dEcg== X-Gm-Message-State: AOJu0Yz21uaO371cExYU34tXYhL0f2Eci+fLEJnzApexICZ1FZnfSF1L 0zUkoBFTVo4Q3khpWM6u/7JtRLSDULyQ2Y7s4dc8w58UFBXgujx4Q9FmkBK3uySiZb2J0bR8yYr nlds= X-Received: by 2002:a05:6000:186b:b0:343:6b76:251f with SMTP id d11-20020a056000186b00b003436b76251fmr5589625wri.42.1712830631600; Thu, 11 Apr 2024 03:17:11 -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 e18-20020adffd12000000b00343826878e8sm1413910wrr.38.2024.04.11.03.17.10 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 11 Apr 2024 03:17:11 -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?= , Stefan Berger , Stefan Berger Subject: [PATCH v2 13/13] backends/tpm: Use qemu_hexdump_line() to avoid sprintf() Date: Thu, 11 Apr 2024 12:15:49 +0200 Message-ID: <20240411101550.99392-14-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::436; envelope-from=philmd@linaro.org; helo=mail-wr1-x436.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. Use qemu_hexdump_line() to avoid sprintf() calls, silencing: backends/tpm/tpm_util.c:357:14: 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] p += sprintf(p, "%.2X ", buffer[i]); ^ Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Stefan Berger --- backends/tpm/tpm_util.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/backends/tpm/tpm_util.c b/backends/tpm/tpm_util.c index 1856589c3b..0747af2d1c 100644 --- a/backends/tpm/tpm_util.c +++ b/backends/tpm/tpm_util.c @@ -21,6 +21,7 @@ #include "qemu/osdep.h" #include "qemu/error-report.h" +#include "qemu/cutils.h" #include "qapi/error.h" #include "qapi/visitor.h" #include "tpm_int.h" @@ -336,27 +337,18 @@ void tpm_sized_buffer_reset(TPMSizedBuffer *tsb) void tpm_util_show_buffer(const unsigned char *buffer, size_t buffer_size, const char *string) { - size_t len, i; - char *line_buffer, *p; + size_t len; + char *line, *lineup; if (!trace_event_get_state_backends(TRACE_TPM_UTIL_SHOW_BUFFER)) { return; } len = MIN(tpm_cmd_get_size(buffer), buffer_size); - /* - * allocate enough room for 3 chars per buffer entry plus a - * newline after every 16 chars and a final null terminator. - */ - line_buffer = g_malloc(len * 3 + (len / 16) + 1); + line = qemu_hexdump_line(buffer, 0, len, false); + lineup = g_ascii_strup(line, -1); + trace_tpm_util_show_buffer(string, len, lineup); - for (i = 0, p = line_buffer; i < len; i++) { - if (i && !(i % 16)) { - p += sprintf(p, "\n"); - } - p += sprintf(p, "%.2X ", buffer[i]); - } - trace_tpm_util_show_buffer(string, len, line_buffer); - - g_free(line_buffer); + g_free(line); + g_free(lineup); }