From patchwork Wed Apr 10 16:06:02 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: 787517 Delivered-To: patch@linaro.org Received: by 2002:adf:fdd2:0:b0:346:15ad:a2a with SMTP id i18csp766895wrs; Wed, 10 Apr 2024 09:08:23 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVlIOKsJswqBeyBv1pUtkzvG2BkkjVXE3QtHUn3/dc6tOLp0h43Js877oMgrZ3Wd6Koc16EUahGtLflmtgiF44l X-Google-Smtp-Source: AGHT+IHZqMxtJvL7sC9mGvhD0RYYvrg2OpMjyLdGXGOtC/7JL23J1ntve9MOuFJGNJ7aZskgnbYk X-Received: by 2002:ac8:5f0a:0:b0:434:85da:4022 with SMTP id x10-20020ac85f0a000000b0043485da4022mr2570758qta.65.1712765302637; Wed, 10 Apr 2024 09:08:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712765302; cv=none; d=google.com; s=arc-20160816; b=DLbcLSn0ZxwndnIrNWuBqR61Kg5x99ltf8DftKHjAXu8d8GWDaCWnNyg7qTOx2S2aW vsgysgA8bXJsrZrmhyZ1uTWuxwcLFPvecD3T8TSXHoT9BK6Oe3seQmVR9lR+hudZc86B XhnfTfaKC1E6AkcAlX/AyT9syub8ZVCMcX90taBdnCQ44COjLhM6EYucx4P2hPYmuzki UZGL4j4QAtVodIM5PmJZlWzK2QgXU26SATdaNX41xj/i27xGUHcvFBeGfZPGoQDtrs/E qJUvcm5/k1DSjFUGAT9eSUJ31z1jjUKUwHk8FvC/kumhOb3741ro+EoEmS8cgaWOVJzC 0jAw== 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=i/lq6iuLQ5c9JQCAm384BpFlIIX3V3zTqW1RLNIFCYE=; fh=zCMmOM3fi5s13M8j2+42MzFDp3ONJLDItW4DW0uVO6Y=; b=k3VcaaAMdsM1ecfADvKmb+TB46UV5DzWpgwqq4qcF5EmLx8+ZL6py6wlUMVh+doglb 2LeclOJrYcCbSEx35SaJQ7TPiRnDn82kPmZSKXIiZa6vI+yUnyjaqvZ0USOtWYgBvfDl PAorsPyGMNDbHqnFmcrIXBqdCRxPB9XcC0EZZmjA2HcHraIe0h5Nn9WH1DO9iKKngAwh hoa1xmkXSeOmht8lmbTitrVIf/DhiEJ41uixrSZiYIE4fh7ShQ2zwr0N2o4JpM+nsJxJ Q2MZePsGrJM4azkLRQ20DfFO0j5ctaQWqUtvHT0sCrvG4P0k85IF+m4eHqZ+e/DzMu4P rOzQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nRw3OsPA; 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 g22-20020ac85d56000000b0043439b932bdsi3098319qtx.776.2024.04.10.09.08.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Apr 2024 09:08: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=nRw3OsPA; 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 1ruaTG-0000FN-Qx; Wed, 10 Apr 2024 12:06:47 -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 1ruaSy-00009Z-Ae for qemu-devel@nongnu.org; Wed, 10 Apr 2024 12:06:32 -0400 Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ruaSv-0002ZB-FZ for qemu-devel@nongnu.org; Wed, 10 Apr 2024 12:06:27 -0400 Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-563cb3ba9daso6967510a12.3 for ; Wed, 10 Apr 2024 09:06:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712765183; x=1713369983; 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=i/lq6iuLQ5c9JQCAm384BpFlIIX3V3zTqW1RLNIFCYE=; b=nRw3OsPAUNL+/YJc7hP6f+fuumc/B/CWcjQDX7kioAS1m09OS1nXXoIcRsWuN0qBP3 or+5OypbJuLERnN39H4AQTxdpEfve42Fho4T0/4f0QqHo67Gr0aswbK9N3zt+Ho4RA1i QVdKLqnznMLb+hI3Z+5xf5M3gxpm0HwNKl/PrUGC0s8rcMrkfoMz3qy3utUWHY5JuJaZ NR+b9/6/Lk010HUalMK0UXRMjJMRqclW6Zi6O26TSNkp8A1Ar/dwh60YUbcMEba/uHFY C1EWa74WTmCQAFuVs6y/CG8J0SEbzo28fKRrXFcSlrYzDVZVFMtlbxVW+ACe5hiXNG1o 9OJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712765183; x=1713369983; 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=i/lq6iuLQ5c9JQCAm384BpFlIIX3V3zTqW1RLNIFCYE=; b=G0U26tJxohBZyIPxXRMPs7eDSjuZRg08fA48Gcni5KNAMFssr63vocojQwxDjE8uwp ZhvKpuoVuJWBiTlrm8C+oPljYqCIoIincqyUvkld3Nq/Wg8Wn7aSe/37eGZdDFJx7pdW 1jXgnjqoZPBkaHqyKXVIj0C0q+LM58/eDBR9sdfFv4uzHcibqh6Y2BSRY6kXnkpLvv85 mLdpiDlAdbHKcI65xu69jBIs+4Dd4CWVyDD2LIL9H2u5QokG8BLdg0o/ZN5FtJhLevIJ QTzhNhfx1GLl58buQ0C9F8L8t0QYncfzoe9ONjVf7Ir1qcfFBKpsOFBXUCl5isO0OClX N/ew== X-Gm-Message-State: AOJu0YxTDlPXvoDbKfZbX+gTQiQFHmYfHwMeeQtvfFyfWY6RTgDbskhh QcugNHObEdaQzhP2MXzF0nJdwAowJemooB2d4q6gvorINj6N9NSJ4R9KIn4Y8rHqTyS5j3uOEbv + X-Received: by 2002:a17:906:45a:b0:a47:34b2:ca4b with SMTP id e26-20020a170906045a00b00a4734b2ca4bmr2296275eja.50.1712765182972; Wed, 10 Apr 2024 09:06:22 -0700 (PDT) Received: from m1x-phil.lan (arl95-h02-176-184-34-173.dsl.sta.abo.bbox.fr. [176.184.34.173]) by smtp.gmail.com with ESMTPSA id c27-20020a170906d19b00b00a51a00142bdsm7106150ejz.212.2024.04.10.09.06.21 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 10 Apr 2024 09:06:22 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, qemu-arm@nongnu.org, qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Subject: [PATCH 01/12] ui/console-vc: Replace sprintf() by g_strdup_printf() Date: Wed, 10 Apr 2024 18:06:02 +0200 Message-ID: <20240410160614.90627-2-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240410160614.90627-1-philmd@linaro.org> References: <20240410160614.90627-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::531; envelope-from=philmd@linaro.org; helo=mail-ed1-x531.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. Replace sprintf() by g_strdup_printf() 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 --- ui/console-vc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/console-vc.c b/ui/console-vc.c index 899fa11c94..b455db436d 100644 --- a/ui/console-vc.c +++ b/ui/console-vc.c @@ -648,7 +648,7 @@ static void vc_putchar(VCChardev *vc, int ch) QemuTextConsole *s = vc->console; int i; int x, y; - char response[40]; + g_autofree char *response = NULL; switch(vc->state) { case TTY_STATE_NORM: @@ -821,7 +821,7 @@ static void vc_putchar(VCChardev *vc, int ch) break; case 6: /* report cursor position */ - sprintf(response, "\033[%d;%dR", + response = g_strdup_printf("\033[%d;%dR", (s->y_base + s->y) % s->total_height + 1, s->x + 1); vc_respond_str(vc, response); From patchwork Wed Apr 10 16:06:03 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: 787514 Delivered-To: patch@linaro.org Received: by 2002:adf:fdd2:0:b0:346:15ad:a2a with SMTP id i18csp766507wrs; Wed, 10 Apr 2024 09:07:42 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWq55DsLAXU2oEWT1MSzPskwf9LHOgrC1U066jAbJtQE7DEJcaaHTfelMldfYcOqK7k6ZB+eLgZFaHij2FMJG37 X-Google-Smtp-Source: AGHT+IH2xxqpBV4zWRWj9Klc0A4kC7+sIP/S4LL+OYv6kcOmvECQmVG/Wv7LfuH0Az6uP9uCH1vk X-Received: by 2002:ac8:480d:0:b0:434:fe03:1797 with SMTP id g13-20020ac8480d000000b00434fe031797mr2441778qtq.32.1712765261871; Wed, 10 Apr 2024 09:07:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712765261; cv=none; d=google.com; s=arc-20160816; b=Y+AbbHF4eZzc357A6ze0v2M2a31EB8LFMTMGE1ZfLtI24xFVu40lMtNR2LqOEO5F0E NExf9clgwMWvW6lkThm6y8NhHRmAHTGgskGmHjC2tK6vVW9bqXMQ/dHzLKD2NopE/yx+ Zf0YiZlimz3bI4005ALwnlReW25hcSNLEMn3E1jYqZ8PTOZWbaxCE485LI5t++uoejg8 ZTy8rqB3Rl6ABLooySfBhozjxUa77E+0kwRRWHtBS/B8YX24K8jYdHByxyd+z7vD8mO7 ZssvKxkmnOeQQPkXUoX7Qit5fJIFe2PEMVQhMmZiKSSIKuBPcxrib93HZqr5wgC7/kYK QzEg== 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=LDZo3IQYGRSUjwFMJgZFbdPKp1+CCXvSyhVLfSqq00c=; fh=E2Hi9dE2NUV5H+/33mf/+b236dvJczf2eqdigiqq65g=; b=LBZ16XOZ7VBn35yNY1hnwiIX7lv7sxyFfAet6oQdSo0WbFMHFAyg7QXoKpUf2PRfv6 AtlW+cjN/2P4YfFQLrvVobrR5gAXbq4wDPOm2nnd+FuaiIJB63djNlyW1bG4mshPHu90 RJSYZF572sp9K3cdMUWcwRKrvxfp7IKpmo3qQGurQwVRc1OmA6eNk4wDOhA6kpI0v29R WQYtVmlpD+ly/VtMDpXfpMUGq8nLHldUmItLy3viX8d1UB6eBgt6fr1Rrjxp/nxHG2Iy LWUZaT4XQ2N4pMcXbotOmuZ8VkLxCHqs70aE8Z3J36+WeueKHUwEvZF0XeEO4CkBUnal ZDcA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GVIQLZUf; 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 b15-20020ac87fcf000000b00434394158ddsi13314499qtk.362.2024.04.10.09.07.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Apr 2024 09:07:41 -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=GVIQLZUf; 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 1ruaTM-0000I3-I5; Wed, 10 Apr 2024 12:06:52 -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 1ruaT9-0000BT-I1 for qemu-devel@nongnu.org; Wed, 10 Apr 2024 12:06:41 -0400 Received: from mail-ed1-x52c.google.com ([2a00:1450:4864:20::52c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ruaT4-0002c1-Cj for qemu-devel@nongnu.org; Wed, 10 Apr 2024 12:06:38 -0400 Received: by mail-ed1-x52c.google.com with SMTP id 4fb4d7f45d1cf-56bdf81706aso9181186a12.2 for ; Wed, 10 Apr 2024 09:06:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712765189; x=1713369989; 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=LDZo3IQYGRSUjwFMJgZFbdPKp1+CCXvSyhVLfSqq00c=; b=GVIQLZUfYb5YWk3EaBhzF41rlxWxBYtLa3btodEuOi8AnkW33w6CWn9t0kCSe3WwPI byC6IHn6hHHuJJXxhSsJZQsgJcPUDaafqUdPd+5SGZYZj4w7n3Une4Ji4XVLJgcJRo5J i/zJI1eh9GE1RoYLzGvz3Xg/uumKUZMGPJHecZdOi29L7C36VJG9Sa85i7PEEngRfaF4 s+SmuQzmteLVH122xlFEfz5c/TWIAGKss2yXCagKVrTkqqMDMjPQRNz85D05sQxBLIpv FUlObDXf06wavEINCpNICd/SE0Gi/4t5w8F4B53op5ZRl1jTqFqrpSq/6/0TgWp2AFKp ddRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712765189; x=1713369989; 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=LDZo3IQYGRSUjwFMJgZFbdPKp1+CCXvSyhVLfSqq00c=; b=nv9eRjtGqmZi3HFszgfLOU8QLGHIdELvFpgQ1LLxv8ZSTdFOSHi//K1B5LXzc0MSmB 5/gwqPQ698t3VVlavebfsMxBh7Xvs8+sejkJE1qDuSBitsHckcQq1/hn/kaKPV/tjYGs LLASWIooqvCjKgW+2oWAmLbrFD9JQzcQ9H8WImn9kaIrLLyHVfNrVCEqadd/8xeXAd8V sbXv2Uq/j1YSnSVHc+U6OBP2eLRddxVszoSbj3dVZ0UyaVd6O6bRzaOh/kutT2OaXUbS VnDgejaJ6lOH/aVNTrDGui7cXfETvIKO7Rc+OWmvHOiMk0+mmKGEFcgF9EKP/pcWKjZk e0Rw== X-Gm-Message-State: AOJu0Yy6ldc/bHQd810A+aQjbK382b2R+OVYrCbSCZr673BN3FC3IRfj hQPI1svisDuD6xvy6qW3dj2hXU82dogkF6GFUkPmWn81UvwtVpirW89xA8SJTOl4nuNtQ2UfpAj 3 X-Received: by 2002:a50:bb07:0:b0:566:47ee:b8b4 with SMTP id y7-20020a50bb07000000b0056647eeb8b4mr1995538ede.17.1712765189165; Wed, 10 Apr 2024 09:06:29 -0700 (PDT) Received: from m1x-phil.lan (arl95-h02-176-184-34-173.dsl.sta.abo.bbox.fr. [176.184.34.173]) by smtp.gmail.com with ESMTPSA id by15-20020a0564021b0f00b0056e591bb644sm4078733edb.45.2024.04.10.09.06.27 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 10 Apr 2024 09:06:28 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, qemu-arm@nongnu.org, qemu-block@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 02/12] hw/vfio/pci: Replace sprintf() by g_strdup_printf() Date: Wed, 10 Apr 2024 18:06:03 +0200 Message-ID: <20240410160614.90627-3-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240410160614.90627-1-philmd@linaro.org> References: <20240410160614.90627-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::52c; envelope-from=philmd@linaro.org; helo=mail-ed1-x52c.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 g_strdup_printf() instead. Signed-off-by: Philippe Mathieu-Daudé --- hw/vfio/pci.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 64780d1b79..cc3cc89122 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -2442,10 +2442,9 @@ void vfio_pci_post_reset(VFIOPCIDevice *vdev) bool vfio_pci_host_match(PCIHostDeviceAddress *addr, const char *name) { - char tmp[13]; - - sprintf(tmp, "%04x:%02x:%02x.%1x", addr->domain, - addr->bus, addr->slot, addr->function); + g_autofree char *tmp = g_strdup_printf("%04x:%02x:%02x.%1x", + addr->domain, addr->bus, + addr->slot, addr->function); return (strcmp(tmp, name) == 0); } From patchwork Wed Apr 10 16:06:04 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: 787516 Delivered-To: patch@linaro.org Received: by 2002:adf:fdd2:0:b0:346:15ad:a2a with SMTP id i18csp766835wrs; Wed, 10 Apr 2024 09:08:18 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXErnbZKFpLbhQOfdOLhtuhlG/vaYnb4VvjhRKfYS0EcF8jASaoS9tRKbrbC9csbyTd52jHxwEk9s1iYRy4V3Sq X-Google-Smtp-Source: AGHT+IHSudbEF/6y65jib3Pxb+kSax4ZI/lo6nU/YzWHnJfvcZFkVoAyx5EHYsQ/l5l7mQOnMNvc X-Received: by 2002:a05:620a:1182:b0:78d:74fb:d6a3 with SMTP id b2-20020a05620a118200b0078d74fbd6a3mr3192429qkk.30.1712765297811; Wed, 10 Apr 2024 09:08:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712765297; cv=none; d=google.com; s=arc-20160816; b=UyjJ93Gwwq0nS6hTctaXaLHHcN4kZY0lZItSw1zbYYuvRmMZT01lJt/w6nm6oYCPRD Jo2xVlcpZQx6whbeOPfrRkKxzLHZSHi7KEn7QgcAlUprqHzpQ5Rnuk9GuOHuQrA7NMI6 4KLo43OAx+KR6VLSr54HFb7YNNCLBiFH5ZwFbpapGY9QV30x2GPmFLdK3u6mKuv3MfTo Q0keA6t/CJDZbMzeQanSh0Tk9YvpMsera7OLuqliJ4yLmNtlk5kvPXQAktPj+jn68PxA WZX6rn78ALf3wA+E0g4i1uVPrJ/Qi53qCWkn1vVHR7Ejt/FbzY2/8z6ve3iWlh/vhJk/ oAXA== 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=aQdWVo6NuDCj/u3KVg91SVMh7Be4Qk4bewXGZ1yULgw=; fh=Jrc3/BRBZ0Vk7CjtURS2a9ZdqJAQP3MYsKv0VgU8hgM=; b=mc2YmNDYlwSHuhlM5hzeuxwo20yyE2X6Db8Zr4AIy577kSVqKIjjMDauzqdM/AMYml wc47RDRtEF8sgX/ZZFO3gytcThx5W22tW8jkmMLsY3DGHSyFNOL05DFHreLCnqVPvZpZ SMPy6A/jGEswf5SSzmt9vBEYOYAmFmtKMUEsnFGAfG7/XGgeksWH9hxEA2ErC02xzm6Z xqnBDkRFMAsMNIW+81Owz6KYQ5lqxOevYH61uZO+eLV6IvE2nJ1KRwhhXIOzVP7/6eXd 4TwwG6HPO1aOvtZ+B67NQL/2sC++Jh4Z1mDH+yBw+vPsr69qH4zjfwn5ZU0qeomBbGQ0 LfSw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fZwumd9u; 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 f6-20020a05620a20c600b0078d549b27e0si10092382qka.260.2024.04.10.09.08.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Apr 2024 09:08:17 -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=fZwumd9u; 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 1ruaTM-0000K9-MK; Wed, 10 Apr 2024 12:06:52 -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 1ruaTD-0000Dp-DC for qemu-devel@nongnu.org; Wed, 10 Apr 2024 12:06:45 -0400 Received: from mail-ej1-x635.google.com ([2a00:1450:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ruaT9-0002cw-Ae for qemu-devel@nongnu.org; Wed, 10 Apr 2024 12:06:42 -0400 Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-a519ef3054bso657564366b.1 for ; Wed, 10 Apr 2024 09:06:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712765195; x=1713369995; 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=aQdWVo6NuDCj/u3KVg91SVMh7Be4Qk4bewXGZ1yULgw=; b=fZwumd9uPxRBgT5GI6xQREaJXs9duP0GHqy/KpNiJsCAqAHkUUbU1Y9QXt1DKcSUJv a4W6qpLhLAAUVOi3qVwYtHLLynCcNbTxBLX+u3F5zjbba0V3iIrcvxk0oC6wM8O2Msjh 22PL4++KX/4tpDsfSb7jvgShDfa9fvfIBtTQO/N0kgmZQZVzZ1DGpvKbEyJqbCpQYLTM t+aSa9baqtcS07glHUqC2qLcVi2Kn5wsJ0jwC2EID91L13YqES6vrL/pQCjVKcNPLcgN qAhxX9g1fMoOtqcV8Vdj53vCoQCPwfBQVeCprqvaTbecMjJCk6+f7O7b9FrwSazOUyV5 dtsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712765195; x=1713369995; 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=aQdWVo6NuDCj/u3KVg91SVMh7Be4Qk4bewXGZ1yULgw=; b=Hj0dfRlHvzEO54Dpxj1CRa6n1uI0bpoycRmOXiN3B71Q0VK0Tw7cpFhyyM9NktlMPj lufR3j6LX+4VgN92V4RB5/rLjnNW5YXHOoB1syWCWFmmPZwAJb9OC5+w+5UHFzwCbEOw qqBLv3v+8yRiG7SKd1VER+ak2wDF3qmeu7n/WDuqcwDtaXDxP4/tRawDytERdgEeWY5O KxMWKxH2q5q/zInHHuJCk8Dgfv1pV4M5jZ/oeToCUcLDYpoolFQMWyi2onG5IPicjtvP +ldogBN272O+bi8GPN0ci9sExgu2s48L46qzOWKN4aOsHjEh9JtDuW/tB0NPpvMgFh8a V02A== X-Gm-Message-State: AOJu0YwH0SVt3FZ6Ouht91mi0ecMjLh2aLy6sqwxORaWawEOHOGXavQ5 d/zkjyhzsAAftAiP3AD32PI41QETX1sSD2e09iBQO1erfjJ9TbiGwh5VkuvDDjhq1qvo9cx3k1T c X-Received: by 2002:a17:907:7ba2:b0:a52:10c4:edf4 with SMTP id ne34-20020a1709077ba200b00a5210c4edf4mr1711961ejc.4.1712765195295; Wed, 10 Apr 2024 09:06:35 -0700 (PDT) Received: from m1x-phil.lan (arl95-h02-176-184-34-173.dsl.sta.abo.bbox.fr. [176.184.34.173]) by smtp.gmail.com with ESMTPSA id b10-20020a170906194a00b00a51b3c951b6sm6080248eje.191.2024.04.10.09.06.33 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 10 Apr 2024 09:06:34 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, qemu-arm@nongnu.org, qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Nicholas Piggin , Daniel Henrique Barboza , David Gibson , Harsh Prateek Bora Subject: [PATCH 03/12] hw/ppc/spapr: Replace sprintf() by g_strdup_printf() Date: Wed, 10 Apr 2024 18:06:04 +0200 Message-ID: <20240410160614.90627-4-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240410160614.90627-1-philmd@linaro.org> References: <20240410160614.90627-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::635; envelope-from=philmd@linaro.org; helo=mail-ej1-x635.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 g_strdup_printf() 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é --- hw/ppc/spapr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index e9bc97fee0..9807f47690 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -375,14 +375,14 @@ static void add_str(GString *s, const gchar *s1) static int spapr_dt_memory_node(SpaprMachineState *spapr, void *fdt, int nodeid, hwaddr start, hwaddr size) { - char mem_name[32]; + g_autofree char *mem_name = NULL; uint64_t mem_reg_property[2]; int off; mem_reg_property[0] = cpu_to_be64(start); mem_reg_property[1] = cpu_to_be64(size); - sprintf(mem_name, "memory@%" HWADDR_PRIx, start); + mem_name = g_strdup_printf("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 Wed Apr 10 16:06:05 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: 787513 Delivered-To: patch@linaro.org Received: by 2002:adf:fdd2:0:b0:346:15ad:a2a with SMTP id i18csp766399wrs; Wed, 10 Apr 2024 09:07:33 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVtJAwI7elOIog9bRqD9VVLbWUbkROX/tudQgcb0OjM4Yo3+jnXNbs2YOxLgHnHl4ODgHGL0KXBCSc6CK9LFghS X-Google-Smtp-Source: AGHT+IEl9lhK88y6fK2Zr5gxfHe0vAzwa1HaBWeFf+vNAvMqI+ND/Jiijv0cPHvNdQkhx7q3iCFT X-Received: by 2002:a05:6214:21ef:b0:69b:24b2:a3ce with SMTP id p15-20020a05621421ef00b0069b24b2a3cemr3807780qvj.55.1712765252786; Wed, 10 Apr 2024 09:07:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712765252; cv=none; d=google.com; s=arc-20160816; b=fMVLv8jfqcbRcpR7wPUwS8VjZwuEEU8MEKkoXx8h88sH5pDK+rZ8iwXhcTlE/5YFtU 1Grv3zIyz7kuo279EiKSdKTmoJjVLxyhFRePlMd6TZEV00xce3UrhpxKt2Z+BgE95+tz BIlVr86YgAgIexE54R4J9SwQLsOM8XzMjB5x1sgyneHbAfyNNLyg7wTiDz4+bkz+XfxZ csmvSsSPQGdJGa5WqgNcJS2hbIoCqt6hy8TjWYtf05Pnsr/ES/T8B1mSw00TRTddqcQs rZk5YTWPZuuFypA/p6xLK6wKkxFJUV3BQT8fPTkz70e9/cUycmvECrxy3G3wussUJHXk 5Iww== 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=i9EgoEyF4/rVzoPOi90aJqArCNPBQ3SZoaAZfVVHCyA=; fh=UWYPSc6lFEtDGAdsfbGXa/TndNnIg9LYTXf2fXfDKtQ=; b=p0mk+DhtyWeKzsMP2EyV2LO1bys8ct+wnibjFfjV68/yMMiHtQt8ECSSAvMBkKdwei foGpP23jaVCKm3hisBFjP8n8syHsAXpJS+RQQhulHCFf2GSFhz19CUXmQH+V80CUjLD0 JNnesp4WCgmtLLDraUZTFJQG9dx89COX0H97wkOoEzDMEoldOU4Kl9m0hWjTKu0d3F0d BNCVvl6DXTxTpVBQnw/OGIPF8qqAuqGUocqg5Z0fmz5fYm57G0t80aQNDbGwUECGp8bl oisy+/w5om4pv0HhSf/+sBl8VUHkF4WOGh9hIGdc9/6dnKgDVHlZz5FZ2s+M+jDZDjWK 8hFw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BNVBWKmF; 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 pm12-20020ad446cc000000b006992c8b6fb2si13040585qvb.261.2024.04.10.09.07.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Apr 2024 09:07:32 -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=BNVBWKmF; 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 1ruaTN-0000Lb-C9; Wed, 10 Apr 2024 12:06:53 -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 1ruaTG-0000FJ-4v for qemu-devel@nongnu.org; Wed, 10 Apr 2024 12:06:46 -0400 Received: from mail-ed1-x52e.google.com ([2a00:1450:4864:20::52e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ruaTD-0002eq-5T for qemu-devel@nongnu.org; Wed, 10 Apr 2024 12:06:45 -0400 Received: by mail-ed1-x52e.google.com with SMTP id 4fb4d7f45d1cf-565c6cf4819so13412797a12.1 for ; Wed, 10 Apr 2024 09:06:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712765201; x=1713370001; 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=i9EgoEyF4/rVzoPOi90aJqArCNPBQ3SZoaAZfVVHCyA=; b=BNVBWKmF+EWgVlLwrYi4ykCSD+oikrFFP0SqNWF8D3f3s2pl7fT6+j627BR9sSLIPa rl8CpDaSaevTtJbJMB3nKVzQVpqoCGKDvMkTJVX9xH8570x2o0++ilejyN4Nj6uqtBKL xjaQNC6bqAglReleDRwbC7iuPcEa9NLtLyw7QQ9H0YDtiU2IKABaIXbJo72QJinE3vRr ZGbMM6CXY7fY4ZtaqKlIqLTbuntH/weBMOkkMeFtXVYGLdTzKnkn7Xcj1ktZBeP2bnDz 5Z/qO7ysuMmG7di6Zz4/BoYSUmwyPdTHre/VhkwvBGiTW4y68+C5J/um+ZtIs14IxYL0 oqSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712765201; x=1713370001; 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=i9EgoEyF4/rVzoPOi90aJqArCNPBQ3SZoaAZfVVHCyA=; b=ayn8A/NLOSRWjvsw5vXv78Ycv2z942yDpfnCcl/r7mc13L0Q9I+DwKOdg1n4iBkHuV yp6p4NnR3MRHbotgzGxR28cJeQQ/OWaubtTu7eTBT3o8fWq7HwZ3gnYYQEVBp9jhZ+HZ Y2+LhEn170GTKTfGsKSMxEHFt1wBEBY8saWwBtYHaxRRCu+pUqC57oROueXvo1eVVwyH QGKbZ0yP4o2lcIOnDFN4IQerGKCGtzgjaB2zlp87zS/WsF646+vdWnSKIdcp67qoLlEY vxwZJjCDRoHpc+v2dSIzZ3GDR+5Td2/9vQjYMXFe6lArxhgB2JJXPsyUNwvOR7uYakPc vwGg== X-Gm-Message-State: AOJu0Yxuozxf7EthuH55cu2giKIkEaTOhjA6yZNgDXSNw5sJpLDBjWD4 7Fs3xpbCiUEbkD3GScMwAux9lHWyauQxlXhSY8MOLhqZmMX5zVcas/tSFoD8ERCMGFWhfBEna2g v X-Received: by 2002:a17:907:9302:b0:a52:9e:45c3 with SMTP id bu2-20020a170907930200b00a52009e45c3mr52304ejc.35.1712765201134; Wed, 10 Apr 2024 09:06:41 -0700 (PDT) Received: from m1x-phil.lan (arl95-h02-176-184-34-173.dsl.sta.abo.bbox.fr. [176.184.34.173]) by smtp.gmail.com with ESMTPSA id gt17-20020a1709072d9100b00a51b3d4bb39sm6059337ejc.59.2024.04.10.09.06.39 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 10 Apr 2024 09:06:40 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, qemu-arm@nongnu.org, qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Aurelien Jarno , Jiaxun Yang Subject: [PATCH 04/12] hw/mips/malta: Replace sprintf() by g_string_append_printf() Date: Wed, 10 Apr 2024 18:06:05 +0200 Message-ID: <20240410160614.90627-5-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240410160614.90627-1-philmd@linaro.org> References: <20240410160614.90627-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::52e; envelope-from=philmd@linaro.org; helo=mail-ed1-x52e.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. Extract common code to get_rng_seed_hex(), replacing the sprintf() calls by GString API ones 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] hw/mips/malta.c:951:9: warning: 'sprintf' is deprecated: sprintf(rng_seed_hex + i * 2, "%02x", rng_seed[i]); ^ Signed-off-by: Philippe Mathieu-Daudé --- hw/mips/malta.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/hw/mips/malta.c b/hw/mips/malta.c index af74008c82..095abbf0ec 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 *get_rng_seed_hex(void) { - char *rng_seed_hex = opaque; + g_autoptr(GString) gs = g_string_new(""); uint8_t rng_seed[32]; 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]); + g_string_append_printf(gs, "%02x", rng_seed[i]); } + + return g_strdup(gs->str); +} + +static void reinitialize_rng_seed(void *opaque) +{ + g_autofree char *rng_seed_hex = get_rng_seed_hex(); + + 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 = get_rng_seed_hex(); 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 Wed Apr 10 16:06:06 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: 787519 Delivered-To: patch@linaro.org Received: by 2002:adf:fdd2:0:b0:346:15ad:a2a with SMTP id i18csp767202wrs; Wed, 10 Apr 2024 09:08:50 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWRSRCtPA6uCANJ4rUhfafS1lTNxyiunK71RtdCXubqwCqU/cV9zhu3uBCfsmxtfz9ERWSS2ZACYZLvARm6FWs5 X-Google-Smtp-Source: AGHT+IGt/Xc73SVSk4FGmjxwJFKpZ0dpRg7JO5cZwG2p5bczoUfbVL8//qCoE5xUcN/lBjhs9oGO X-Received: by 2002:a05:6214:e64:b0:69b:10cb:f607 with SMTP id jz4-20020a0562140e6400b0069b10cbf607mr3850601qvb.29.1712765329755; Wed, 10 Apr 2024 09:08:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712765329; cv=none; d=google.com; s=arc-20160816; b=KEBHZuKWHxp9apDVOuK5Qv8EbQUBqtqwyrsNxWZpPywF4+7/1UMTz9SI0Kr6DQdHsS SpCLk2HKrmTWCVQV47gyH8LF83lr02i8tzS500gFInvwPTHIe1DgLInlJSUaZpbcCiRk KGsyA+wzCXg1z/VMgCHZ2rGZeOwcbbmcggvHXAX4idlFEbtnTdh+t6z4WBYyF+QGSAD9 gHXJpIG7p0awybocrYQA0DO7oiRdVU/KfzAXIX6btWDUGQnxLGRYMyk4AeZfFEtbBScF A156psQUmFVmCewhq3q5Eufb1gIu2GnhHGLuV2snNKgLybh8u9WP8cjaRKDKkdIhIQgl av/Q== 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=r5X2EE/M3HTtZrcc5pc+aHgL0l0ZN+IEz6DvlLDGmqA=; fh=ANY1Rh01eNrDTN2DlkuCxtLkQX3H15Mkm0Tjd3WZ3jM=; b=aYVt+Tt2EWP1Hvb9yxF+8qeU9IJcOEam+cFbc/v8xALcWbXam+cI1sYBShGgoWZvAa AgwFn46bBYl7tgdfbIot1SG0IiiKKVPgieuBwnhO/FxeTF3D38A6lJJ5PGi+bw20KqS3 7TNARClQpykal3BTtcCx8zACL/H5B37RBVo+m0wMArHDuSazGceMC/O7nW5s4bTYbRpQ 2k7rJitlScuSKzZmyOpEWcqHLeHgEXx43TgsEHfEWwaZ/YBR790rXhNrhy9PyDYxO/bx 2g2OvHnIOJGzSfK26K6d2qDAICsgxMJeGJ5GlUorc9i49ra/19eBZJdEaR8Xck6zAZ+2 zw/w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UtA37+7o; 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 14-20020a0562140dce00b0069b1a67026bsi7922265qvt.177.2024.04.10.09.08.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Apr 2024 09:08:49 -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=UtA37+7o; 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 1ruaTO-0000Nb-KW; Wed, 10 Apr 2024 12:06:54 -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 1ruaTL-0000JR-ED for qemu-devel@nongnu.org; Wed, 10 Apr 2024 12:06:52 -0400 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ruaTJ-0002gI-TZ for qemu-devel@nongnu.org; Wed, 10 Apr 2024 12:06:51 -0400 Received: by mail-ed1-x532.google.com with SMTP id 4fb4d7f45d1cf-563cb3ba9daso6967947a12.3 for ; Wed, 10 Apr 2024 09:06:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712765207; x=1713370007; 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=r5X2EE/M3HTtZrcc5pc+aHgL0l0ZN+IEz6DvlLDGmqA=; b=UtA37+7oTYMelq7k448ihPlbDkjYlIPJzSwz8VumbZKf/pF3hexQo6SsttMoHUdtiK YMgI/m5zkMOng3fTE9EdsLwljdiNCcaYWLUyAmfMBJtLAB5+I1EqJ3dOxOUeylCN4P2A NSCp4tJ+QB8Kz/CZD8yj3QVEWVRdgKtqVBvCHD9/yQ01Hd8wcKDqu0b9+XvXammHPPV4 8jWqxoFIdyCOEcYvoxbtbaEd+gu0YilUoTws2W/QBevcyVcJ1ZYF1f5p8L6nbL+BLoEa 3uSNMwIAYNS4jhEQbqqMfYudjctp0SJYk7k6gP+xQ8JggrInNmMzT876qIwe9Tu0krCE i4SA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712765207; x=1713370007; 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=r5X2EE/M3HTtZrcc5pc+aHgL0l0ZN+IEz6DvlLDGmqA=; b=ZYwFhOdDKlzj7Cgkj2Lt6BT04IimJmswJ8gLHBnV1rzQPlQH31K1+8E22BVKk8+kTO Y18qtV16GMy5qsL4U4WvwdJnl2Z1zbhS1uwrNFdwi/DT+88hAUiF9uRF+p5rkaeSxn5m xCBfzmL17Ybb9DmctutCJaS0lfin3j5X6dsOuq8gI/Y1mN2A4CjilxHOB+jSeKSlHv3x fdRO5PTF1ZbSsEEGTFVeKyRrE3EGIRynxUXM6uyxcH6sA6QiPt5z3moG5v1I5rSGFN9k noujOOARyIxYBSSCPL6sr1nwZgrT5tT/4IEZs5y8KDNx4BKIgrqB+F0nFV+CwGGILuzK U2FQ== X-Gm-Message-State: AOJu0Yx2wUBeqidZf7eC9yrg7Ozf4p5PBy3krmbMDh0cYEoSkz0vdSk3 kSL7Ljj60iz2vMD2/uUUmJm5WdSKY1d8aebv3GbTT0TIHZbK3BzuLTrTYU299KRHPOvFV4ZDTLS P X-Received: by 2002:a50:d613:0:b0:56d:fdb3:bcc0 with SMTP id x19-20020a50d613000000b0056dfdb3bcc0mr2519771edi.11.1712765207148; Wed, 10 Apr 2024 09:06:47 -0700 (PDT) Received: from m1x-phil.lan (arl95-h02-176-184-34-173.dsl.sta.abo.bbox.fr. [176.184.34.173]) by smtp.gmail.com with ESMTPSA id k11-20020a056402048b00b0056bc0c44f02sm1268403edv.96.2024.04.10.09.06.45 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 10 Apr 2024 09:06:46 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, qemu-arm@nongnu.org, qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PATCH 05/12] system/qtest: Replace sprintf() by g_string_append_printf() Date: Wed, 10 Apr 2024 18:06:06 +0200 Message-ID: <20240410160614.90627-6-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240410160614.90627-1-philmd@linaro.org> References: <20240410160614.90627-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::532; envelope-from=philmd@linaro.org; helo=mail-ed1-x532.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 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 --- 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 Wed Apr 10 16:06:07 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: 787521 Delivered-To: patch@linaro.org Received: by 2002:adf:fdd2:0:b0:346:15ad:a2a with SMTP id i18csp768063wrs; Wed, 10 Apr 2024 09:10:16 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU/dlnF2c809qlmbrjpSekH+MZvlpw5O+UVqnvmBjy7v0r1HlUPFKxV0akF7kqts3LuDAEwQZZNtkcFnediLcoS X-Google-Smtp-Source: AGHT+IEUVE6IRwbhNXuxs7yP9v3Rvzi5QytB8czCKRtlw68iuJr4jUbQEV2pQo5y6pOeeatmyXWT X-Received: by 2002:a05:622a:11d2:b0:436:24d1:574 with SMTP id n18-20020a05622a11d200b0043624d10574mr1569706qtk.56.1712765415840; Wed, 10 Apr 2024 09:10:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712765415; cv=none; d=google.com; s=arc-20160816; b=BI1Z8hbzE5QxW+4uzm8IWMb9x8PkOtXD+LVjLNK/CK0s6r4+9WiSackNb7Gdq1kL8D /IUTUyik8Ch4siUViCaXaT5jtD46NZc4QbA1coqhCO6CbRxoKoIk8rIFQfxmr6uKKr6/ gkFjhvjz2tLIs7CTVMty5cBHZ/b35BI5SqLjQgyvFQSn5Klt4QClMQxGrPooT1u25jHJ 8gfah47kQHuxStQOxUKt2J+k2XPM7gHWFwPBbaqHl5MvtleuQSOkpP317xdqrZ4hkE+A H8hnPtaCygOl6mBmccQDFODogNlfLaHcEUQYzxBN0+1dR7L1cdH7L1Y3s3q2zivH9Si0 iYTA== 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=giPTBnUjI8fArjIax7+V4Zbn4iy0n9Mu/MOvDTvHtS0=; b=n/xykR4ZpCuixoWZI7fVuDPMY+Laiqzu0DXPLXD+i2WIYPyj2ZzIghlyrOsk68Bzzd 5OymuFGLdd6k37SlJ6sKzWTB9ECt5tlA5JXwQeptp9pluSmk6ESFkcXcKui8jYaCvpW+ FjyPzqiJRCRy5yASHx9AXAbsaX53kyuJ8GVKnFUu98KNGfh2PSVSoEWjyJfQT0oPUegR GoYozq1KwSRCx6mEiJoUxOym7Xhm+xkfeWGIuDFzlJKGM8U6gVggQqMzt96zyvOM+T6C HCgpb5RP7BEMm9VR1KWyaCuJuYVG7KjEBJlBC6bkVigEB8EmEJHCOMEZjdKk0LJsKK6I 7R5g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Tsg5YHeD; 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 d4-20020a05622a15c400b0043653903ac1si132835qty.91.2024.04.10.09.10.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Apr 2024 09:10:15 -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=Tsg5YHeD; 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 1ruaTS-0000Qm-IA; Wed, 10 Apr 2024 12:06: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 1ruaTR-0000Oc-4E for qemu-devel@nongnu.org; Wed, 10 Apr 2024 12:06:57 -0400 Received: from mail-ej1-x634.google.com ([2a00:1450:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ruaTO-0002hR-PY for qemu-devel@nongnu.org; Wed, 10 Apr 2024 12:06:56 -0400 Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-a4715991c32so932330166b.1 for ; Wed, 10 Apr 2024 09:06:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712765213; x=1713370013; 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=Tsg5YHeD7mSxw0UaB4lmQ1RUfRORqL3+j2KyD6Vu2/XuDjHcO0YO+TYkMhM6rk0EIC RC2VfbvzMyslhfAOnOujjDJu9iKxbGSR3KXO1m/zYa6Pkd0dJrmN4xS1Mam3soSz+GXj WK0nJ5kpWVVU1nD7Rxh7phukWj6bfEqGekmYwI7q2tbdYv8pe+k4M1KU+QQth/RMjJj9 51jCiQUgg0YOS4Hx7Q+9IWbcrOqP8qBqPfsmtRM5eBIzQl2C5IUyqbGeBy6+vUzWnAGZ 8uRPh7SU23sdZmchB/L5Mqg2NOvfOI/MDjgITP6sL2vZaTwhTvmqENKCCzk/mPElE1hR 3QYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712765213; x=1713370013; 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=NXvIv1Nnsnusk28E1G2ughHHo6aG8OkrFq0vwBY6ggdVGOn7C6Nj7PRREp9SIadJRU MfOUG1HdIyaBz2yK5upr1GcDDoYKO3UdyZ8S8StrYwKHfZudeGJFw0yOr/J+j9M39fut eVynQkdDxQvSap3M4oEalUUmK+tLx/4miYCPIlrJyoAeVChfQHfAk/yclhgX2+AqCGu8 HMxMEHZvhYuAYBT4r98EWK66N20GhfPlbGnqkV9A+dm4XPSfELpZ7/q4IIvtdeODFeC7 VpvviYz8UeYiRaGpU7nnMo61I7es0xpibmt2OPK8waPEv1mkFPTF1W2rQeB51hjr1NWc fSog== X-Gm-Message-State: AOJu0Yx7W2ovaFKOZrKt60F65KJGTz/PlXoVz/FIdN3YPiVrNrHzkbtm 8j6oKMeIR/aGTVSE1wP+ErRQwCyTN6kfcB5aPRTQcEWudDqUzR5F5A3m9uDsZ+PI7Z01n4dGtEu C X-Received: by 2002:a17:906:2a91:b0:a51:8540:c671 with SMTP id l17-20020a1709062a9100b00a518540c671mr1832686eje.50.1712765213206; Wed, 10 Apr 2024 09:06:53 -0700 (PDT) Received: from m1x-phil.lan (arl95-h02-176-184-34-173.dsl.sta.abo.bbox.fr. [176.184.34.173]) by smtp.gmail.com with ESMTPSA id xh13-20020a170906da8d00b00a51c0c0cb86sm5506389ejb.22.2024.04.10.09.06.51 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 10 Apr 2024 09:06:52 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, qemu-arm@nongnu.org, qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" Subject: [PATCH 06/12] util/hexdump: Rename @offset argument in qemu_hexdump_line() Date: Wed, 10 Apr 2024 18:06:07 +0200 Message-ID: <20240410160614.90627-7-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240410160614.90627-1-philmd@linaro.org> References: <20240410160614.90627-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::634; envelope-from=philmd@linaro.org; helo=mail-ej1-x634.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é --- 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 Wed Apr 10 16:06:08 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: 787515 Delivered-To: patch@linaro.org Received: by 2002:adf:fdd2:0:b0:346:15ad:a2a with SMTP id i18csp766729wrs; Wed, 10 Apr 2024 09:08:07 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXEFGrnFyRCCtQ7zw08M4z57Kyjwcjr9TwdpcF4KXAHsv2qp+sqK5gXUfmvzt3b/1MGXPNCOZ82QeMedg+50FJV X-Google-Smtp-Source: AGHT+IGWxvvyqwzfYogB1kzHLGGjqfBRy7Krz5ZO5kCKr0rKh4tUx8W+KkjmRJ/aONrm+3sUCJk+ X-Received: by 2002:a05:620a:4152:b0:78e:ba0f:d07 with SMTP id k18-20020a05620a415200b0078eba0f0d07mr1803513qko.18.1712765287330; Wed, 10 Apr 2024 09:08:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712765287; cv=none; d=google.com; s=arc-20160816; b=jE4bru+97q2eKhK2Zs9+3R9Aac5ynss0LZrVxEgUweWVdb/pHWt2KCvvLVfmyLkm1V FUvH8ZaPimtyKg9V36pRt8piyPs0cVGmbRkMYn/84c2eZWDWnmLzJ6EX/83MKsU+6T2J c/kUql6KT6XumeY/p6D3DEYafFaMyYcfoZ3AjtXDVCbzRvjpEQLwDryKpzbd9wSMj5GQ LaTlI+C+KOPrlxvKprLLsyoUhnQbhkOQN2PbNC5j8OM90mCvbEv2N6r1SdgnnkK3Y8T9 IuEWJw58ro2j7HwVE1XnNABuunx0S/6YV43As65vZ5RQuuWrIjwXql3IqkzSy5MGpfbo P2jw== 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=giPTBnUjI8fArjIax7+V4Zbn4iy0n9Mu/MOvDTvHtS0=; b=NN1ItTKnKY87jj7KcUZv/8UjO1SOmRu4mwJ9M+QJWx+1QdhoKKKlA+e5Tkxv3oFoT9 feRaCuIFbjXkoiQFZt2YijjIarIM7b/+ksrjX9DgzdtFmv4lh1JGaNHCCDs+1ZvARy0M O0zZplD+LytuCjEiAqCScsMiwwc0T6rP+q9RRK1Ntt0pgm/edq3mYk0znKxl7EFfVsb0 z+Cr547LTqdkmWXfBOpNuM+gUNyWjCt7yjU9NG9qGvvzeeGLUzxsA9IUasqUMOaBQVaL EamN0WiIoqGoYhsNcsWglc0IUErMqPKhx1w0m+ZA/u+JC31ra9bSzFcOb8YtJ21uXCPS A+Yw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uBKqE6xB; 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 e8-20020a05620a208800b0078dba304ed7si1582037qka.423.2024.04.10.09.08.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Apr 2024 09:08:07 -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=uBKqE6xB; 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 1ruaTz-0000Zr-Q1; Wed, 10 Apr 2024 12:07: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 1ruaTY-0000SK-CS for qemu-devel@nongnu.org; Wed, 10 Apr 2024 12:07:05 -0400 Received: from mail-ed1-x535.google.com ([2a00:1450:4864:20::535]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ruaTV-0002iU-LA for qemu-devel@nongnu.org; Wed, 10 Apr 2024 12:07:04 -0400 Received: by mail-ed1-x535.google.com with SMTP id 4fb4d7f45d1cf-56e6f4ee104so3288120a12.2 for ; Wed, 10 Apr 2024 09:07:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712765219; x=1713370019; 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=uBKqE6xB1DFp/3Cl4RBPdgOBXi7v8hIAJH1Blz6plkPcSoURFlI/JYJvWCBauO4oje t3xjuf37JYjmTlXaVKPOT5s+J+FiPTAakrkZj215VL5PTr8j+dgwrz5D1C35rw82Ayfy bCAGHjH1HOhBzDSa0T+jSOxR0CGlemc049QD8ylHUwin0m3V9yR09LXH67B/uMxEfoLp 79fDgWhZy/Wnx8jDkYG2omddV348EgtcybYiBLLb+zBgB38xZIx47gTEqln7hl6zMtzq fZGDRlV3VHkraWXCNpNbUxMRwzWECf92PXkCGTxF+dSQN1yCibV5Jcv4lqo7jkGTwrQJ p/Lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712765219; x=1713370019; 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=ISv+YFlhyNmKA50KEtr/+Vrov4yQJJ7fUfIt9+9H4k6d9GSwMBOcbw06tPkDMRR1e3 xi53KRdX1q43ILZRGey5m885MDXvaa6Pii7KCuvPTjdJklgfdFX6SUOLednX5zsIp0MN amvMnXQEBMPh6jOfnoFf70QMFaxcvWJLB82NfPgqFv5gZjLnu+fJtZGoxNGjljzfxIcS VulMvJNxM8QO4KD5ux5ZswohhOCtbXUtM20fwPphOkyl2Gcnu6oHR4K9stgbGhIrdpfc nXSJwPTapBazMRNENRqoS+JkWQdKYr7n2JX+67cXYZjgg5ft5rnU3fTt7c3gES5yduQ5 BstQ== X-Gm-Message-State: AOJu0Yx6Lfqg1Wo3ecxCe2WpcryoXPJMCRKp3OjsBqcRiFWdU11Czunc RfOP7FYco+uFJnq2gBvFKyJcBNNWpfIdDcl/ohtk4FUleaO6gR4qwINyyFBz2D1wnbHufVKUmOh X X-Received: by 2002:a17:907:7e97:b0:a51:b0e1:863f with SMTP id qb23-20020a1709077e9700b00a51b0e1863fmr2426735ejc.13.1712765219100; Wed, 10 Apr 2024 09:06:59 -0700 (PDT) Received: from m1x-phil.lan (arl95-h02-176-184-34-173.dsl.sta.abo.bbox.fr. [176.184.34.173]) by smtp.gmail.com with ESMTPSA id t1-20020a1709067c0100b00a46aac377e8sm7089906ejo.54.2024.04.10.09.06.57 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 10 Apr 2024 09:06:58 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, qemu-arm@nongnu.org, qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" Subject: [PATCH 07/12] util/hexdump: Have qemu_hexdump_line() return heap allocated buffer Date: Wed, 10 Apr 2024 18:06:08 +0200 Message-ID: <20240410160614.90627-8-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240410160614.90627-1-philmd@linaro.org> References: <20240410160614.90627-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::535; envelope-from=philmd@linaro.org; helo=mail-ed1-x535.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 Wed Apr 10 16:06:09 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: 787522 Delivered-To: patch@linaro.org Received: by 2002:adf:fdd2:0:b0:346:15ad:a2a with SMTP id i18csp768058wrs; Wed, 10 Apr 2024 09:10:15 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXu0/d+bCzVdfhTBft3QVutocLUaavLy8uHs514c6+NPo+CIYpfxkFIR/rj/1BbthPko332y3wM84MzQqP6g3tI X-Google-Smtp-Source: AGHT+IH5C37qPMVwvLJazxrqpVu5tgYvF3RekF6h9JzAA0kzVKLERdq3bEfhSaVHlLP/AhEwnTxv X-Received: by 2002:a05:6214:d87:b0:699:24ab:f0b4 with SMTP id e7-20020a0562140d8700b0069924abf0b4mr3455850qve.45.1712765415803; Wed, 10 Apr 2024 09:10:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712765415; cv=none; d=google.com; s=arc-20160816; b=c/BgmLrP1zYi3eribnRNCbb1fUTTuNGfLycf5i5wdV6SdanszV/n4wCH3DgHKRx0jt Tt/h+YwHbalv9Rm84GDNNPj0sZEU7U3TtwQnjDxbmLex0RodrUHjZB+QosmgdhWsAuFR n2Oxc4HYyN+OHulED+XwGOUCqlye78kpWG3sZ/o1YUjsNwD5JV9HiQpOs+3WDah31eRi UOIgZIghgm5AZLVaWk8VgLkM0TOUzpHbf97RetR+1NzvrV1AzdChMSKHy2J8C70THIcY vsD7CFRhdZJT3fZYDOVlb0411mGNlCrhfgUImKSPOkt/rpUPywat/m6eWKNQDTyB/SgY v5xQ== 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=EimFR6qyD8jVRzrypR3qdir+LX4teJrOzdaO3aqohIA=; b=wGQV+OAPrlYTTLMdbTKV3e9SjKIm6mkzg8wR+YfdReZYq+MdJLZYC7yfhL0HL9+9ry MwuNpab+bmSkpzMFRxnYbHsea4vX4rI4wHiMp4PvbVfdBNEP2veNvPyM2ABuRzdglkZ7 bRJXA/ivuHIY36CrL+rK0XMnwBqQjCP6VpaLtoCMJ8qtjJVTIPQrk1GoNQTVeKuFvrkn w6wyckjl/jS1Y4PC+ZxNf36fGcVy1O7RWrhpZ6mwDflAmZfc0MT4uzjwB7KSKxXMHfml y/TopXl0VrqDSH+R/3zr+jq84y2QZnsrnrj2pgz0pZyQ5JSqXXROizbm+ZAhpMUJLsLz +t0A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=h2Nwfwv0; 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 f11-20020ad4558b000000b0069946e09e78si11430757qvx.115.2024.04.10.09.10.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Apr 2024 09:10:15 -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=h2Nwfwv0; 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 1ruaUC-0000tq-Ok; Wed, 10 Apr 2024 12:07:45 -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 1ruaTe-0000U5-89 for qemu-devel@nongnu.org; Wed, 10 Apr 2024 12:07:12 -0400 Received: from mail-lf1-x130.google.com ([2a00:1450:4864:20::130]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ruaTb-0002ji-VB for qemu-devel@nongnu.org; Wed, 10 Apr 2024 12:07:09 -0400 Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-516d47ce662so9312614e87.1 for ; Wed, 10 Apr 2024 09:07:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712765225; x=1713370025; 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=h2Nwfwv03c1Celk2hdK5rW1ihxBBnc5LWQlUr6GnhPejS9vwlvrTCr4Mu7rgM7fsCB MPEI51DqhMjZk9tF5HpZ56cuaXZ1x/1dzxx8njrFBjepEszeO1De6Qa1nAF17liBKbKC 2lZDIEOyT/unzLaOJJu0Gghp+Zglpwj1uorIDsro2N8O98wpeEyOmah1oQ+nvVlBY7cW pSJHglYGsVgEik18RLzvdJLBvz7UuUGH7HjhNV/oAGgMrHB2wJtSYB8ow7IVqfltC6AR RWkw742YYAqeYuO5q3oxrCXlG25bZS+2cYG5fDKVPKxsDRA5F7FXbcp2hzY0Mk9pNA24 k7mQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712765225; x=1713370025; 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=jlfR9d+HzjqPb1aM/USnTzRYTpcX5QMJzdpI1fVLTfDRd27YfefvGeNWQ0Me+GP7YN qHA8ZvxGn5e4KQPp7ymIwMQno35DhHGNwSGnG1wHVZXHMrFsmOLJaQRbIYx1k6JRNbDJ 832hDYncIWkg/PBGBVclMZ26/mDr6dykdb0bmas8ZXSz741i7Vt3WeJr9UQYcsfBonMr gefFW+3nNFrEWgXTwYlcIAvkRTNbwDB5ImxkWdH/Bx8sEid00O+yAb7FsWM43KkjGsJQ a7A6gEm8n+AnVxY3YnIts/cbB51+UKh7vrLw9jXFnJZ6ewUF5IRP7Xo7HpywP+65ylU3 SZKQ== X-Gm-Message-State: AOJu0YxyjdrKkQVZtULsSOgW9gHG8lKt2c+pkYfpDxAJS+QmdWCIKbLo elptMFFTetw4CW4ALXFLgkHzDwRzoGOFTK3b+Cinnl3mrENTasBbIY/dVNbU8YBy8wRoPicABzO t X-Received: by 2002:a05:6512:ea8:b0:513:cfaa:e618 with SMTP id bi40-20020a0565120ea800b00513cfaae618mr3244047lfb.0.1712765224777; Wed, 10 Apr 2024 09:07:04 -0700 (PDT) Received: from m1x-phil.lan (arl95-h02-176-184-34-173.dsl.sta.abo.bbox.fr. [176.184.34.173]) by smtp.gmail.com with ESMTPSA id r16-20020a170906281000b00a52196cce80sm58124ejc.121.2024.04.10.09.07.03 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 10 Apr 2024 09:07:04 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, qemu-arm@nongnu.org, qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 08/12] util/hexdump: Replace sprintf() by g_string_append_printf() Date: Wed, 10 Apr 2024 18:06:09 +0200 Message-ID: <20240410160614.90627-9-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240410160614.90627-1-philmd@linaro.org> References: <20240410160614.90627-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::130; envelope-from=philmd@linaro.org; helo=mail-lf1-x130.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é --- 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 Wed Apr 10 16:06:10 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: 787524 Delivered-To: patch@linaro.org Received: by 2002:adf:fdd2:0:b0:346:15ad:a2a with SMTP id i18csp769787wrs; Wed, 10 Apr 2024 09:13:09 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWRd1iAJ9sv6ntRtvt86yW3LFCq2vmSleS4a9J12WNbYwmOQ032iQhN3ZISbhQuYeE3i24JUGhARZf8W5/6WQMd X-Google-Smtp-Source: AGHT+IGYLHuWhHaY0R1cIJgIIwCIL7L2aDTOU0YMiIF64yo5O+MGg/KuJJDESCUAwK3jmFQ8AO53 X-Received: by 2002:a05:6820:1b10:b0:5aa:5457:c5f7 with SMTP id bv16-20020a0568201b1000b005aa5457c5f7mr4081787oob.4.1712765589710; Wed, 10 Apr 2024 09:13:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712765589; cv=none; d=google.com; s=arc-20160816; b=K+w7b+Bi7PLbbSGW9hwszdjtQay6hU5YOesv3Cr7whi3frN0JXZ/4Dc7RwuteWCT7Z 7Rnp2sGuyR1hY46c37Dh22fX7USZeKqXY4h2T3WhoqgoOySzXAgHieBX2HuDUjUymJiE q7o7Yl6OcdEd1xmTGglPALk3lrlgj7gAhM2Dqx0rX5V2KIzO6BkJKPFSbUMI+BuA+/dg mcXM79jT4g5HYIV5T6iMGDDdIFERcjOjiawjx85lRL5OVEqUxdUIbB6UGyr7NwfOW6M1 rvnLvJ6+lmmRwpWKfm0SgvZAU+7zS2hjxRqXBf+EeT8yIqDTUWtBp0YziyTc3pUGc/nX 6+nQ== 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=YFVGCxpzDNSk/I4Sx5czuIx/gHz0oN2Tm8cjWcs0zN8=; b=vI/r+QLJk8tF3eKpZc0N0suhZRUyOFWAXivD2ppoSYgO8HVCvSkSWlPgD4BefK/+Fa /0iUwb/y6UmwiJL1H4QmMxNaWsARpE4dcIyovyLdvb7NfemyJcqOPFwyWM8XIke2rkfX abqtH7UZQ2gdgDA7Cqirf6AOmmmIHY4VoRNHTOXY8qiR4gSJiy/oxb0H0ho8TmyR2fKY 6dWnLkeeOE05lFeYptfsp6RhsmxRPcwtoIFFQrgpVNHxdMGB4r8MWgWKNva0zilSYSpR PuCmsJfReC7+8NpcO//4RmEcQ3pyGX2VN7BD6aoTTYO31Mxo2PvKHNKzZOBwS/HABB/S vsuw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tOOc6QyI; 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 d11-20020ac85d8b000000b004313ff9cf1esi12756957qtx.330.2024.04.10.09.13.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Apr 2024 09:13: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=tOOc6QyI; 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 1ruaUQ-0001H4-O1; Wed, 10 Apr 2024 12:07: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 1ruaTj-0000V2-IC for qemu-devel@nongnu.org; Wed, 10 Apr 2024 12:07:22 -0400 Received: from mail-ej1-x632.google.com ([2a00:1450:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ruaTg-0002kP-55 for qemu-devel@nongnu.org; Wed, 10 Apr 2024 12:07:14 -0400 Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-a51beae2f13so504767466b.1 for ; Wed, 10 Apr 2024 09:07:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712765230; x=1713370030; 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=tOOc6QyIpBcgIP8g3gYoYZOb16yecid/rvj5ulN9defoMP3d8AC/czHMkyE6IPWErW zjbJCyALT9qxtj2dweeVHGRG/tKYE9ns1hHmbnNBGqlu0Ke012m/g/FOyvW8dQAxe7kF xAi70GYAXbJpOz366h5Kjgm10oLo5VrPYi3yw6hsjBNTm6R73HJTvt1HVaC51XZ27bfV O6kscC2e2Pid0h8K01Umx7ER/GU9RZJ5dS80wdO22jOLloMv2dQ3RfpFX8XQWCYO95cb Lil3ZpE/fHNa4MvsLfeqAQsEoBOQwf4fQxYR6k+cCDJCKbWaDG5ApD1Mza5z+sWN5F1L 31Xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712765230; x=1713370030; 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=DfFZDuVAB88nBTF/hGdWNxDOSDcF2ECnyaU3G9KQyYmWy1B/2DDvMDUgqrJ+eSW//h 5T/CBFDK2LchtqbSsXWrogjj6IeujpHnIPnVNoQslA6uCmiKEI1ff75CJVamRjoXFuDy E+OEK/tot+toC7Gt2Yid2oYUFBuKptBaoG0LzYxA4ik6ha+vvIXjiEOtMAzh8aE0iRao TveEeC4bQ796RSEh6CheLPmJ5lIHf4GGKJUffthi1DIG92eJEpNn05Cq0OIJyB6ahM2X 2prhRAbZOcjSPQhCjNsaHbdQROejh/6Kst+hcgGUR70g5I1NhvCBk3n79KtQYtZ5G8CC CauA== X-Gm-Message-State: AOJu0YzbX6a9WRZ/PmLHk9cmVi0MO+RMDDeTTJ+Y5HmKvwkYqekPLkl6 mk45fbtaA8ExpCbATiuElRY6k8mQAVxlFW7fT3bq0wVtEvPFNneDCow2hYNfMYiJpOs6yPeWMlg o X-Received: by 2002:a17:906:118d:b0:a51:913c:1c83 with SMTP id n13-20020a170906118d00b00a51913c1c83mr1864645eja.58.1712765230578; Wed, 10 Apr 2024 09:07:10 -0700 (PDT) Received: from m1x-phil.lan (arl95-h02-176-184-34-173.dsl.sta.abo.bbox.fr. [176.184.34.173]) by smtp.gmail.com with ESMTPSA id k7-20020a170906680700b00a51e5813f4fsm2662622ejr.19.2024.04.10.09.07.09 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 10 Apr 2024 09:07:10 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, qemu-arm@nongnu.org, qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Paolo Bonzini , Fam Zheng Subject: [PATCH 09/12] hw/scsi/scsi-disk: Use qemu_hexdump_line() to avoid sprintf() Date: Wed, 10 Apr 2024 18:06:10 +0200 Message-ID: <20240410160614.90627-10-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240410160614.90627-1-philmd@linaro.org> References: <20240410160614.90627-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::632; envelope-from=philmd@linaro.org; helo=mail-ej1-x632.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 Wed Apr 10 16:06:11 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: 787523 Delivered-To: patch@linaro.org Received: by 2002:adf:fdd2:0:b0:346:15ad:a2a with SMTP id i18csp769231wrs; Wed, 10 Apr 2024 09:12:13 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWHPVLNCSMWn2xGS1arW+NmgguhwkqdnoQ/IN0GFDtMnr3Cw6ybcsRoy1g42LQCOMYkzgKBL+Fi0IGNPiN/zJd8 X-Google-Smtp-Source: AGHT+IF/cy6LyLcuj1XtFF+ffnIKvKPGYcR74p/F3Vq01A6hGD7qml2+hVLzJQeZYy1FIw2pVrLH X-Received: by 2002:a05:6870:d8cb:b0:222:11f2:11d8 with SMTP id of11-20020a056870d8cb00b0022211f211d8mr3495369oac.26.1712765533104; Wed, 10 Apr 2024 09:12:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712765533; cv=none; d=google.com; s=arc-20160816; b=juKSC5j6znJcYtJ8wABbP7HSs7TRzAcGq0xhSsTnCAbJUBXXlc3eBOeyNtQemZFLfY rGybaVXt4qBLW0Srm6n6ITc/Aqo3ENaHZbY4OiUjwzSbJqoRKGaLswJFSteQ9ECiCphv LvtXQfZfkzcWSyz9++vCAgjbZgqMc8wKuZwdG/9B+PTnRjapi0xGLMq+a89QFBiLJKYs zqUfhvKEHLn1cHGejy8OA+pO0rF4WtAJPbk+DuG30xBgVErN+kTLhxlwtnMm7Zt4hOA2 NcdMR54fkCBrNKI9KBMKcrOeWB6NugDVSueRtaWHaHz50vmIuOdEwNZ7VeGOd6VMq2J5 D0fg== 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=v1F0ucs5PgVUA+L3P2Sg+Drf9UWIyAl4BUdR386OT2Y=; b=b/PKspJ0HdJfAw2MUTrTSrt1HjKQj5h/yBIHMjYoI1QMz4l4uyeHEuRAQzLUWJ1qwY J0ZBFEQBwbM4q3SkETmLyf7wN/hx3HJh1xX8NLxGzW+0R4rP/Ci8kIAYULEl9Xj9OgD8 NnT2In1aQZgeiDlrd/9ir9As9Bw++141DeJngceXqIpt8wULl8UplkCy2ceN+XW6XiRt UU9cTBokMgKz2Q0PKBFQAV3ES1LUNzQJnn4P8NXKerhnswgMMlqafJxlSHyvfSXofSq0 5GtT218QuaT7iT4671qgzOlvqku/mpGs1V0IhCtXJBAZaJLVkrgh3Vy8hl7suwgDKwfr LEoA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="JVdI3/bJ"; 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 h25-20020a37de19000000b0078a3910418fsi9611229qkj.73.2024.04.10.09.12.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Apr 2024 09:12:13 -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="JVdI3/bJ"; 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 1ruaUV-0001V8-OY; Wed, 10 Apr 2024 12:08:03 -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 1ruaTr-0000XV-71 for qemu-devel@nongnu.org; Wed, 10 Apr 2024 12:07:23 -0400 Received: from mail-ed1-x535.google.com ([2a00:1450:4864:20::535]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ruaTn-0002lD-IT for qemu-devel@nongnu.org; Wed, 10 Apr 2024 12:07:21 -0400 Received: by mail-ed1-x535.google.com with SMTP id 4fb4d7f45d1cf-56e477db7fbso6642908a12.3 for ; Wed, 10 Apr 2024 09:07:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712765238; x=1713370038; 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=JVdI3/bJyAnRiH7HM0mKCBnRJihYXsZIOUsDWSD3sC5DjVTt6pGKrkp2JfW2S+DWmE adeWdhxLYuUs2HZexMoICMxAusqGH/0ogO2zYoLDb4bNcfjMmii8BcYH03bCNxJEPHg/ aG9kkuGQJoDa0DvRO9zbrZYyhC/pLa3W4AmbcNktrCYyafp3z+T5hkZUwSrQcRsd8aDq ff5fBygq0kgRXVrd9+1Oyk+Yx4vvKVcFffYrBYmAbOo//pRMeHkJBLg1XtDLqpZ/7pPy xlh651SeqU0Ykk+SzGq4HJsy9KDfJ5y3lXFO1hKuWI+DuYQ0sj7wKBLtO5NEC18v6oR0 7/Dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712765238; x=1713370038; 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=sRrYWvSF0NqNB6J56Fk3ChGKMMcj3wpJhNR63Zs0kK4OKVOaDdU706Ql5tAbW+uhJJ 1oR9P3QWpWyW3R/B5wiepcAjWhyuVssb7Z/DM4Il/izDdRp9Llq2345n7V1NTWwWwP5C +S5jtFHgFzgl3QQzhDXowUxG3QMRnG20KUfzULdJpVf98vv58AT6FRros0wEXGa4oNoe 2DLmm1F0xUpxiVkdI/GmxYRJRz6ObhwT4k/WxbCtndOwxM5d0fd+IUU2mf/HGpLXRapL cSXA6zUCQ41qbAoNMm6y8fMn/n3ljOybSbsKgF42JG3yaEPkDBzJA+ePhayNtjVqaM0Z +24Q== X-Gm-Message-State: AOJu0YxtnDGpCeLf3Cm376W8T/+YgXvh68hnPVxjTX7uOZKnTdXQgtyQ LMcq0i/+DHXpQ3O0FAvHGnGMCh6HPORd2wCq0n3GG+B8xAQpXCuONkUkQLTcDnjqKV5y8QXrGhD M X-Received: by 2002:a50:d6da:0:b0:56e:230b:853c with SMTP id l26-20020a50d6da000000b0056e230b853cmr2079454edj.15.1712765236469; Wed, 10 Apr 2024 09:07:16 -0700 (PDT) Received: from m1x-phil.lan (arl95-h02-176-184-34-173.dsl.sta.abo.bbox.fr. [176.184.34.173]) by smtp.gmail.com with ESMTPSA id y9-20020a056402440900b0056e3707323bsm5824580eda.97.2024.04.10.09.07.15 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 10 Apr 2024 09:07:16 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, qemu-arm@nongnu.org, qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , John Snow Subject: [PATCH 10/12] hw/ide/atapi: Use qemu_hexdump_line() to avoid sprintf() Date: Wed, 10 Apr 2024 18:06:11 +0200 Message-ID: <20240410160614.90627-11-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240410160614.90627-1-philmd@linaro.org> References: <20240410160614.90627-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::535; envelope-from=philmd@linaro.org; helo=mail-ed1-x535.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: [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 Wed Apr 10 16:06:12 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: 787518 Delivered-To: patch@linaro.org Received: by 2002:adf:fdd2:0:b0:346:15ad:a2a with SMTP id i18csp767188wrs; Wed, 10 Apr 2024 09:08:49 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUgrHjnaeAH10MP+wMZAY46+4qs30voO7hYQoap7otYkRrmvcaujZHlqiTw+nCkY1NKDuiAThPDflo7fScC3Pu3 X-Google-Smtp-Source: AGHT+IF5OPujDGefcqv+zAYsKkMEkSn2IwKTuEd8RtmFUJAEc83dRae9hg/YTCcJkTs+e9DB/vE+ X-Received: by 2002:a05:6214:230f:b0:696:aa14:4998 with SMTP id gc15-20020a056214230f00b00696aa144998mr2590271qvb.36.1712765329147; Wed, 10 Apr 2024 09:08:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712765329; cv=none; d=google.com; s=arc-20160816; b=IJ8VV27+1R87Ows8rC+owirRs3jN45pP+sqR4k9sObtYHYWdnAKCX7peQ6N50XHJAs 50L8I6eZ/eAKUSZlDak6KNpgt5Ihp7FcrG75BNyWZ9lZ2IeVOUb8C3hXTEeZw1ApSOnm qiFs5thOSptPJ3PFZgPpaiCanEj5JiAqh2dQu0WfWqxF68mYAsufzW4D6i0uA0r63Z56 oNWShQzoJ/o9HJ/Lx3vp+bSc0N6eCJNI08fYVLseLfw4eCluOTXv9/UlVifCbS7MikZP v1CefCFnc5tqjOHi1HSyVZJvhbT1FhD2ZMPwv0kNEbHVxGhEXVQvi7/7jr/iCuWQMfPp bZ2g== 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=KcgGHOG6QoaQYwB2Xdi5TqZnppgbC5zrvabIMQVEDYw=; b=iJ0tha6gJzXCMXxasmtbwlwAGTc4fjDp9aLbfme6xskmA5OK28t/uERwoGhopCWw+S trSS2MD17iH3TYY138VqkhoLkhwzMXMwC544YocCxLqAR7N8L/SuJNIeMpvXqC2kr1Rv BoQK/ywJIC9CfBRMWaJQUP75CvXcUkCenPtHTcIfbhvdYSCP+8Ydw1n3nNizE/W9Wrt7 JnyO1nl4v/6hSQWZXZYknrll1ggr04Niw/gn9/8SLfZBwxB8bWLdzltqGFHct6MkPcxb 6V6B1OeENqYvF/ho20hA0HyiXQU84vQDznlD5T+d35FdBzPwNTUb+CAl5AKYRlU8djdS UCHQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=N3xqMDZa; 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-20020ad441cf000000b0069924c862b5si13132349qvq.43.2024.04.10.09.08.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Apr 2024 09:08:49 -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=N3xqMDZa; 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 1ruaUY-0001dq-Hb; Wed, 10 Apr 2024 12:08:06 -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 1ruaTx-0000d2-On for qemu-devel@nongnu.org; Wed, 10 Apr 2024 12:07:31 -0400 Received: from mail-ed1-x52f.google.com ([2a00:1450:4864:20::52f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ruaTs-0002m3-DY for qemu-devel@nongnu.org; Wed, 10 Apr 2024 12:07:28 -0400 Received: by mail-ed1-x52f.google.com with SMTP id 4fb4d7f45d1cf-56e2e09fc27so10177013a12.0 for ; Wed, 10 Apr 2024 09:07:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712765243; x=1713370043; 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=N3xqMDZa86/KP5ggtImz01ldF4iYqq1O/1aPDpU/g5ACAmFPzq5uiSis1u2+9L/bkm qGEBLC9m/hnwCawX2VvXnEhXg9CIINrlGhxPB+5VUtmztX4lWGe5fD9hkakefQC5f598 jyAbg/MgNU/wXok1Ea1HVbFO60yPwJR2hOeMfI9tsD268EY6k3uyI0clXS42Ff/NJLYZ aa2btk2SvXbTBu+Eee9KA0EcyYBKIibfdCum/bVmVz1T95d6SaBKw5QvWwtClEZZirX3 sDzHGdz1CME7S7ZBgv53EbwH0faF2Dv/dfBDtso1uXwgB8guvaf3Eq00P4H+IBz4pnTk yjsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712765243; x=1713370043; 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=gSofnhx0o6UKTft5dd1/OfqKLsGHKKT61vBltyKTIde1Pm6UQPYa/90G+nWsnZVi4Q bbs6zWbT29BsUnhfITncXAvEiDZUX5fwnnn8BRTPIU6fzc50LIijahWThMdMKIFWL3Ai vZ0d7zJv9zL9eo/FzZ1a5JQHvm0bmgjGaItcT0hnyvOpGaP8GrUkQS/XlY+Rav7XDUPr EwGllY2l4svQ/BZaGpLRlOMSjN2jG8Z6vzokSB6hoRDLvLmMqmPOLtS3mC6nYZ35PKTI pwAEA8sLB47zfi+bRPsqDB8T+oK6DUWsYJJqflxnQk8A8bjtfLJskb67eJLy3IuG4rCk JXVw== X-Gm-Message-State: AOJu0YwoNoNGRFZFAR9QXoBLBa+nIRXk4xRhtA8mIIz+8vViKttc1jDd R9EhWB7wjkQSjcNi2FpRDa9/SwHMqd2q80VH4DL+v/xMb5InjUhLnJvLlaLwy4OQsFHMlmm8Duy T X-Received: by 2002:a05:6402:1955:b0:56e:6fcd:bae7 with SMTP id f21-20020a056402195500b0056e6fcdbae7mr103914edz.5.1712765242764; Wed, 10 Apr 2024 09:07:22 -0700 (PDT) Received: from m1x-phil.lan (arl95-h02-176-184-34-173.dsl.sta.abo.bbox.fr. [176.184.34.173]) by smtp.gmail.com with ESMTPSA id h25-20020a056402095900b0056e62321eedsm3669224edz.17.2024.04.10.09.07.21 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 10 Apr 2024 09:07:22 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, qemu-arm@nongnu.org, qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell Subject: [PATCH 11/12] hw/dma/pl330: Use qemu_hexdump_line() to avoid sprintf() Date: Wed, 10 Apr 2024 18:06:12 +0200 Message-ID: <20240410160614.90627-12-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240410160614.90627-1-philmd@linaro.org> References: <20240410160614.90627-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::52f; envelope-from=philmd@linaro.org; helo=mail-ed1-x52f.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. 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 Wed Apr 10 16:06:13 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: 787520 Delivered-To: patch@linaro.org Received: by 2002:adf:fdd2:0:b0:346:15ad:a2a with SMTP id i18csp767960wrs; Wed, 10 Apr 2024 09:10:04 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWYHjR6x32bRvlRZl1EBe6hpV7+ALF7K9ZK9xZipp1uxmoKucTLZJTs97GHUxBonhQvut8l2Mx//badoqyUQDbT X-Google-Smtp-Source: AGHT+IE5GYpSQ4E5vb5VcvxG622eMrIwDfs7pu8WGzx/Q2pFJsWCsQ3fBjGYx9xwkqOKvIVY4I0/ X-Received: by 2002:a05:622a:1911:b0:434:6721:440d with SMTP id w17-20020a05622a191100b004346721440dmr3468337qtc.22.1712765404094; Wed, 10 Apr 2024 09:10:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712765404; cv=none; d=google.com; s=arc-20160816; b=fFW53/cpcwqEWfrH2DncfsrOJdhRdJ7NUCQasotDu5URklkGo1t5L8Zqm7F8nhiRq6 gKj6AEXI7gGaD1LUeUPisqd/PMZ27t3JHuCpFun9R0u+bJnWeMXI5xaFVh0oPrR4LtWF lfST0CezgEoVH+eGPfIT3brSNMkmY6SCwKGSqRx3AP9S/ERWSndH/+Rh30pgpdeCvgHu /TVzjCALKY7YhIKwaymY6dKC5gRssAx5d0Y6vtfYy5bOoOjsplzX1RZrZ5Jk26jT/Wqt aQinnOHDN0MiDgSdFaW2wU/e5Qp+hCBHHMaiKtwbFJus5H5TgddvZ3ExrNyhFDZa2H1/ ANZA== 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=UeYRJP22yetpo8HRu7YHvf77//gfViY+eu8d75tRzXk=; fh=V2AlPqyEGFHWZtkFD79KU2F2BfDuVznhZc3W4v14hIM=; b=nhaHh/sl7cVX26YNH77kBsFWtBYkOR6/mAa7xKBxHTDpJ74mMvl/BGnfWiMH5FAkZ0 RjPA5Ve7FDYC016Cp4yClAWd1wrCSbcttaLtzb8fu1QnRV82v9Jv6HSRYPUCOKNdiXFW fgu1iAFmFJUIGZN8ynfTGzkR2PwJYHK4sOZ6N1uR+uaohta0SA60prs5SZbAMiokB7wF llBd/CdX13XHbeHYYiLkzUZ0quPTsDGLybfJNOelZNdbWujtD0/r9V8wRIAbmbESEgba XycaBvhYiqs1V4wQ51esmL2XU/gZHxRq2tU4ifyixQXOvJvP+yoPuC6Ih3uup6IUTxni G1vw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=b7WGxMpv; 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 dj21-20020a05622a4e9500b0043181621de6si2019063qtb.253.2024.04.10.09.10.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Apr 2024 09:10:04 -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=b7WGxMpv; 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 1ruaUf-00022j-Cy; Wed, 10 Apr 2024 12:08:13 -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 1ruaU2-0000jQ-Po for qemu-devel@nongnu.org; Wed, 10 Apr 2024 12:07:35 -0400 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ruaTy-0002nw-3i for qemu-devel@nongnu.org; Wed, 10 Apr 2024 12:07:34 -0400 Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-a51beae2f13so504833566b.1 for ; Wed, 10 Apr 2024 09:07:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712765248; x=1713370048; 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=UeYRJP22yetpo8HRu7YHvf77//gfViY+eu8d75tRzXk=; b=b7WGxMpvUr/7JNYG7q1dBqA/OJlwdZUXwVuWRnxSxhnn3lgpettZWZSMLCgJiKqhGa C39tTzpF6U3NpH+dk3hs9Yem9VUGa8qlvLGQ+hBGB4S0gS2OXnoLGngUToPFUbuSEe2x It6Kv6qQMJ3n7QsvBkowxAc43a6K3smjB4PC+Sgwye4YtLa7O1BdhCRy0HX4Rq0G2QtZ pcSA0Ie3T5zZpDKP+Vezp8hup5koLKp/RmarX2jddUz2GnuZ9anizNgd/3qlFrbj8thL 8GhIq0Bc6cPI4LqZKW306Ql6+PhKiKGZkd2SSKX74tb3oEI2udkMWczsNCoNRPEo8Wck /ppQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712765248; x=1713370048; 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=UeYRJP22yetpo8HRu7YHvf77//gfViY+eu8d75tRzXk=; b=ZkUhTLgtXbspKOoGNHQjpiwYfqefHbaM1ttUz862THZEoLqtOX/9zsSnmiRYSCieJ9 7JLcZXLiTjchsdDrNihMFhznzH3M4ConVz7jAUS0vgcDKOnQGv5jlrL6TsuRfAa8Y5gI oxyqB3gq1gn0yXyHXpQxYMorFsw+aQ9S8ldRLYhPGjVkCjR3SPRXJ41HKd3Sh9LWxdAN YV+tytv9Q32CmetYj9lm6rh62nk84whJ+rpF+ZJjAxwdOtJw7Hl4yZM0ME5P5ezLp8uL TTqsedpl3Ud6NG6FtnDie7KPpQosWUkT9OWzvnIqabaQ3MVpD5YvUJwVP2nmmqJMdED8 hzEQ== X-Gm-Message-State: AOJu0Yzb7Sm9wnuvTom31WrTnie2Ls8RLU3eOsQn72sU8T/LNDzRW0Uv dDQM78TR/bdSC2BnVqcX9fLZS4Fb9XIK4/y70hauJDgmnqBtnaE8mEggpZKP1tlNHaNvhz3JtLD Z X-Received: by 2002:a17:906:7f19:b0:a51:b752:7ed8 with SMTP id d25-20020a1709067f1900b00a51b7527ed8mr1556519ejr.25.1712765248441; Wed, 10 Apr 2024 09:07:28 -0700 (PDT) Received: from m1x-phil.lan (arl95-h02-176-184-34-173.dsl.sta.abo.bbox.fr. [176.184.34.173]) by smtp.gmail.com with ESMTPSA id re9-20020a170906d8c900b00a4e6750a358sm7054546ejb.187.2024.04.10.09.07.27 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 10 Apr 2024 09:07:28 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, qemu-arm@nongnu.org, qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Stefan Berger Subject: [PATCH 12/12] backends/tpm: Use qemu_hexdump_line() to avoid sprintf() Date: Wed, 10 Apr 2024 18:06:13 +0200 Message-ID: <20240410160614.90627-13-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240410160614.90627-1-philmd@linaro.org> References: <20240410160614.90627-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::633; envelope-from=philmd@linaro.org; helo=mail-ej1-x633.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); }