From patchwork Fri Apr 12 07:33:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 788260 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp591073wrm; Fri, 12 Apr 2024 00:36:28 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWUsatOd/HEB4nKCc+abm6tGn7/DNWap1oAG5RSwm14FYySU9UkbpkaLVsHXJAAOz3cO9D8Z6dmUyObVyMqdI7F X-Google-Smtp-Source: AGHT+IFSd3aKSgzbFNIl+nlB/2Gj5QosuJYrHCO4WtSC6r1yxdDp5FVytzw4Yh2tgphmK7oI9i+W X-Received: by 2002:a0c:c605:0:b0:699:1657:ec70 with SMTP id v5-20020a0cc605000000b006991657ec70mr1961644qvi.12.1712907387907; Fri, 12 Apr 2024 00:36:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712907387; cv=none; d=google.com; s=arc-20160816; b=hPOb/pPBMHIRhw3w+EfKOVHSH9zJbn1nrLvIgHxlV2emlCnHnhPLV7p3JhOSo7PPo8 Yniw52LeR6+uBh96IB/nlLjOoO6kgyqjnqqysKpa1Ei+VdaymTrgN/v2SvWVnXkODC7U EwPyWSUJTnjMeYWW+kn8rHpn6HAFX/QINdn5wNsO1QOfMDLaDL5OJ0WS64Dri++X7krI pPFEPNvLHtLWkdKs3rTU65TT7CN3HXpxkPgBpNZTKvg+9n8RZZCrfjxIY4eZWgw/gDba VuKxRBrNkAfOSfCvNSYnsdyHu07sW6/UFw4LEHchzgjJHaLjuOAqzWYfHRY3LcpzViez hQzA== 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:to:from :dkim-signature; bh=ISGCLEDJVFZiUeSj505TnpSQiQ8gRVs+fhfSNIPx8Ks=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=O77s+8Eq5glk/NjDLPFMFah6wtullZMZizB2OSRkWbTd0O7u/lEHy7/tqnyphrDtta YnnjegorI5yF/Etxj53XGnn+dZQU+z702/qoVgoUwYUNAWhSWvcVZ09L29If4JLdS0u+ VkEqWifzRIjNWFauzz21TBFo2Yi8g+G/Tyv9I+zlMBLuuad7a0dJW2wb0x81Pdj/BcmN sbbQI6IB3LO9DX00cKk18MQ4PNNTraa8IFO/Fdnn9hNg0/kIkAaVqoySqlpuTLPoYXfs 3OD9H+1f8QpN/N/tPECr7NRpx+h8F2EMR2BnAZjI8V2+CQZ0UdCmiy91MyIiqcKjXhAz mBYQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RaCYFfs3; 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 h5-20020a0ceda5000000b006993b807a27si3056672qvr.169.2024.04.12.00.36.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 12 Apr 2024 00:36:27 -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=RaCYFfs3; 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 1rvBQ2-0006yT-JI; Fri, 12 Apr 2024 03:33: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 1rvBPz-0006ww-OW for qemu-devel@nongnu.org; Fri, 12 Apr 2024 03:33:51 -0400 Received: from mail-pg1-x52f.google.com ([2607:f8b0: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 1rvBPx-00074a-Qf for qemu-devel@nongnu.org; Fri, 12 Apr 2024 03:33:51 -0400 Received: by mail-pg1-x52f.google.com with SMTP id 41be03b00d2f7-5ce07cf1e5dso421993a12.2 for ; Fri, 12 Apr 2024 00:33:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712907228; x=1713512028; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=ISGCLEDJVFZiUeSj505TnpSQiQ8gRVs+fhfSNIPx8Ks=; b=RaCYFfs38nvxICiWQCl6+45MYFyfzIsrBmBLs9NTtKTwIZH3tc47PtZauX4mEkGNYA DE98YqDOiTkqh5RTEISNhWensMSu2B7LVLG+Z5oauXSX1z/+pkxVeqHVmVhZdHGERbNd 0nQ5tZQlBmyUND4KSzZR94C6rkTVcD/+3xN6xjPF1U4hHGvbrQ39K1Ewsfjxd119qykO DO4Psm8O7cOTzot1isbzrffti0CelbxuH5r71sR8ylpynUntvIWzpptMA1oJC1eSFIXs 9MkhcC6KI+Od1OlNE8NXM1tGIV36uT3HUo+uUav0Dd/AV1VLB1phu6wB3jb2U/fOpDfI Dl5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712907228; x=1713512028; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ISGCLEDJVFZiUeSj505TnpSQiQ8gRVs+fhfSNIPx8Ks=; b=ZG5W/G34smriHMz+CdxtSmc/vFBAeRASJVL3+crunjQTTuDRxSOCDV+H8PpIkx8yAb 6xhpwKRjFgtVchYKO1GHkvkUMdVBNyhpplOlGzg9JTDsTNwFruSptIdNS6bQvHBI0pjz 4Yw4JfhhNdHg0jrXfnOuZ557uZH8DSayDxsmbQXfHAhe7Lc1G0PEXZSn+OfpLNL11GUe G0wSHj09vHdmnpbXweGiMZgAHMbowXhE6eD0lg/YXWZAPhWHlyuWe15F+gAr13z4o0Cz xtp2qhpgURJ/dUw7mqwNdfowUj4cNh6YiFM9GurE7gJTTuYej0Zy8K/y+mPEgXweMnPR 2TKg== X-Gm-Message-State: AOJu0Yxx2IOdqSXXN9f8YJyyDdi9N47DGS/GoxnrPsEOlRhnnvcQq9Hm iCXsec+kkgFMUNl18pAAzGxkt7aKiwWO6s5i0oS93Dz/jH0C7vKw5Cam6JbMFDHCxSxSFG6VveS S X-Received: by 2002:a05:6a21:3e02:b0:1a7:9adc:86de with SMTP id bk2-20020a056a213e0200b001a79adc86demr2025603pzc.20.1712907228329; Fri, 12 Apr 2024 00:33:48 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id e5-20020a17090301c500b001e556734814sm2206099plh.134.2024.04.12.00.33.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 00:33:47 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 01/27] util/hexdump: Remove b parameter from qemu_hexdump_line Date: Fri, 12 Apr 2024 00:33:20 -0700 Message-Id: <20240412073346.458116-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240412073346.458116-1-richard.henderson@linaro.org> References: <20240412073346.458116-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52f; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-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, 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 Require that the caller output the offset and increment bufptr. Use QEMU_HEXDUMP_LINE_BYTES in vhost_vdpa_dump_config instead of raw integer. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- include/qemu/cutils.h | 2 +- hw/virtio/vhost-vdpa.c | 4 ++-- util/hexdump.c | 13 ++++++------- hw/virtio/trace-events | 2 +- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/include/qemu/cutils.h b/include/qemu/cutils.h index 92c927a6a3..3415f5d249 100644 --- a/include/qemu/cutils.h +++ b/include/qemu/cutils.h @@ -257,7 +257,7 @@ int parse_debug_env(const char *name, int max, int initial); */ #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 int len, bool ascii); /* diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index e827b9175f..b4afa142f6 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -946,8 +946,8 @@ static void vhost_vdpa_dump_config(struct vhost_dev *dev, const uint8_t *config, for (b = 0; b < config_len; b += 16) { len = config_len - b; - qemu_hexdump_line(line, b, config, len, false); - trace_vhost_vdpa_dump_config(dev, line); + qemu_hexdump_line(line, config + b, len, false); + trace_vhost_vdpa_dump_config(dev, b, line); } } diff --git a/util/hexdump.c b/util/hexdump.c index 9921114b3c..7324e7b126 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 int len, bool ascii) { const char *buf = bufptr; @@ -26,13 +26,12 @@ void qemu_hexdump_line(char *line, unsigned int b, const void *bufptr, len = QEMU_HEXDUMP_LINE_BYTES; } - line += snprintf(line, 6, "%04x:", b); for (i = 0; i < QEMU_HEXDUMP_LINE_BYTES; i++) { - if ((i % 4) == 0) { + if (i != 0 && (i % 4) == 0) { *line++ = ' '; } if (i < len) { - line += sprintf(line, " %02x", (unsigned char)buf[b + i]); + line += sprintf(line, " %02x", (unsigned char)buf[i]); } else { line += sprintf(line, " "); } @@ -40,7 +39,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[i]; if (c < ' ' || c > '~') { c = '.'; } @@ -58,8 +57,8 @@ void qemu_hexdump(FILE *fp, const char *prefix, for (b = 0; b < size; b += QEMU_HEXDUMP_LINE_BYTES) { len = size - b; - qemu_hexdump_line(line, b, bufptr, len, true); - fprintf(fp, "%s: %s\n", prefix, line); + qemu_hexdump_line(line, bufptr + b, len, true); + fprintf(fp, "%s: %04x: %s\n", prefix, b, line); } } diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events index 96632fd026..d01bc85037 100644 --- a/hw/virtio/trace-events +++ b/hw/virtio/trace-events @@ -50,7 +50,7 @@ vhost_vdpa_get_device_id(void *dev, uint32_t device_id) "dev: %p device_id %"PRI vhost_vdpa_reset_device(void *dev) "dev: %p" vhost_vdpa_get_vq_index(void *dev, int idx, int vq_idx) "dev: %p idx: %d vq idx: %d" vhost_vdpa_set_vring_enable_one(void *dev, unsigned i, int enable, int r) "dev: %p, idx: %u, enable: %u, r: %d" -vhost_vdpa_dump_config(void *dev, const char *line) "dev: %p %s" +vhost_vdpa_dump_config(void *dev, unsigned ofs, const char *line) "dev: %p %04x: %s" vhost_vdpa_set_config(void *dev, uint32_t offset, uint32_t size, uint32_t flags) "dev: %p offset: %"PRIu32" size: %"PRIu32" flags: 0x%"PRIx32 vhost_vdpa_get_config(void *dev, void *config, uint32_t config_len) "dev: %p config: %p config_len: %"PRIu32 vhost_vdpa_suspend(void *dev) "dev: %p" From patchwork Fri Apr 12 07:33:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 788273 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp591433wrm; Fri, 12 Apr 2024 00:37:47 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUROD14RfdouBRRA1Dt+z9ZzMSxvyjKZtENho/8EdddlfawFPbYLTUVn4S1rn0EGmoTUOnUnbHUKNZb70YT6VbY X-Google-Smtp-Source: AGHT+IFcEYODSFwei6TxOSEVjwEpDippNfmFsL0XWVuagHtrWihUgA0Ok06R0juZssmacYhxsEH/ X-Received: by 2002:a05:6214:92:b0:69b:247b:a4f9 with SMTP id n18-20020a056214009200b0069b247ba4f9mr2069627qvr.6.1712907466990; Fri, 12 Apr 2024 00:37:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712907466; cv=none; d=google.com; s=arc-20160816; b=Aus+l428+9D0SaTXNSyOkhtXlIylo5a6yge7rr/n4wspOJJWVwCISiQgMiWl8Xun0+ 5JoXcOxXqRkAudVRIoVsMULnu4Gdj+EzbGjf8RQ2sX9b+IaXqaeHpaJho8bQJ5OIbB64 Cc8TOQroq5td6bmnauOIQ+Ja9meclYdiSfyttG7jVV9n59iy7bwnYtLQYulk1G82euVK QOoKBQC+B3HMp3nJotudVeGHqRo/9wom33eF/qTDV4aP3w5cvkRi8c8ySWIKdAH1GAjI Rf5ipByoDkFWfE39+D8+P33wmLnPP58S3GEp80t9L3sZYC/XOnQXPBHVuUPpmJqjM0jq 9KXA== 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:to:from :dkim-signature; bh=+WtY4DsJRn2jEDsEW21TOMqrULwYncFBXOs9a6AYGRc=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=gGSda3D9sKJwNn7vzXKZjgNBvOYRJ5M3TFV8WZBeTyco0txFJdWUco2pZbn5VnDXsb bW+nSU2wBuPRfy7G+iqVCCVDAjz2sui3IfejrUdkvFqxRZ8D4lNOiNkVMYSRyQ6p4A90 RRQDQttED8wv/EyWeJVrUiVz4TGGuZS0R0RJRYiVanCKLcJvcVS/MFFcSD7l7Yot2d/7 rBSo2NofXPF9iSlPciSjOCt8V4NUAAyG29RSpdr6RvUNKTYT0+qrivtY5ZSIkbE7AwNx U8Bqb4gSsChcUOPQmCIfFg9H+vNjMVyQh5PRMKk+MXUa7i5KUEBehK7XZLK7OlxQblLz 3U0g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=efqxISQZ; 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 l14-20020ad4452e000000b006993ae9d630si3112306qvu.369.2024.04.12.00.37.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 12 Apr 2024 00:37:46 -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=efqxISQZ; 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 1rvBQ4-0006zB-77; Fri, 12 Apr 2024 03:33:56 -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 1rvBQ1-0006xO-4u for qemu-devel@nongnu.org; Fri, 12 Apr 2024 03:33:53 -0400 Received: from mail-pg1-x52f.google.com ([2607:f8b0: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 1rvBPy-00074g-DC for qemu-devel@nongnu.org; Fri, 12 Apr 2024 03:33:52 -0400 Received: by mail-pg1-x52f.google.com with SMTP id 41be03b00d2f7-5dca1efad59so451629a12.2 for ; Fri, 12 Apr 2024 00:33:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712907229; x=1713512029; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=+WtY4DsJRn2jEDsEW21TOMqrULwYncFBXOs9a6AYGRc=; b=efqxISQZfqOPZjn4MTPsnHQcAkoNh3ktYf1OveUy2/hMVh0RRqO6jwblvv/3JIU2eF xqBxUHyS/WZml8f427Mx0fo5KuzpM3vgRM828wuclKCgmyZFr+r2qxAmL6aY52fDxWAI OxuhKGyvt5DNhHaBGDHtVjW71ewJEJLxEbCHPGY5ix9bQCBe2FeH2nR+pEy9k7ygrcga Q0vrzV0le61GpptaqrKT1Cn5fq/48uqMVR+sxkfLoiHFo+z5JK75pbpdT7zzM6qCCj8b Zsv1aExQaPosk+DUD1Orb97M++FUTI+mX1kVcGNs9pneeULOmmLH67rfZifgt+dSYk87 3jKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712907229; x=1713512029; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+WtY4DsJRn2jEDsEW21TOMqrULwYncFBXOs9a6AYGRc=; b=tDLU1OSK886T52h6Ae8nmqyYHG5T4AtTtdMiCEiU96doNN0KbQEhUslfJNsiPcrcj7 uCtPMAAVK9nNWH3fvEBom9S/1DC5xckKET6Vi89Ynv1SsgSPScAWgAkNYwQxwRTQ3Ksz +52ly/9fIOk/nWRp5w2nS3zCTSftCxqPgRe5Ik7SVI1AdDYUo5GPrqgi6olAqoXDbj/0 sy3rSFdJaiJnbhbr3lovfU7lKymMVApJ8ErTmy7EjPUdjT8P66ngqQPxUgouRUp+iKB5 sHL3w9CrBnwyghPQYl3omntCEV5stytGlji41yf95BuzfrA4CsDea9Uzn5kfEf5UH3S9 kLmw== X-Gm-Message-State: AOJu0Yyz09xBwnMvo8/zqrwCyjV3UNcBRp7pOHQ1n0UPrWVlioLy1PMo i55+lRzd9XRVHAENcLA2O8O8S41ZUEDQ8CMiidk5slxWvioMh1svIum/H7nv2uvrqS5kQvSJ9jZ O X-Received: by 2002:a05:6a21:151a:b0:1a9:b3e9:a62c with SMTP id nq26-20020a056a21151a00b001a9b3e9a62cmr307545pzb.48.1712907229154; Fri, 12 Apr 2024 00:33:49 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id e5-20020a17090301c500b001e556734814sm2206099plh.134.2024.04.12.00.33.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 00:33:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 02/27] util/hexdump: Remove ascii parameter from qemu_hexdump_line Date: Fri, 12 Apr 2024 00:33:21 -0700 Message-Id: <20240412073346.458116-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240412073346.458116-1-richard.henderson@linaro.org> References: <20240412073346.458116-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52f; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-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, 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 Split out asciidump_line as a separate function, local to hexdump.c, for use by qemu_hexdump. Use "%-*s" to generate the alignment between the hex and the ascii, rather than explicit spaces. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- include/qemu/cutils.h | 3 +-- hw/virtio/vhost-vdpa.c | 2 +- util/hexdump.c | 54 ++++++++++++++++++++++++------------------ 3 files changed, 33 insertions(+), 26 deletions(-) diff --git a/include/qemu/cutils.h b/include/qemu/cutils.h index 3415f5d249..d0c5386e6c 100644 --- a/include/qemu/cutils.h +++ b/include/qemu/cutils.h @@ -257,8 +257,7 @@ int parse_debug_env(const char *name, int max, int initial); */ #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 int len, bool ascii); +void qemu_hexdump_line(char *line, const void *bufptr, size_t len); /* * 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 b4afa142f6..32bad5ce68 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -946,7 +946,7 @@ static void vhost_vdpa_dump_config(struct vhost_dev *dev, const uint8_t *config, for (b = 0; b < config_len; b += 16) { len = config_len - b; - qemu_hexdump_line(line, config + b, len, false); + qemu_hexdump_line(line, config + b, len); trace_vhost_vdpa_dump_config(dev, b, line); } } diff --git a/util/hexdump.c b/util/hexdump.c index 7324e7b126..dbc536fe84 100644 --- a/util/hexdump.c +++ b/util/hexdump.c @@ -16,8 +16,7 @@ #include "qemu/osdep.h" #include "qemu/cutils.h" -void qemu_hexdump_line(char *line, const void *bufptr, - unsigned int len, bool ascii) +void qemu_hexdump_line(char *line, const void *bufptr, size_t len) { const char *buf = bufptr; int i, c; @@ -26,39 +25,48 @@ void qemu_hexdump_line(char *line, const void *bufptr, len = QEMU_HEXDUMP_LINE_BYTES; } - for (i = 0; i < QEMU_HEXDUMP_LINE_BYTES; i++) { + for (i = 0; i < len; i++) { if (i != 0 && (i % 4) == 0) { *line++ = ' '; } - if (i < len) { - line += sprintf(line, " %02x", (unsigned char)buf[i]); - } else { - line += sprintf(line, " "); - } - } - if (ascii) { - *line++ = ' '; - for (i = 0; i < len; i++) { - c = buf[i]; - if (c < ' ' || c > '~') { - c = '.'; - } - *line++ = c; - } + line += sprintf(line, " %02x", (unsigned char)buf[i]); } *line = '\0'; } +static void asciidump_line(char *line, const void *bufptr, size_t len) +{ + const char *buf = bufptr; + + for (size_t i = 0; i < len; i++) { + char c = buf[i]; + + if (c < ' ' || c > '~') { + c = '.'; + } + *line++ = c; + } + *line = '\0'; +} + +#define QEMU_HEXDUMP_LINE_WIDTH \ + (QEMU_HEXDUMP_LINE_BYTES * 2 + QEMU_HEXDUMP_LINE_BYTES / 4) + void qemu_hexdump(FILE *fp, const char *prefix, const void *bufptr, size_t size) { - unsigned int b, len; char line[QEMU_HEXDUMP_LINE_LEN]; + char ascii[QEMU_HEXDUMP_LINE_BYTES + 1]; + size_t b, len; - for (b = 0; b < size; b += QEMU_HEXDUMP_LINE_BYTES) { - len = size - b; - qemu_hexdump_line(line, bufptr + b, len, true); - fprintf(fp, "%s: %04x: %s\n", prefix, b, line); + for (b = 0; b < size; b += len) { + len = MIN(size - b, QEMU_HEXDUMP_LINE_BYTES); + + qemu_hexdump_line(line, bufptr + b, len); + asciidump_line(ascii, bufptr + b, len); + + fprintf(fp, "%s: %04x: %-*s %s\n", + prefix, b, QEMU_HEXDUMP_LINE_WIDTH, line, ascii); } } From patchwork Fri Apr 12 07:33:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 788261 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp591097wrm; Fri, 12 Apr 2024 00:36:32 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVIyulxJQwuuBH9aNf6KOpCBj/Cz1+VxmyKWi/tPkcO0ttdsIqzhW1TWCNAk5iQ87hSoOYMSrTaUQAqnxjmrUIh X-Google-Smtp-Source: AGHT+IF4xqvo8Ys9UfU5CKnKzCbTB+2eNPIzbS4pzLqGUi7/r91NVqdudTwcYsJJtPC3/yTczEBD X-Received: by 2002:a05:620a:13c4:b0:78e:d154:2ae9 with SMTP id g4-20020a05620a13c400b0078ed1542ae9mr111433qkl.63.1712907392065; Fri, 12 Apr 2024 00:36:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712907392; cv=none; d=google.com; s=arc-20160816; b=aUexHtncmhDN4JXF2vj2gHtElzSyNTiffhUExZyl9nJSYfWWneipB7ykfVwqUquJq6 e3rKmlnHoVDuH8C9EXeOk6JMLTWi0Aj9u8TA1HtZb9NRTqcDUwHVTO+qjVmLjiLCa2UG dDLkotszN4YDvs4Jzmi6BbzPudeUgT+5BwJ6DUdi6tYIRB4MVqLNKaxa1N7qt2aPfghh 3x4+qFW7iQOpfLTO1BuMuOy5bPS+qb8/3hTGWmkRtcpl/HkUkdhbQvQh/p0pQlkaArc2 2R1tnWxY+r8RPPjrQYuM4trOtRyipawJevGkLF7DGmhiFxtGJj8I4Wxy1gkUAa1rwZkz N0YA== 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:to:from :dkim-signature; bh=q7LRFqckZoWWz6WECvkgu9IuYe9DhqTySxBwiAwbY30=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=VG7ALYGZj3oBHpRX8Nun8xN3s5I0ObtQk+IuhUjEemqAxQYjsDzRrs94pbZ85KQ91L W5BwbrioJ1bzs97XaXs0uL7/eXPHDw6R0Mp9Z0MtJmIRBwg8KZqTu8D1Asrx3RhJQ697 hPP50Sy49oBzsDhGg7/hErOXeawBd0KdNWTDjn6mvs3zpnfb3K1uDorJWPy5gouMW8hh r48j3eTiTsls1UfpU9T51UESkngZM/wlIE16UG5uU+mFe/Oux/TkqeeHWXYYnol+jK1H ZowuERL2N3Rd3jX0ytCyCkI9ZN0l+09+JWPI1EboL2O5fl6zVmtixUcHLJ6tNTqGCl3+ afnA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ji1OwLEq; 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 a13-20020a05620a16cd00b0078bc5363c35si3125556qkn.259.2024.04.12.00.36.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 12 Apr 2024 00:36: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=Ji1OwLEq; 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 1rvBQ2-0006yU-J3; Fri, 12 Apr 2024 03:33: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 1rvBQ1-0006xY-Cm for qemu-devel@nongnu.org; Fri, 12 Apr 2024 03:33:53 -0400 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rvBPz-00074k-7X for qemu-devel@nongnu.org; Fri, 12 Apr 2024 03:33:53 -0400 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1e3f17c64daso5125995ad.3 for ; Fri, 12 Apr 2024 00:33:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712907230; x=1713512030; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=q7LRFqckZoWWz6WECvkgu9IuYe9DhqTySxBwiAwbY30=; b=Ji1OwLEqenHekJ5WeWHeaRXRfrT88eaNY5bBL/LziJFECT8hpPCiLFkgvFBSoXHBmm 17SVvvvIXayIIkBX2MFT9S1iG2iSAEJtQEqPfTTQQLjrQ1sQdQZ5iRLLi4aPxDtZy/jA ZGWrkNAvpbROhTTAh5ZFG6xMNVtDfNmTx1I5Y1eViE2maVZdBwJ09cD4V/e2Xsj1SbAU wUohtZNNsx7hwRofGKNKqdl/SU4aEp+ic1sXs+j82ocFy0c7niv0ueOwwrNkwXUH1Lxk YzRM/3uW7Jc/fzO45RNabTYgRVlIDy13RdosyaSBl9U5DewJt7+8BGBf/y6fE1Zs/Gdv 8sbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712907230; x=1713512030; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=q7LRFqckZoWWz6WECvkgu9IuYe9DhqTySxBwiAwbY30=; b=qO0WNMIMdJQQTcBR/BhBDk+rat/ur6368t1fMX6Yf/oZnnAW4fb1gSmIgtQUfFV1H3 Ni3n7IjdCWZnQu2S6Er590l3PJaZItBJbSVw6G8AnrQa2lsd2StzhIklbs9TBPwmsbJH y59sR8fBrLoHxl8o23MVvbd2FYEpgGlgw+aWVbjJubBjnkEpK9sjnXzKPFSmoYEzODZv vg4QKTOxAC0ScvzghwDA1HFOqXeZCZ/gYAyL/Qw1abpF6tWSowKl8xKN5eQfMFS8kElF 6pWm/atonTJzth+JsEs1aJfNaIGYnYvSrbbtDFtmbyalpcHqZzJeHZ0BWfGH4V1+kdLz IMJw== X-Gm-Message-State: AOJu0YznmLtaGYDDGPjcEUQ6T31rYVYHVPYLAqf5ElS+KBg1caLySPwx fJj6ZvxbVPHLEzIh+YYtVm+Xmq28IEOnUutlvJAzKA/2cIECi6FUnCPUiY2UWTqXc5D4/eqRQJW Q X-Received: by 2002:a17:902:d2c2:b0:1e2:3d05:5f4c with SMTP id n2-20020a170902d2c200b001e23d055f4cmr1837714plc.39.1712907229941; Fri, 12 Apr 2024 00:33:49 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id e5-20020a17090301c500b001e556734814sm2206099plh.134.2024.04.12.00.33.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 00:33:49 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 03/27] util/hexdump: Use a GString for qemu_hexdump_line Date: Fri, 12 Apr 2024 00:33:22 -0700 Message-Id: <20240412073346.458116-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240412073346.458116-1-richard.henderson@linaro.org> References: <20240412073346.458116-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.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 Allocate a new, or append to an existing GString instead of using a fixed sized buffer. Require the caller to determine the length of the line -- do not bound len here. Signed-off-by: Richard Henderson --- include/qemu/cutils.h | 15 ++++++++++----- hw/virtio/vhost-vdpa.c | 14 ++++++++------ util/hexdump.c | 29 +++++++++++++++++------------ 3 files changed, 35 insertions(+), 23 deletions(-) diff --git a/include/qemu/cutils.h b/include/qemu/cutils.h index d0c5386e6c..7311fb36ca 100644 --- a/include/qemu/cutils.h +++ b/include/qemu/cutils.h @@ -252,12 +252,17 @@ static inline const char *yes_no(bool b) */ int parse_debug_env(const char *name, int max, int initial); -/* - * Hexdump a line of a byte buffer into a hexadecimal/ASCII buffer +/** + * qemu_hexdump_line: + * @str: GString into which to append + * @buf: buffer to dump + * @len: number of bytes to dump + * + * Append @len bytes of @buf as hexadecimal into @str. + * If @str is NULL, allocate a new string and return it; + * otherwise return @str. */ -#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, size_t len); +GString *qemu_hexdump_line(GString *str, const void *buf, size_t len); /* * 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 32bad5ce68..ab047d8ee0 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -941,13 +941,15 @@ 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; - char line[QEMU_HEXDUMP_LINE_LEN]; + g_autoptr(GString) str = g_string_sized_new(4 * 16); + size_t b, len; - for (b = 0; b < config_len; b += 16) { - len = config_len - b; - qemu_hexdump_line(line, config + b, len); - trace_vhost_vdpa_dump_config(dev, b, line); + for (b = 0; b < config_len; b += len) { + len = MIN(config_len - b, 16); + + g_string_truncate(str, 0); + qemu_hexdump_line(str, config + b, len); + trace_vhost_vdpa_dump_config(dev, b, str->str); } } diff --git a/util/hexdump.c b/util/hexdump.c index dbc536fe84..521e346bc6 100644 --- a/util/hexdump.c +++ b/util/hexdump.c @@ -16,22 +16,25 @@ #include "qemu/osdep.h" #include "qemu/cutils.h" -void qemu_hexdump_line(char *line, const void *bufptr, size_t len) +GString *qemu_hexdump_line(GString *str, const void *vbuf, size_t len) { - const char *buf = bufptr; - int i, c; + const uint8_t *buf = vbuf; + size_t i; - if (len > QEMU_HEXDUMP_LINE_BYTES) { - len = QEMU_HEXDUMP_LINE_BYTES; + if (str == NULL) { + /* Estimate the length of the output to avoid reallocs. */ + i = len * 3 + len / 4; + str = g_string_sized_new(i + 1); } for (i = 0; i < len; i++) { if (i != 0 && (i % 4) == 0) { - *line++ = ' '; + g_string_append_c(str, ' '); } - line += sprintf(line, " %02x", (unsigned char)buf[i]); + g_string_append_printf(str, " %02x", buf[i]); } - *line = '\0'; + + return str; } static void asciidump_line(char *line, const void *bufptr, size_t len) @@ -49,24 +52,26 @@ static void asciidump_line(char *line, const void *bufptr, size_t len) *line = '\0'; } +#define QEMU_HEXDUMP_LINE_BYTES 16 #define QEMU_HEXDUMP_LINE_WIDTH \ (QEMU_HEXDUMP_LINE_BYTES * 2 + QEMU_HEXDUMP_LINE_BYTES / 4) void qemu_hexdump(FILE *fp, const char *prefix, const void *bufptr, size_t size) { - char line[QEMU_HEXDUMP_LINE_LEN]; + g_autoptr(GString) str = g_string_sized_new(QEMU_HEXDUMP_LINE_WIDTH + 1); char ascii[QEMU_HEXDUMP_LINE_BYTES + 1]; size_t b, len; for (b = 0; b < size; b += len) { len = MIN(size - b, QEMU_HEXDUMP_LINE_BYTES); - qemu_hexdump_line(line, bufptr + b, len); + g_string_truncate(str, 0); + qemu_hexdump_line(str, bufptr + b, len); asciidump_line(ascii, bufptr + b, len); - fprintf(fp, "%s: %04x: %-*s %s\n", - prefix, b, QEMU_HEXDUMP_LINE_WIDTH, line, ascii); + fprintf(fp, "%s: %04zx: %-*s %s\n", + prefix, b, QEMU_HEXDUMP_LINE_WIDTH, str->str, ascii); } } From patchwork Fri Apr 12 07:33:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 788269 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp591401wrm; Fri, 12 Apr 2024 00:37:41 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUw2SB9tsC0opGItEWryvYwgIpnW9dDKDyD5/Wf3biRU9Y19+tG6PW9eo786kDwRhw1qmQBTnIpnm8GssFvmzAk X-Google-Smtp-Source: AGHT+IHrVTovnM809YuSyO1qMbTHMWTpSnXYUsjPMZ89ed+Yph1m5b5N/dqBYV8siXc1h9RhaDlm X-Received: by 2002:a05:622a:50e:b0:434:921c:3169 with SMTP id l14-20020a05622a050e00b00434921c3169mr2049665qtx.39.1712907460727; Fri, 12 Apr 2024 00:37:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712907460; cv=none; d=google.com; s=arc-20160816; b=ihT5hrKT3wOoO3nIngYMJKVMzo817lCQ5HVUUgPc7CU6OF0aPTmoRGLpMgEqVjEQV4 hWMTX0+fLSLuAU5avPvOGnqqnwi/wruqdjZp4Yor7XG/NUs9m5auXU5+HJsLCvHVppet w5EgB2ILYu4tIy3WhjC0D9bo0lbs7xu2K6vPAs2Za8c1pSlwQz153Fm/wS5Jmd4N7xfy JcTquXETylGa3mqT4w/xw9xENVGZ0hljnxy7B93DYu7TH3uaRfmGKni7LX+niXXQjd7e b8BDueK1S5aJ4WRfy1YmYRJQCibmYyh7diODItOnqLWwtgn0zWMnyYdXTbQDM8w7rEuO vQ3A== 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:to:from :dkim-signature; bh=QYzl2xtlupH583p6wNi2Q7esWD8H9kcrEe3HL6WSapw=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=hHE3Dwq0WAHGPrIx/hwbK1NsLFvXR1L3cleJ/vjOdUkyLHMp9ycz24xOGmPPq+kdvU hhnuWyXcs1f3XWjd7cNi7G7Z2nFPtdB9fEshT+2LxIBweW0n8qBrI1PlkP2jKP3Wzw88 JhlLAdTIyFo/2rdShvljrxqS8Bv+qF3Ayo18LdF9AfNsB2mYB9HS+l9ODacFL2UpB7Cf FTJ/2cCh6fkdqyZCsoSkszoG3lV4CdrQ+jHlqoqwNaiRO2nUna27hiqThjaf+LQo1Wua onNKrHo/GCfIygkPCJ7aALHKqDqIM0DW/CQx9s+rNLD5cXp1dUkifWkSgRdoHiJkAwTx Qytg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uDszS8zS; 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 n15-20020a05622a040f00b00434f39f0037si3241597qtx.60.2024.04.12.00.37.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 12 Apr 2024 00:37:40 -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=uDszS8zS; 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 1rvBQ4-0006zO-Ql; Fri, 12 Apr 2024 03:33:56 -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 1rvBQ1-0006y7-Th for qemu-devel@nongnu.org; Fri, 12 Apr 2024 03:33:53 -0400 Received: from mail-pl1-x632.google.com ([2607:f8b0: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 1rvBQ0-00075H-3C for qemu-devel@nongnu.org; Fri, 12 Apr 2024 03:33:53 -0400 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1e50a04c317so3846935ad.1 for ; Fri, 12 Apr 2024 00:33:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712907231; x=1713512031; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=QYzl2xtlupH583p6wNi2Q7esWD8H9kcrEe3HL6WSapw=; b=uDszS8zSHNzzM33hEt1IjGa3vNQ74URtC5Fx7HvDS3j7WfRTwarpkwGfYRULr/lr1Z vPumyb9ifl6X3LubvPWkmn5CEIf1UCo2lxl5BBwCQYA8QrF9hokpASM/w18rQnLLJlr7 eXRMfSNrUOfv7bLwKHCLJtN3FPJpVW8HFci2HSQK47qmwOnk9hyDhpBQMzuDLEi/eHrD Ba6PFXjX6uhpWrypOldioR8o8zdMENhWxRg2ou0kdmaK+rNJ/uaXosL0Fqn+xbPOw771 k9mtUCJG4T6UDnLaWMZNOOzLJ2zauLf0nljC56GmVkTpZjn1KXnogqHakVdFw+88/8B2 sKMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712907231; x=1713512031; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QYzl2xtlupH583p6wNi2Q7esWD8H9kcrEe3HL6WSapw=; b=CgBeT4JyOe/M9AW+nNUlIhftAi62lxWhHaeT9W1NBiH28amsKzn5js7NpsH/ksKtZR F1sdTSgg6iHLS3Vsmo6zOsSVFCMigPpMwKlZdpzKjWK5XQPCK4nNYwM6q2x8nBR2YAuH 2tSvECOokg5p3QnBDh6F40AVu0dOx3pXnySbeQNnRha8tMA8ClGjeRSoIEwuqALNcqRX J+aioka5j9npL+290kOXYaI6rvyj6lmkggIoHl+neh0OqLmiMojGDZeqzhDrmZfnlBuH M+KoIowBANaB7L9sgbVx8HOSD8N+wwBlZ4p8PlgvkpF1h8+2yBLk+YdxXyACezb4llRM QM6w== X-Gm-Message-State: AOJu0YwtnlDb6YHrgrLIhL49GXIbE5tRvzkIerwzVv7bPm9UrQFDIQ0Z xLDdbCqsfUSE6sxP+Ob6mvwMDYqk/vC5DgTfgVUyz/GHcMi0sasxOvTZHt1Cu3W+B8TK4CjfzgU t X-Received: by 2002:a17:902:f602:b0:1e0:b2d5:5f46 with SMTP id n2-20020a170902f60200b001e0b2d55f46mr2241118plg.46.1712907230749; Fri, 12 Apr 2024 00:33:50 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id e5-20020a17090301c500b001e556734814sm2206099plh.134.2024.04.12.00.33.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 00:33:50 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 04/27] util/hexdump: Add unit_len and block_len to qemu_hexdump_line Date: Fri, 12 Apr 2024 00:33:23 -0700 Message-Id: <20240412073346.458116-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240412073346.458116-1-richard.henderson@linaro.org> References: <20240412073346.458116-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-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=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 Generalize the current 1 byte unit and 4 byte blocking within the output. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- include/qemu/cutils.h | 6 +++++- hw/virtio/vhost-vdpa.c | 2 +- util/hexdump.c | 30 +++++++++++++++++++++--------- 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/include/qemu/cutils.h b/include/qemu/cutils.h index 7311fb36ca..e28adedab9 100644 --- a/include/qemu/cutils.h +++ b/include/qemu/cutils.h @@ -257,12 +257,16 @@ int parse_debug_env(const char *name, int max, int initial); * @str: GString into which to append * @buf: buffer to dump * @len: number of bytes to dump + * @unit_len: add a space between every @unit_len bytes + * @block_len: add an extra space between every @block_len bytes * * Append @len bytes of @buf as hexadecimal into @str. + * Add spaces between every @unit_len and @block_len bytes. * If @str is NULL, allocate a new string and return it; * otherwise return @str. */ -GString *qemu_hexdump_line(GString *str, const void *buf, size_t len); +GString *qemu_hexdump_line(GString *str, const void *buf, size_t len, + size_t unit_len, size_t block_len); /* * 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 ab047d8ee0..911742e291 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -948,7 +948,7 @@ static void vhost_vdpa_dump_config(struct vhost_dev *dev, const uint8_t *config, len = MIN(config_len - b, 16); g_string_truncate(str, 0); - qemu_hexdump_line(str, config + b, len); + qemu_hexdump_line(str, config + b, len, 1, 4); trace_vhost_vdpa_dump_config(dev, b, str->str); } } diff --git a/util/hexdump.c b/util/hexdump.c index 521e346bc6..b29326b7f2 100644 --- a/util/hexdump.c +++ b/util/hexdump.c @@ -1,5 +1,5 @@ /* - * Helper to hexdump a buffer +* Helper to hexdump a buffer * * Copyright (c) 2013 Red Hat, Inc. * Copyright (c) 2013 Gerd Hoffmann @@ -16,22 +16,34 @@ #include "qemu/osdep.h" #include "qemu/cutils.h" -GString *qemu_hexdump_line(GString *str, const void *vbuf, size_t len) +GString *qemu_hexdump_line(GString *str, const void *vbuf, size_t len, + size_t unit_len, size_t block_len) { const uint8_t *buf = vbuf; - size_t i; + size_t u, b; if (str == NULL) { /* Estimate the length of the output to avoid reallocs. */ - i = len * 3 + len / 4; - str = g_string_sized_new(i + 1); + size_t est = len * 2; + if (unit_len) { + est += len / unit_len; + } + if (block_len) { + est += len / block_len; + } + str = g_string_sized_new(est + 1); } - for (i = 0; i < len; i++) { - if (i != 0 && (i % 4) == 0) { + for (u = 0, b = 0; len; u++, b++, len--, buf++) { + if (unit_len && u == unit_len) { g_string_append_c(str, ' '); + u = 0; } - g_string_append_printf(str, " %02x", buf[i]); + if (block_len && b == block_len) { + g_string_append_c(str, ' '); + b = 0; + } + g_string_append_printf(str, "%02x", *buf); } return str; @@ -67,7 +79,7 @@ void qemu_hexdump(FILE *fp, const char *prefix, len = MIN(size - b, QEMU_HEXDUMP_LINE_BYTES); g_string_truncate(str, 0); - qemu_hexdump_line(str, bufptr + b, len); + qemu_hexdump_line(str, bufptr + b, len, 1, 4); asciidump_line(ascii, bufptr + b, len); fprintf(fp, "%s: %04zx: %-*s %s\n", From patchwork Fri Apr 12 07:33:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 788270 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp591419wrm; Fri, 12 Apr 2024 00:37:44 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUzFV/qn67PWlWNXModzZ58BXQ+8EZ3iY9YMiy3itHnuRrJWGsUwDk5TnQfDRREiy4XIMFW4HML/r+N8wt/JPIp X-Google-Smtp-Source: AGHT+IELVAenZrINXcD1tky4mVC3yWZf6I9Ors8GiiOH045VsyKZ+M+rmjxST0K7WuJTjXTyVeWX X-Received: by 2002:a05:622a:19a1:b0:436:4c3d:e0c3 with SMTP id u33-20020a05622a19a100b004364c3de0c3mr2408815qtc.33.1712907464510; Fri, 12 Apr 2024 00:37:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712907464; cv=none; d=google.com; s=arc-20160816; b=EMCNb6ZchyJYCAwmeQZkCrwscIhNNzJaP6lqpSnh6ak+QbjYywRcoYMw0YhMONQErY rWHNF9JpaSaknFTCFsxYdVfMt4smbcCZhtDQttPfYlYTSjzlTvENrHUxkPqK4rY7LTBR kO8HNjec5SeeE01pJVL9UDtzON4Hw3lsxDqBpyHmXECvZ+Nnabp+HVDDUGEsbHUR4k8k r1K2hfsrnzPG7JXlmQwSM26qGjtikbEyAmicSRKbc6UGou5PqdiNHSu2D+MBZ+kWymle D4UaD/2weoF/djofnakiqcmy9Mg0aanc5EozsbSwn6JUZygqJ8CwO1i50+9mfCEU6OKj AuMQ== 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:to:from :dkim-signature; bh=rvakkgiyK54UTlLULBlH8+XzGitioxqA6YEQltyd0/U=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=iblhwI/1kv1+rDyiSuWUUSy5Gs4Ds6EIG53Gdtxc8PFxkQUwElKo+/JMKywKyVmcdX R4naX2BYcNBioAUk5rDlz67RNaqhbexIOzDlDVjoU/BURKpTHRUXWgY25QGdzAGIEnV8 o5ZHK/t2VYvWt4o7tXW7qoNEfYSUpXGQryr16bOrli70UP+0NK7jRa/8eSw3/Q2qh8uI +xS6HEDhih5qrmilK0JjxtqP5wLcBD7RCFVTPkAeIN4YJ3DGH5jmPQn7lyFcDDal+YaO G9s2q/ETRhUcB0mLZjE9BIHGWbvL5pHBQxyHF2i/X5b3/BhRK8hzDhVzMdDaLch9Feo2 /X9Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hKhneatP; 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 p12-20020a05622a13cc00b0043697b12d33si391085qtk.603.2024.04.12.00.37.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 12 Apr 2024 00:37:44 -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=hKhneatP; 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 1rvBQI-00074M-ST; Fri, 12 Apr 2024 03:34:10 -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 1rvBQF-00073M-M2 for qemu-devel@nongnu.org; Fri, 12 Apr 2024 03:34:07 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0: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 1rvBQ0-00075y-Vg for qemu-devel@nongnu.org; Fri, 12 Apr 2024 03:34:06 -0400 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1e455b630acso3259055ad.1 for ; Fri, 12 Apr 2024 00:33:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712907231; x=1713512031; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=rvakkgiyK54UTlLULBlH8+XzGitioxqA6YEQltyd0/U=; b=hKhneatP3JxefFbpSjx+2RsvWTzNmgAROrGwt10PAYaGUGnMYQqWju2IjtD9lhLw3G 3cDQz/YzF6IzIA8A0R9etF06dNM9pgKspsuTBfWNaaM1KydQN9NlpqtmDzDb0CZ8mqAn U76MfmrFD+Ap72LpiwR+B/cbzmO2PHW8IokQ/IgPZvCf1RaaaOzYoRlb2dOXKA1iizyu BBlcChnOFfg8nB5yBMSmJnXyHZxWhyHW1w1OoxXxmjbqWc9hxNzgqN9Y1b25WvUUmCyB 7lLm9SKdutRX8ZmHrw7FiSmo019YHbAnbauSkIiUsOiL7LZbYZjDVBAn4bZWx0UmrxoI jXIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712907231; x=1713512031; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rvakkgiyK54UTlLULBlH8+XzGitioxqA6YEQltyd0/U=; b=of0EQwyglxxM+qxmUejj1hXznes6C+R7D+0lJZ2GtRN0dNZAonisC5zuLwphzyO4zN vXSwah4VW2k4+BVQojV1Ffrvyi9Lg6XhqHbjPims897OK3AAcF8qNWMOeP4R8gnOJjfX w5wbEsoqub2sVxPZO4y4ELtan6lLydB2Ggv6RvuO4Zw6dDA8zb38qMAew8e5aK5hnUBS A1U+2xuJ+1MUMX2OyRClLscLX3SOIb3RK4bZDqTD6q94bqcqeBxXvF0S3Ub+RaQ4BuNj a4AaZD/+uQ4zzpjCBO2ISX6XodlPuFKfEfMhUOjV5UFYKcytVmy8YXmxNcDFvavUrxct Wbew== X-Gm-Message-State: AOJu0YyZodsSI2NWI/H6qC/YsFp+0KH0WpxAHPykF5m9WwMDOFEMzVz4 7HcinVxXdV8+eSi8zLMmZJbPrIJblIGBtP1QPJRUO4F1wBw6CTiJt5owH9s6FEj805sYoW9oY5s i X-Received: by 2002:a17:902:6f16:b0:1e5:3c5:55a5 with SMTP id w22-20020a1709026f1600b001e503c555a5mr1557546plk.8.1712907231562; Fri, 12 Apr 2024 00:33:51 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id e5-20020a17090301c500b001e556734814sm2206099plh.134.2024.04.12.00.33.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 00:33:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 05/27] util/hexdump: Inline g_string_append_printf "%02x" Date: Fri, 12 Apr 2024 00:33:24 -0700 Message-Id: <20240412073346.458116-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240412073346.458116-1-richard.henderson@linaro.org> References: <20240412073346.458116-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::635; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-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, 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 Trivial arithmetic can be used for emitting the nibbles, rather than full-blown printf formatting. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- util/hexdump.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/util/hexdump.c b/util/hexdump.c index b29326b7f2..ae0d4992dc 100644 --- a/util/hexdump.c +++ b/util/hexdump.c @@ -16,6 +16,11 @@ #include "qemu/osdep.h" #include "qemu/cutils.h" +static inline char hexdump_nibble(unsigned x) +{ + return (x < 10 ? '0' : 'a' - 10) + x; +} + GString *qemu_hexdump_line(GString *str, const void *vbuf, size_t len, size_t unit_len, size_t block_len) { @@ -35,6 +40,8 @@ GString *qemu_hexdump_line(GString *str, const void *vbuf, size_t len, } for (u = 0, b = 0; len; u++, b++, len--, buf++) { + uint8_t c; + if (unit_len && u == unit_len) { g_string_append_c(str, ' '); u = 0; @@ -43,7 +50,10 @@ GString *qemu_hexdump_line(GString *str, const void *vbuf, size_t len, g_string_append_c(str, ' '); b = 0; } - g_string_append_printf(str, "%02x", *buf); + + c = *buf; + g_string_append_c(str, hexdump_nibble(c / 16)); + g_string_append_c(str, hexdump_nibble(c % 16)); } return str; From patchwork Fri Apr 12 07:33:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 788267 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp591280wrm; Fri, 12 Apr 2024 00:37:14 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVuZYW/u601rpc2kPA/fu1ajebeiOCxn4GnlkIz9hz5fbKSVf/77p/Qw8MSd0wlc9suCfTEFRlB4zbGqhE5d7IW X-Google-Smtp-Source: AGHT+IFiX9zjX/fGElQ7/nFrTHY/EtMfSA4ICnNhMiip5nkr/0rnG9ND4TG1Q9sQ+/DuJrimf8Nz X-Received: by 2002:a25:8210:0:b0:dc2:2608:af74 with SMTP id q16-20020a258210000000b00dc22608af74mr1758060ybk.26.1712907434259; Fri, 12 Apr 2024 00:37:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712907434; cv=none; d=google.com; s=arc-20160816; b=KXe51G+Dw9LrTch9H1/Q2528MEIPrWVpyzzHOBte6hxPSPnakFj3BZK45S0voNs99M XLGjIy83b/jvcyudRKy5pw5z188oNoFu+5s64tJ3+RLkJdlgho6d+J6w+l8exfuhlBkG qJij6437KPy4JbJmn/uKeaEbZXCi7G4PBD/WWHGYL9OICJF+3dXgw9v5dLzoGfD5Ey4U fDqUi/N9uwaEqiWxy/+OkDYu1ma5OXombQPqK53Lrg2/Y2VHKS40UNu6XG7C1XYLxGl/ EieSO8coFjinv/5AJyHEwsmqA5UguqQUHzljaGXxRzVlCf+ifx84wahDDlOWJq12JuSf hcJg== 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=qyr/Ts8Rn5hOhvh/4SLos/fwt7+2NBBMVS+YXiC8DT0=; fh=kQadAhxV42GJ3cd2VUw1RyURv/zJQGvmUdF7iLEVTtc=; b=tB8Ym0QCQ+wJUdEtUDUvgEztS6GWvYo6XM8Dtq4DgRS7qIJS51ibfF2Ovl5kHDwSI2 07FOEYRb3hx5DtwSuaAxD2pBgLLpIWMt6dHHDoTG1ILALiSe5ZWXBquR+IfE6nOXmFUo kKNiC40Ku/hiw286mArG39JM2A2qiMc1IQqmXYAdnkfam7xwbvk39u6XwpvCrFwx9SyR IY/x32jdCOXb/bgJwyJNmcPH9f2EiRg+qpUQR9WCF5f4fBLJdAQVlVF2tUQDZY07ZOkG MW7v0hBAJ6et448NIJTFAemo1/IRZjUGKUljRpGBuC4rq6j4UQWBukcPmnvQE/yqP97U +miw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Vvfbjnnz; 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 t7-20020a0cea27000000b0069b47accd20si3160973qvp.427.2024.04.12.00.37.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 12 Apr 2024 00:37:14 -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=Vvfbjnnz; 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 1rvBQ5-0006zl-EX; Fri, 12 Apr 2024 03:33:57 -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 1rvBQ3-0006yh-Po for qemu-devel@nongnu.org; Fri, 12 Apr 2024 03:33:55 -0400 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rvBQ2-00076m-7N for qemu-devel@nongnu.org; Fri, 12 Apr 2024 03:33:55 -0400 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1e3e84a302eso4959245ad.0 for ; Fri, 12 Apr 2024 00:33:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712907232; x=1713512032; 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=qyr/Ts8Rn5hOhvh/4SLos/fwt7+2NBBMVS+YXiC8DT0=; b=VvfbjnnzFXryrybZSXsWtuc97xkdxA3A9l6/f/WNc9652gAHjBunrhAOqgtv5gtm8w c7rZOo35DswuFVNIT03tigsEbiwuQCTSxkHWZae5Sj422mqiP1MK2xoSGDfqvNzJhW3q bGWB6pfF/HTilifFCuYHARFF2k3jVkSnILPaxDJlcJStTJICA0ZhGXkP0I9ngH+K9Fd9 Mdqcrmjsy6rok338UG7tWxkC0uR5fNZf7Bry0ynMZwToqSdhjESrUerDcVrjYR5DmIUd 7jS13ZVurCJ+BAzAJdRb2KuM51fRGjJYz1i/FPetX9Bga/3rKtnM+Zw9A8E7DE1Utiml H4tQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712907232; x=1713512032; 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=qyr/Ts8Rn5hOhvh/4SLos/fwt7+2NBBMVS+YXiC8DT0=; b=TycboKdIINWdTPflxM/BBDqnn0ESC9REnPLHjWtsVlClWnhCXwuOhp8568EXofSAND sDe63JuL/rgqIkMQIl7+FC3b22fMx10iBvXgHfDz2jJHG/FouzcMAGcUUk7KXQK0MHao m0iKDVwmY+/auX3nzED1NEMjWWu6e2BMES3lQDZ+Y+d1gw386AQ2BIIyXwcBwKDyYa+A SCLQW/5QFDNeNMTI3VtgwJAx9Ym/My7ZO0O1UgOv9FiyFsAdcQ3fkp9gW/yh1By1PQ8I IAr1cv5Vj2dzvsZI7t3HJkURjpxXdh8yn9d/KqjoDHFTGaL+4JRDzoVViYcNiFuvzv06 yCGA== X-Gm-Message-State: AOJu0YzlupyETpjFLb1/UEdkN5xxN5C0DNEz2dLkEO6Kmrxq8NceXB6d oTZan4Z9HnnqdJvwN3QBmr/W3O51ujhawoe1b5TQYSgzbS3wn8dmOmZmpMw6O0+Bi5aPRG2/OWC G X-Received: by 2002:a17:902:c40b:b0:1e1:4806:79cb with SMTP id k11-20020a170902c40b00b001e1480679cbmr1948271plk.56.1712907232517; Fri, 12 Apr 2024 00:33:52 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id e5-20020a17090301c500b001e556734814sm2206099plh.134.2024.04.12.00.33.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 00:33:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 06/27] hw/mips/malta: Add re-usable rng_seed_hex_new() method Date: Fri, 12 Apr 2024 00:33:25 -0700 Message-Id: <20240412073346.458116-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240412073346.458116-1-richard.henderson@linaro.org> References: <20240412073346.458116-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.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 From: Philippe Mathieu-Daudé sprintf() is deprecated on Darwin since macOS 13.0 / XCode 14.1. Extract common code from reinitialize_rng_seed and load_kernel to rng_seed_hex_new. Using qemu_hexdump_line both fixes the deprecation warning and simplifies the code base. Signed-off-by: Philippe Mathieu-Daudé [rth: Use qemu_hexdump_line.] Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- hw/mips/malta.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/hw/mips/malta.c b/hw/mips/malta.c index af74008c82..664a2ae0a9 100644 --- a/hw/mips/malta.c +++ b/hw/mips/malta.c @@ -26,6 +26,7 @@ #include "qemu/units.h" #include "qemu/bitops.h" #include "qemu/datadir.h" +#include "qemu/cutils.h" #include "qemu/guest-random.h" #include "hw/clock.h" #include "hw/southbridge/piix.h" @@ -850,15 +851,18 @@ 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 GString *rng_seed_hex_new(void) { - char *rng_seed_hex = opaque; 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]); - } + return qemu_hexdump_line(NULL, rng_seed, sizeof(rng_seed), 0, 0); +} + +static void reinitialize_rng_seed(void *opaque) +{ + g_autoptr(GString) hex = rng_seed_hex_new(); + memcpy(opaque, hex->str, hex->len); } /* Kernel */ @@ -870,8 +874,6 @@ 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]; size_t rng_seed_prom_offset; kernel_size = load_elf(loaderparams.kernel_filename, NULL, @@ -946,14 +948,13 @@ 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; - prom_set(prom_buf, prom_index++, "%s", rng_seed_hex); + { + g_autoptr(GString) hex = rng_seed_hex_new(); + prom_set(prom_buf, prom_index++, "%s", hex->str); + } prom_set(prom_buf, prom_index++, NULL); From patchwork Fri Apr 12 07:33:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 788259 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp590970wrm; Fri, 12 Apr 2024 00:36:05 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU7/K0xwpurI1zp0L3HAmkCSr1k7fXy8+F4CBOGMLiDbX63TDRpxOPqsbSWhtINY0Gte0+ExsyDX6KMwF50OfFm X-Google-Smtp-Source: AGHT+IGoCNGMpmB55YvaTbb3Z8g6nQ3rtl2YqCuYH/YrLVb1HZjj8UqmU9Rvj3FS/yT3sE/77Zvv X-Received: by 2002:a05:622a:1813:b0:434:583d:3776 with SMTP id t19-20020a05622a181300b00434583d3776mr2093470qtc.6.1712907364839; Fri, 12 Apr 2024 00:36:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712907364; cv=none; d=google.com; s=arc-20160816; b=ZmPne5GCHIsTGDc4oJ+N8jWD67cHU28ToYm08+uKih8Uk1/vzeqP691fvI6weftsA5 wQFbKsJ6vy37066SRVNADU24N6l/1fhwF8v4pAuYADl9VB0eO+TEE8QvBN15S0dcz9Sm Vx/H7svojjCYURYqFgeSQ5BsirMI4y2grP72luHDm6hjROuEVbiZalqqc66Zs1rgLJDR W+eEyJVna2/elyQNfh208cC60Pf2skG7KnhzkdrGHg1/Eyda7Dm3Z4kD6ZXWk2r2UNKp ZGy9YR2GpxAuQgD+Lu00fhKTkHl+/CxKBXq5NluuwUzx+y0LThdFIMh9YWMNRozCgcpp WyPw== 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=fnSXZctlzd8Wm3DUoANmQRZQ2vSrRZB+EmzfSv7sIGQ=; fh=kQadAhxV42GJ3cd2VUw1RyURv/zJQGvmUdF7iLEVTtc=; b=GHaaV2tP4eTKGDgwZ3pUnYRr1EQB0qjLYdcHWOlTcmf8TgUihoi1gKefWXWkvf/3CV 5caQEu4FCDeD1lpZHsFszw1YLWTaNMDG5m0/o6KnN4yg0G8J2vWjQwi9hp+6ej7z03x4 AR1FxzQ6lS7s1Q7ahO6ZwB0SN0ke2k37MvZOV77JfgEK1qcCiz37Tvus67YN47VL7V0n pM4Y7LnU1qhION2fsdN6dw+KkEiNh22c1oBbYxE1wyW9nqSNaoiFSJF/xggTKn5y18pk qx1t6w5bUQvbrzXY508OdJ3FHLAIZG2TGUtMb8hTRubSF+jhkJN/0B0FFyH5D17ZfPyS tW4Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jfS7hNKj; 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 d9-20020a05622a05c900b004366340b380si2826119qtb.270.2024.04.12.00.36.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 12 Apr 2024 00:36: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=jfS7hNKj; 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 1rvBQ6-000703-EV; Fri, 12 Apr 2024 03:33: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 1rvBQ4-0006zD-Cz for qemu-devel@nongnu.org; Fri, 12 Apr 2024 03:33:56 -0400 Received: from mail-pl1-x634.google.com ([2607:f8b0: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 1rvBQ2-00076y-QP for qemu-devel@nongnu.org; Fri, 12 Apr 2024 03:33:56 -0400 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1e50a04c317so3847065ad.1 for ; Fri, 12 Apr 2024 00:33:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712907233; x=1713512033; 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=fnSXZctlzd8Wm3DUoANmQRZQ2vSrRZB+EmzfSv7sIGQ=; b=jfS7hNKjWkfRCMcM1YDj6JhZgolCUtddi8g4hfJjyh3vwZpAhb6pqMfliCbFChFCz7 QJyeRsvFgutfHRhb8dJ8XuVFJw96SL/NMyBwSTTHD4yEzYmo9vCA1eWzuOzbXzIH5yxQ bnbYuJLzhEkkdfFUD8Flwh5T18sNGdMw7cnhXf/qDNEujPF65ks18vMwp4vh4oAlh/YS GfroGsNUqAaezoAYjClvZUN1RRSoGoFGF3aYJTBzHbN55ojbyWNA3QZBzg8AB3S3ndvd OQuzBDcub1Ln0gFvS1uuVDoJEl+bSWKon/cl3ZB93TI2pP8P6+zav6rSNZyoBIJjbRtL Ggfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712907233; x=1713512033; 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=fnSXZctlzd8Wm3DUoANmQRZQ2vSrRZB+EmzfSv7sIGQ=; b=I5DntoSogwyRd0sYc2E89v/P8D7pfMORlHHlJ4EKTcI73dFP+QgUR/LGmLO2BDWkbL fOU4jQEQ3nEctjrbr9T/YdEjjzDFLP/tmQdk48d50N/NE/xX6eQJPpBHQOH4lk14AbNW WpPDol4qPN5rLiLcKxHd17uY7ptJUqIVGAajFZ5ieRSO6WXyUzqlT2X3lsqg442ukl0o 2nGbv1Pki0EsbKjGX7N47p5Y8nlENviH60VWnEjPtHznWg2JG2SU2sJq+A0MY+8myRvC Vqhqbc5CbHZQoLBSRPMhjMJCuzZK67pVKO4d0BzVDQ4kmsAziBNyITUnaPWFI6TQND2L waIA== X-Gm-Message-State: AOJu0YxtGDSLRISbZ9YwPzOQXdb3ylipxQfV3DkLJHHW+iEqswBes7Rs RwiK4oyFNaUTcCOcTbEARQqdSc9a4CTUWbt7HGaRqeFfVJFOQLbml3Wz2o4EkmvBgWaffOpNL5S i X-Received: by 2002:a17:902:ea10:b0:1dd:135e:2604 with SMTP id s16-20020a170902ea1000b001dd135e2604mr1977494plg.40.1712907233310; Fri, 12 Apr 2024 00:33:53 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id e5-20020a17090301c500b001e556734814sm2206099plh.134.2024.04.12.00.33.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 00:33:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 07/27] system/qtest: Replace sprintf by qemu_hexdump_line Date: Fri, 12 Apr 2024 00:33:26 -0700 Message-Id: <20240412073346.458116-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240412073346.458116-1-richard.henderson@linaro.org> References: <20240412073346.458116-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::634; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-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=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 From: Philippe Mathieu-Daudé sprintf() is deprecated on Darwin since macOS 13.0 / XCode 14.1. Using qemu_hexdump_line both fixes the deprecation warning and simplifies the code base. Signed-off-by: Philippe Mathieu-Daudé ` [rth: Use qemu_hexdump_line] Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- system/qtest.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/system/qtest.c b/system/qtest.c index 6da58b3874..507a358f3b 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) { - uint64_t addr, len, i; + g_autoptr(GString) enc = NULL; + uint64_t addr, len; uint8_t *data; - char *enc; int ret; g_assert(words[1] && words[2]); @@ -618,16 +618,12 @@ 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]); - } + enc = qemu_hexdump_line(NULL, data, len, 0, 0); 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 Fri Apr 12 07:33:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 788252 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp590541wrm; Fri, 12 Apr 2024 00:34:42 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUIEqgiYv2wcWDS5hY7vg4l2WYMMX1quAwX28I8N1TfmxM6XMq3vaF5N/0oBcy4/aLVm3PF/tLFdle2RKtOTVIZ X-Google-Smtp-Source: AGHT+IE/zFlMBW5jPbq375PdaOtWPD/bXwlN2SeTlmfZpVcuZz0b2V0Z/2S79+f9L3L6PeX4NJOc X-Received: by 2002:a25:bbd1:0:b0:dcd:24b6:1ae7 with SMTP id c17-20020a25bbd1000000b00dcd24b61ae7mr1516308ybk.63.1712907282487; Fri, 12 Apr 2024 00:34:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712907282; cv=none; d=google.com; s=arc-20160816; b=vAs46zBrRRBswiQqhs3vT5Xrzv8NaJy1Pc1edNdAi59L7y8t0h+xwz3RlKbjZSUS7i JleL12LwnvN8rKS6TI4QtCjCKuWNEcUItguxDyDU476DFYJVIM3dmssUwW/UOjq//rNh XDNLGiepn2aGdyOTDZ7etVkebAp7YMau9aBR3BV14xFF65OcKfqiO72fVx6WaDVciX70 pRLkkomIgNZBzTkL6JPMumsUZCUe/8LQsG50RRhvIaGBFJuOugeNJLj8Pu1xHEfdwI27 nWQRvwtSLr+RC4E31FZxN7raxYPl1fdpoLjqG/oXvx9InrXpDAwXKZ0Ev8myWyOXb49i V6ug== 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=7ZOZ2GpOHx19JGGX2PLqgY++2k2pqd50fzr6oa/q3CU=; fh=kQadAhxV42GJ3cd2VUw1RyURv/zJQGvmUdF7iLEVTtc=; b=cEgBc2JFQyPFCW9BZLDn7uaOWYxnUNVxEb/SRrY/sSd4d+WO5WwfHrdH8Jy3a8rwp5 9wHsUARzOx7DVM6km6oD5Yvnnc+7koJd2sYmFYPOQHTxubR0sUWOln09siNzfeY7xVZZ 3awQ+3VpxpRA3E/OwQwbegpJZ8KdDuIGqCed8WoXTBgOsZtuCVUuWB9jKfXh4iwybRAH zsJ97klMf47AgEGJFPvo7jBYICWIWoBxRdFbfHL85Hzqe+VDEGPjRaqq5sWHH7KPamlB kywO6CuZYck9UnH+wo8gLzOVhcpHgCdJF636BORffva6iCNSg+EEISvPMrYFnQohtCTW giHA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=znqmiNVr; 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 l15-20020ad4424f000000b0069b1ef03333si1041433qvq.6.2024.04.12.00.34.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 12 Apr 2024 00:34:42 -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=znqmiNVr; 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 1rvBQF-00072G-1z; Fri, 12 Apr 2024 03:34:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rvBQ5-0006zQ-0U for qemu-devel@nongnu.org; Fri, 12 Apr 2024 03:33:57 -0400 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rvBQ3-00077c-Cd for qemu-devel@nongnu.org; Fri, 12 Apr 2024 03:33:56 -0400 Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-6ecee5c08e6so678885b3a.3 for ; Fri, 12 Apr 2024 00:33:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712907234; x=1713512034; 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=7ZOZ2GpOHx19JGGX2PLqgY++2k2pqd50fzr6oa/q3CU=; b=znqmiNVrFi4ywHzeFmQIarTlblzjn7NzQwUZMZEJ0VvKzavwAn+dgfvC4I9BFNi6UC 2JmL0I9UnASgsccFyL7cz1P9vql2I7BCS6gf6ncE/pB3Znpj+wFTVq4ep+ULhaHgHT+O GqJdo65emWbjeyQPCWoXXr/iw3PAazHOigIF3l4p3+dzhVV7Tn8e7ZxH7GheUmFb0pnV CHmD4r0b8UjiVZR25enm8Yr583pmlr7vyVSz/wnjKU+vetSgKv2VIeRLvRz+ynnegESe dJ3SQ1a9K+z1kMP4OiqfH0XX/WTW8RFpIB5ZCyjsxhiwJWNEJ3iHxNOeYsLFjN3Q74sj h4OA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712907234; x=1713512034; 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=7ZOZ2GpOHx19JGGX2PLqgY++2k2pqd50fzr6oa/q3CU=; b=c40jbfhoYCBASNCeSULZ94yl8ow40MMf+zS37ag82hMsxhrCGgZTqSKBU5vQTBIuEj wC2oQZz3DkyDFPLP/Ho2ZE4MYT/18/Sb7Bd+T0tR3Akfz1roWg69o88AQ+9CfIABy0D2 /e19Wi9fGLtsURNeAcqJUqGDsSbh91VwkkQUawdbFxT3MnIfYER4qHE262MWXBnzHjS8 97bE5DHKcSkpQDSRTnPu1YmBKoqkeE8+MiFd0gsmfsQwVTMNny/WjVD/rKaJAApdeGNx tR3soCWEeOydZlOoezNkbZMkaHfK6pjVO3Y/ymU3vjoB81avKjSgIMFFJhex8KC+9Qj2 WudA== X-Gm-Message-State: AOJu0YygnwAEKIU914vJkxJ69SbeEymbK7sddwTf215ialpX+yVVHF5d 3MHyEz19tG6Z7BMH3T3pTWUimjBSpg3jUg3ZqztRETimRWKggFYZZEjUmOwT6+D8bWb9cAnx6TR Y X-Received: by 2002:a05:6a20:2591:b0:1a9:5136:13ba with SMTP id k17-20020a056a20259100b001a9513613bamr2713325pzd.14.1712907234026; Fri, 12 Apr 2024 00:33:54 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id e5-20020a17090301c500b001e556734814sm2206099plh.134.2024.04.12.00.33.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 00:33:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 08/27] hw/scsi/scsi-disk: Use qemu_hexdump_line to avoid sprintf Date: Fri, 12 Apr 2024 00:33:27 -0700 Message-Id: <20240412073346.458116-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240412073346.458116-1-richard.henderson@linaro.org> References: <20240412073346.458116-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::430; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x430.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 From: Philippe Mathieu-Daudé sprintf() is deprecated on Darwin since macOS 13.0 / XCode 14.1. Using qemu_hexdump_line both fixes the deprecation warning and simplifies the code base. Note that this drops the "0x" prefix to every byte, which should be of no consequence to tracing. Signed-off-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- hw/scsi/scsi-disk.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index 4bd7af9d0c..f386a2f01c 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -2648,19 +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; + g_autoptr(GString) str = NULL; 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]); - } - trace_scsi_disk_new_request(lun, tag, line_buffer); - - g_free(line_buffer); + str = qemu_hexdump_line(NULL, buf, len, 1, 0); + trace_scsi_disk_new_request(lun, tag, str->str); } static SCSIRequest *scsi_new_request(SCSIDevice *d, uint32_t tag, uint32_t lun, From patchwork Fri Apr 12 07:33:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 788253 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp590626wrm; Fri, 12 Apr 2024 00:34:58 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWPsX6vimNfg0N0aQl4QyV26CBWoCe19oLFE0nIfWrTR68RkmIHO8EaahdTLpqwIE9JbA2d7TXFBBwAA9eezPAh X-Google-Smtp-Source: AGHT+IHPhn6FAZJaWRVBlzfAE7lUNDowT7cXCRg+b6kEByFUtIDR1HeM632Eq0BnZbcN2Wmf/UeY X-Received: by 2002:a05:620a:28ca:b0:78e:ca95:cea8 with SMTP id l10-20020a05620a28ca00b0078eca95cea8mr1969017qkp.4.1712907298613; Fri, 12 Apr 2024 00:34:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712907298; cv=none; d=google.com; s=arc-20160816; b=w+3a+8/Fzl5LUJMGdo18UTSIucU3FyFii9hzoNIxxbFeIRwopF3nMR82xPvUr/ZsNP pqqJH3AU1bee2XX1XR89w5jt7YAd7olYTUwMnuvVs2s2aC7AlQe2Mw7Eyo70WMGn111S UczCkel3evIPYYYr5sZD5J5NLog/IMQ0emwajUVVmVmbEkGb2ydct2Tsl7yGXOX3c38i iHZk/BkjaI6kOBYSb7xrNr4PnuKO8ONvm/ltsMWkXG6hEhKWZFrxOJq7XIzM1hJmWbqr qN3QwjGupT5t0nRBdReSm7JcZOfLkNjPYmSToRqZZw0BBPlQTmyqC2fU+QS02SDQneGp G0/g== 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=vWTBmrF16GSaydEzWRv0Zn9YqSFsjsSSjgb9YwJ02w4=; fh=kQadAhxV42GJ3cd2VUw1RyURv/zJQGvmUdF7iLEVTtc=; b=z9yvDodERQY2bwwfXUt8S6S4qnbgcNEOIUF/F19kgN/atOO72GvZJyMKS6JaQaMEbw AQhLrXFkwryzHwgv7Hw6HMKsr9CwR67ZDjL0zXmhFOHKnmP7xMgOQ95JrRbnU2x8mg9p XIYicRXcfFXfxG8s6PxNU6nj6uP+VoREhBAw14Ia3WlhK1CCv4Wqd6mDlnjXuE+NXSFw XWf8zWesYcw2vTim4hVgS+Hu0DBzEFi8liD6OG/2Z4mKmV4mpEJSrVUwk98XBO+dug3E IqmMpxj+eYIe21RjswbNiqkf9be+Nbln/VeSDR807wpS3o+ywg9FObqKVl1HMIZArpbb 61cA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Zuz3gB39; 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 o1-20020a05620a0d4100b0078d5fed75dfsi3069611qkl.717.2024.04.12.00.34.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 12 Apr 2024 00:34:58 -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=Zuz3gB39; 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 1rvBQ6-00070R-Tb; Fri, 12 Apr 2024 03:33: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 1rvBQ5-0006zo-T7 for qemu-devel@nongnu.org; Fri, 12 Apr 2024 03:33:57 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rvBQ4-000786-CQ for qemu-devel@nongnu.org; Fri, 12 Apr 2024 03:33:57 -0400 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1e51398cc4eso6364615ad.2 for ; Fri, 12 Apr 2024 00:33:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712907235; x=1713512035; 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=vWTBmrF16GSaydEzWRv0Zn9YqSFsjsSSjgb9YwJ02w4=; b=Zuz3gB39RFRPXjjhlMe00Gye62SaGQL9MZHWpfKIzppFAiGXWsnI1oqea+lJUC9vDI KdrbE3r12I3nIQhES049JHCTs8xbWHpLoxRGVEGxjfjdVzc1IZ42X/sejepJ/stMfScG Qi+MVCORtIQBXUYbF8yp0bBupNMnD6u8kewKSuunjmKJ6WqMERrTLgWWXI8YoAMD3IlM Yxu+uwMuM4aJT+C6J3XRvg2s0XHrnEVwwnmz126O4ImNpFeAcO8d1tHslTfAFUF//BHy E46FEh3pD7zFQtJEb79g3KWZnhp8y2jIA+3roQbWGuvngF6OKsF44aQ5nNMnErLWfYsT YtAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712907235; x=1713512035; 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=vWTBmrF16GSaydEzWRv0Zn9YqSFsjsSSjgb9YwJ02w4=; b=Uo3UIrwI38THwhwHMCA+WWH79pcoXnzZZC7Bb9JQ8TbC+4qXqcTlQ+j4ytrxLE+Olm fxVclEvBBQbpL9/OtTNtPdZGANLZOEURZKXr2o0e+ayUzetbUpmFc3Sqia6yyVppadMV Ja+Jua+dl7OT6sidSjiC1T+0qLz1GKW2wPx8oH74L+IHs2OId/CwOTzuYa5F7ILUv2q2 X5kN0LCpQpaRcIn0hZIwGux2G7u5of+85RvqiTfLjfwIdhLlmXDnANEnpkZDwRU5iV/V l9YGHJ3w0ZuYhT1zHsXffFOsgU4+LoruBzPLe01CdjMJZCgL04Vd8M8ivGokHYAGlqjc NxYQ== X-Gm-Message-State: AOJu0YyP17coF7LsZfvfK7V1hm20t77ln2KGc+31Ff+gjRch/L/d8SOH COd7wp+mTNKp98XDva6dwrp+gZtWCXlh2MVLKeRxFyMz3PIalATGPFmAj7RM7hukv31KA8Mite2 o X-Received: by 2002:a17:903:2289:b0:1e2:81c1:b35e with SMTP id b9-20020a170903228900b001e281c1b35emr2143992plh.54.1712907234841; Fri, 12 Apr 2024 00:33:54 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id e5-20020a17090301c500b001e556734814sm2206099plh.134.2024.04.12.00.33.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 00:33:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 09/27] hw/ide/atapi: Use qemu_hexdump_line to avoid sprintf Date: Fri, 12 Apr 2024 00:33:28 -0700 Message-Id: <20240412073346.458116-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240412073346.458116-1-richard.henderson@linaro.org> References: <20240412073346.458116-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.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 From: Philippe Mathieu-Daudé sprintf() is deprecated on Darwin since macOS 13.0 / XCode 14.1. Using qemu_hexdump_line both fixes the deprecation warning and simplifies the code base. Signed-off-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- hw/ide/atapi.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/hw/ide/atapi.c b/hw/ide/atapi.c index 73ec373184..fcb6cca157 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,14 +1310,9 @@ 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]); - } - trace_ide_atapi_cmd_packet(s, s->lcyl | (s->hcyl << 8), ppacket); - g_free(ppacket); + g_autoptr(GString) str = + qemu_hexdump_line(NULL, buf, ATAPI_PACKET_SIZE, 1, 0); + trace_ide_atapi_cmd_packet(s, s->lcyl | (s->hcyl << 8), str->str); } /* From patchwork Fri Apr 12 07:33:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 788263 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp591145wrm; Fri, 12 Apr 2024 00:36:41 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVMOW8Gr31NeEC1VONWmrr5ViT6D6dDO1uxtmsUURnUu0SVUNKV5pNSucQY0LzdnU1FHf+IBodUOqYAHV1f/fVC X-Google-Smtp-Source: AGHT+IHYvhFvbkGr5QreDe4bw8+28M7/QqTfpsbJQ4GmS1fNjfuoXnnld8Tj9YdlwfOIX3CVkQMi X-Received: by 2002:ac8:58c1:0:b0:434:bf8a:6554 with SMTP id u1-20020ac858c1000000b00434bf8a6554mr2175267qta.52.1712907401039; Fri, 12 Apr 2024 00:36:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712907401; cv=none; d=google.com; s=arc-20160816; b=Q+KKV0MQiOh39KqB7U4DSo68+kuZRl0vwj8zuQ6xtW+ieRWGQvYDrqHsZ7x45Y4DE3 Kcs3tyggbGpyz5WA4lXQVyEGXzpi5dWujZTbtRUSRS8k5PsFdtenq/IfFqQ+EPSp6J5f /0DK6AAgiKRCOqBSvmgnYH0j1GL831r/W4eTfVa4yn6UO7M2p0UV4KzrbDTfjUiqcWM3 4A7gsdkcv4rd0v3Q4bImdchOPxuxoWMVxpnOHASd19phFTlZBu1kou0fBz+i6fKHQALb 7VM3LdyEtGEPbssWvDTMFHeqMAQ3NtRFMmZknDg84YnB0nM4yv3dpkphzDyABiR9Epel eZyA== 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=6ilxVF5BFwS4yjUJP5brLaFANRlAZicyrMWrO+XSuc0=; fh=kQadAhxV42GJ3cd2VUw1RyURv/zJQGvmUdF7iLEVTtc=; b=KjJ2+NeYyak+BSojrdMnAYEp4urvz9wjJ4RZIDxY8M/0e6AuFB7q8bX3+sNv/2L6t3 X7wPI8I5hqE4QJN4xGtt/LSNqMuy4kZ9nJZ161zPhA3gGGesw1H0OhiNjuBnaH5kaeo3 hBl5qxd9IxTn/wj4Y7cVR7g0lzQ6grS9h9ZxLlT9lS5K0IDuxsePWch6T9Y/ph/YnuDG C8y1Ei4mB/lEruKUbzhBQuKyCCSF1pcvBOnrRjGcdbDrXm9dWug6l71itTRUPU7ph363 QJEQgcly8lhoxWWualfgJBp52jO93uUk9kr/bsYVMvxqCWVEUM62on3LZQ3defaaBgHZ joqA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TZXSFWDs; 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 d16-20020a05622a05d000b0043467b97307si3239779qtb.21.2024.04.12.00.36.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 12 Apr 2024 00:36: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=TZXSFWDs; 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 1rvBQ8-00070j-1J; Fri, 12 Apr 2024 03:34:00 -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 1rvBQ6-00070C-ER for qemu-devel@nongnu.org; Fri, 12 Apr 2024 03:33:58 -0400 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rvBQ4-00078P-Va for qemu-devel@nongnu.org; Fri, 12 Apr 2024 03:33:58 -0400 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1e5c11076b9so640725ad.3 for ; Fri, 12 Apr 2024 00:33:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712907235; x=1713512035; 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=6ilxVF5BFwS4yjUJP5brLaFANRlAZicyrMWrO+XSuc0=; b=TZXSFWDsAsMGQVsYPjBqDchaQDmbOPAHKM/mgPJZFKOqGbDHoFqE4DMQTolwJT/oPm eOGKEAk3lg4DGoTK9ZxQQRwo6OMgkkM67eYoF/rRZoqW804imrnbw14AJgpmL1lezudM a6EG09maLY4M/phWqabf8jytQRcGNq08Fb0HzpjJmkeOpwZs5MJQtiwPCpiUGew22ZBe 3VVYNIXpThn5fnOObzkVzxohofOnGOJMvFEKsWeoeP4681R0vQTBZGeLv9+3tUwqF4MT NOjIelZwb11j1Qlpbz0cQid/SEqf48j1mN2FarH0ufaUoeGlqkEOf8xOm9jLzPy7LnrX 3Ffw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712907235; x=1713512035; 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=6ilxVF5BFwS4yjUJP5brLaFANRlAZicyrMWrO+XSuc0=; b=baQwoQO5atYM08PmEa8jorRxcv0EAN8KH9XvosgMt9lUuFfsAGopK/6NP8ndEDJnR4 S4++yolis/J7p27lGWN8gRbG0i/n1g1l16Oy75Ox7MBiaPOYmaaIX0hsY92Jl/YbIpvX ynItaMcZhmQQBSCbUXmToDEIbgtyryEIkT/pvrpTpg1OYIdC45Rahbw0HV3oow82wUQB wVvHzMHT4hQ6DlkPekceNJOsT4fuF/C4KkMzyRUgRyKkDsaUwuHbNStwi/C1+i+zNwRf korrMZegqP4OBhbV0bzCdsALE7t6dDboiyq33KOWKc4FNGpJskSvz5wFyF4tbEpnxvQR wzKQ== X-Gm-Message-State: AOJu0YyHqfBGS1vKELy7eEV0+EKOU5jzJ915aEfJizH+Wp4APjcbnWbv WOVOATm3IXuoWW1HqQkFjXEC1n9q7xH0mEo7NxhX5pG1jXRdw0ClFBGGJfLPvXY15mPCTYoma8K z X-Received: by 2002:a17:902:f64a:b0:1e3:ff5e:159f with SMTP id m10-20020a170902f64a00b001e3ff5e159fmr2442098plg.18.1712907235663; Fri, 12 Apr 2024 00:33:55 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id e5-20020a17090301c500b001e556734814sm2206099plh.134.2024.04.12.00.33.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 00:33:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 10/27] hw/dma/pl330: Use qemu_hexdump_line to avoid sprintf Date: Fri, 12 Apr 2024 00:33:29 -0700 Message-Id: <20240412073346.458116-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240412073346.458116-1-richard.henderson@linaro.org> References: <20240412073346.458116-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62c.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 From: Philippe Mathieu-Daudé sprintf() is deprecated on Darwin since macOS 13.0 / XCode 14.1. Using qemu_hexdump_line both fixes the deprecation warning and simplifies the code base. Signed-off-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- hw/dma/pl330.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/hw/dma/pl330.c b/hw/dma/pl330.c index 70a502d245..5f89295af3 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,22 +318,14 @@ typedef struct PL330InsnDesc { static void pl330_hexdump(uint8_t *buf, size_t size) { - unsigned int b, i, len; - char tmpbuf[80]; + g_autoptr(GString) str = g_string_sized_new(64); + size_t 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]); - } - trace_pl330_hexdump(b, tmpbuf); + for (b = 0; b < size; b += len) { + len = MIN(16, size - b); + g_string_truncate(str, 0); + qemu_hexdump_line(str, buf + b, len, 1, 4); + trace_pl330_hexdump(b, str->str); } } From patchwork Fri Apr 12 07:33:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 788254 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp590699wrm; Fri, 12 Apr 2024 00:35:13 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWzf0mS/1Pdq+Mybt0iY32I/DZOALsHLRpVlN7en+hNR20149sAl8KTEa4q1x3KcEtCg6bvIbZDq58KpKjX/Tjy X-Google-Smtp-Source: AGHT+IHFlNuKusJw4L0FINPG6xeKYLTBD94If8FQxri4GnCTlMPEQkTZZ/IzbgAZBuhtC+V6EAZi X-Received: by 2002:a0c:dd8f:0:b0:699:406d:9030 with SMTP id v15-20020a0cdd8f000000b00699406d9030mr2082927qvk.38.1712907313278; Fri, 12 Apr 2024 00:35:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712907313; cv=none; d=google.com; s=arc-20160816; b=oPraXP6tfEMI2rzyICxdXIno+P3Ijgc0Jf6OSV6n2XH+tZEO7FkhuyTOn58zYkZtBB rbM1G64JUT8d6bdafmHJa3vUd+EsmUZkwkzL2iSgccXyFN60nTH9RV/obWAIhmhEUw02 a1nTJmJDEh60f5vm3OZ6UqgYNGA7fgTUwM8zPvQBUXtwG7ag7RpiZ33MzXaMFkDbPtMj xyccKjfzNoXjTaf27JBVOPzAN1vhOc0Ahge3KBRdO9yfTs0+uggdbC8WqGv1KuxLKwAN utQ1BaXqbHbB0pRj2ack2itmyWlKY9p9DReJPewX2MMcYIswaFxsBXWMqEUNoUg/cMll MAZw== 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=+7uXdJXbZvFgUDV/6dLp0dNk/3VKiyesi33hYvTO4ao=; fh=jZ3p54AjrOULBe9UxOUKEqL9GOupA8QOIQHPSzacviQ=; b=UFvNikgyGnhQ2/SR5/3s8l73jqCajwJPE96jkuAWV62m5xbirO8mfosjukTjUOp/nZ 63KY7je+RokuT85qV4sDDp/zFAr/B+uGVvUJHD4FVO1PDF4xFFvr424/0/uTr9uKs0d/ zYZKZiuzC93gH9heUJDxXbUBZ+dH68qcZfZ8EOkFuO1/hJw4ooDIaVUbco3ULuHtT83b 7d1LfAYsqW/9Pzy8V0xkr9yoljIc2vzSDCiecgchvMpcjspotW4BF/jkiIvLDQ/4OAav +1iCHOBNwObalV9FwEDNGIF6i3C+RdQVphmV+w1lKlZm73RiRiJKbDqH9KmbffAvuJlE 9T2A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GcSJtibv; 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 ne1-20020a056214424100b006993eecb931si3092903qvb.601.2024.04.12.00.35.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 12 Apr 2024 00:35: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=GcSJtibv; 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 1rvBQJ-00075K-OM; Fri, 12 Apr 2024 03:34:11 -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 1rvBQC-00071a-0U for qemu-devel@nongnu.org; Fri, 12 Apr 2024 03:34:04 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0: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 1rvBQ5-000797-O0 for qemu-devel@nongnu.org; Fri, 12 Apr 2024 03:34:02 -0400 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1e5b6e8f662so1413895ad.0 for ; Fri, 12 Apr 2024 00:33:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712907236; x=1713512036; 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=+7uXdJXbZvFgUDV/6dLp0dNk/3VKiyesi33hYvTO4ao=; b=GcSJtibv9rodPYdW6Y516ABbpRY5FWgJhv0J+olKvlxdW3H0wOOcjldEAAorJU+nBA xmA1gGRZh7RGVgmV7+PUOfU0QpGKlQSYVTrPWVQF7crgpgUal8M0C+5RCQav4Fo2c4WV hySv6crQTK5p1a5+xkkWhuc7gJpRie7lm4a8xZsvKGgUnXptFCsn8saEx7eVFtWkKPsd XBijoPHbjSQvlB+AFptewFzgwv0noF0IpRnH7mqK4qWYJS2N/w9l/UundvD4DFcG1vZG jvCYBuWaHkb9BCycS636Cn859AG8CzymIQdn9W2dT7qDPAYwb9+1HhqqrWzhV8WxPZND 0bGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712907236; x=1713512036; 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=+7uXdJXbZvFgUDV/6dLp0dNk/3VKiyesi33hYvTO4ao=; b=TmNTkxy6iLyD0ActzZ1jkUJbAuEbNpOmjo9fM+F+YwMOSX5v4CohxHPStNq+7sQDb5 qYkaoWLRB8r8Rmb2sGeG1ghcU1OynCJ9zUDUJfmNrNcNFUuVYL13BA8DefK179sH8Lun zHor5uvkRdSr4fWkfxiNqCcLoGbQvCg17Q4td9yTxiUB9sL77K+i0LkaA0wFN1MOmPV1 1kP76AXoYrl0zX/4ZpKCqt5/pjz2cQwHHdTBW2cup+bzLZ4kD9X9dLBvEewDsWB0acbS uZa7ooAB/QNZRthSFLzsvAB56ogJV+5KUp3uUpguJ4hTMYM33XWvgtsOfNd7gwJkZ4Je yegg== X-Gm-Message-State: AOJu0Yxojar7JS96yv+gdSeF+gPOKLUCaB+Ob7CQLwSr6iP6fz1oGgpm yVt+6Mc2NuOxPb43birQncgc4wgkPgbiaV2RAvdg1rbTLSAMqKQD43EBdFpY7wAzmv6dD1sCYTr R X-Received: by 2002:a17:902:eb87:b0:1e4:12e1:88bc with SMTP id q7-20020a170902eb8700b001e412e188bcmr2498786plg.11.1712907236483; Fri, 12 Apr 2024 00:33:56 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id e5-20020a17090301c500b001e556734814sm2206099plh.134.2024.04.12.00.33.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 00:33:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Stefan Berger Subject: [PATCH v3 11/27] backends/tpm: Use qemu_hexdump_line to avoid sprintf Date: Fri, 12 Apr 2024 00:33:30 -0700 Message-Id: <20240412073346.458116-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240412073346.458116-1-richard.henderson@linaro.org> References: <20240412073346.458116-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.google.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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 From: Philippe Mathieu-Daudé sprintf() is deprecated on Darwin since macOS 13.0 / XCode 14.1. Using qemu_hexdump_line both fixes the deprecation warning and simplifies the code base. Reviewed-by: Stefan Berger Signed-off-by: Philippe Mathieu-Daudé [rth: Keep the linebreaks every 16 bytes] Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- backends/tpm/tpm_util.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/backends/tpm/tpm_util.c b/backends/tpm/tpm_util.c index 1856589c3b..bf3378fbbe 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,22 @@ 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; + g_autoptr(GString) str = NULL; + size_t len, i, l; 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); - - for (i = 0, p = line_buffer; i < len; i++) { - if (i && !(i % 16)) { - p += sprintf(p, "\n"); + for (i = 0; i < len; i += l) { + if (str) { + g_string_append_c(str, '\n'); } - p += sprintf(p, "%.2X ", buffer[i]); + l = MIN(len, 16); + str = qemu_hexdump_line(str, buffer, l, 1, 0); } - trace_tpm_util_show_buffer(string, len, line_buffer); - g_free(line_buffer); + g_string_ascii_up(str); + trace_tpm_util_show_buffer(string, len, str->str); } From patchwork Fri Apr 12 07:33:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 788250 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp590534wrm; Fri, 12 Apr 2024 00:34:42 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVrAbB6ZsbUhuqKcL44g34Cw5DMgS3cMmDxYU2kig7UsqexlgaBGY2IWlJnkQ53apuYM3dCNWSp3XvoCNiu9L9j X-Google-Smtp-Source: AGHT+IGyjvcMbhvA0JS/e4tFoIPRAQqKR36W1T59WAfce6vIzJnLr9e15YtAnnWXK97JCqIav2yP X-Received: by 2002:a05:6214:d82:b0:699:17cc:3e69 with SMTP id e2-20020a0562140d8200b0069917cc3e69mr2683377qve.61.1712907281671; Fri, 12 Apr 2024 00:34:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712907281; cv=none; d=google.com; s=arc-20160816; b=cvMzkxQE61JTx2keyWW40YRVbA8N5e56R8CbVbYtliogiSrFEcyqdUgyFxbMK/JpYY wQ0S+gp/A02acQPMuQe4sxSQu6bzXFsOomsGqc6PGKjGcZ+jDo5Edhp0SHQ3zJS4fcGn NIA8z6yPpWc2zZmSBro7VaUF4SIxeWaP0yB/JLcOSxs5i65I57qp9/Dq2sVHkNsfU4N6 H2sNsGi0F1dSVcUHOovQiLLnZeW6CNAHsVdLwdL6zohLy4Ki9i31ZLSfyUB9MRhiaNKQ jfNWdYFl5cBsbdAcPRpPz5Q5bNkDtAe3C65kE4ipNAnRYO5osdu5qnHn6kJcF0bt0J1G JxZg== 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=2rkNxCt/0g8Id1+pQXEkuRBEGY5hnj70aYW+ARQ9RhY=; fh=XWTD8Z9WAMjh+M8BxQj8k30uAZD5B0T9z1nl1AeO1vA=; b=mvgteLGE+8nvuoJFYi2GYi3kl+JDELQ2eByo1opiI/j17oeQLBDFH7uwtuIcG43HPC S2m7txDWhljrjmIcKgDdvBuw77/ddQrTROqa4y4LiDFNY7rCYluguA97ueadNKRKT2d0 s3dQHxUBuC5AfX6OaD2hXwZPVLW/8itzA9Ll4aMUcR3AyVXw54gJelsspRchsECHf481 oUVuYby3HRk9kmF+mot5UU2vqyr1EfdgLZimTTv4Gxgl4hwV4Z2bc2mZPJMhW5aIFznt nnqNVAsBVQW6bx5Be4xSYBlvzHZXskL7aO6E/4JgENC4INPk5uqcwcTFDVGixcAyFus3 JdUw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IARtOh47; 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 kk22-20020a056214509600b006993cf9de84si3354533qvb.343.2024.04.12.00.34.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 12 Apr 2024 00:34: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=IARtOh47; 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 1rvBQE-00072Y-ME; Fri, 12 Apr 2024 03:34:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rvBQ8-00070n-FL for qemu-devel@nongnu.org; Fri, 12 Apr 2024 03:34:01 -0400 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rvBQ6-00079b-US for qemu-devel@nongnu.org; Fri, 12 Apr 2024 03:34:00 -0400 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1e411e339b8so5282885ad.3 for ; Fri, 12 Apr 2024 00:33:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712907237; x=1713512037; 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=2rkNxCt/0g8Id1+pQXEkuRBEGY5hnj70aYW+ARQ9RhY=; b=IARtOh47MGDsmxINTCLsAlLoq5CkD61rkgaKBjMBK9nkSArqpj8+tPHa6w6yRC8vvH Tk0S0PZo9GRAsRcr1Uq/J/sS8OICGwuxm490d36XIVMQTUQcH5ADDaTF8cLA/5D/sCSl ZhFSro03qmK69JGFiIXgiWCxqoWcrbjTN7W3hcc1q3MK1E3wwrIWAReNgCPYhpnQj5bh GPyRpe/QzdI+G4QsprY/Wzy1ZT+uei8cpyRECxZCppW+4G1Tif9c4m4iHe3z0qYGN6kY PRM6Rm9A1KfMgHGjMPSRzCvAP9MibwKPW6i60OSphXmduNkTW0mAW0at1xcTUQQnwsEV vmww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712907237; x=1713512037; 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=2rkNxCt/0g8Id1+pQXEkuRBEGY5hnj70aYW+ARQ9RhY=; b=U2AyRBU7dNliZAU0y2EOugMTAjM9NNKhC22Yj+6+tSWrP0VPCsGsREJhcAXBZudhLs du0YiB+QZnEs4/K4li6bmzFCMBM3gBR3xUf0LP/uMRf/uCxlpgSIE80z4s6E3SeYfhLe ia7imXlfa9R/sKSL5xR+itcOyY51kkr7ovT720UQQ4KPlURdaRiYlM+Ln279xEhzSNvX DvHjODcG0RBtsqmc7lSD53yJ6d1+CmSszDTMtqgTYUKL8hCtQhLB+FEyudvPLnDVHbvk 4NpBd82WRyHMP/Y4xV2BbpssH0cL1ySzd8NOutr1uxXjJhkR7htHzDYWVTCCMh8s1a5c 9nhQ== X-Gm-Message-State: AOJu0YzBIPOwL4dy5fKn44XuVTMEPJz0VG1mzEw0ICZ0Y0NgrLnLVGUO 0gdiA+clQwaECIHolytfeaP2eczZ6xsvjH/yQN/Cuw437igcUt9vqJz4IOKtRo4Lsxf0ObA/L2r C X-Received: by 2002:a17:903:24d:b0:1e4:970e:37a7 with SMTP id j13-20020a170903024d00b001e4970e37a7mr1874001plh.60.1712907237402; Fri, 12 Apr 2024 00:33:57 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id e5-20020a17090301c500b001e556734814sm2206099plh.134.2024.04.12.00.33.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 00:33:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell Subject: [PATCH v3 12/27] disas/m68k: Replace sprintf() by snprintf() Date: Fri, 12 Apr 2024 00:33:31 -0700 Message-Id: <20240412073346.458116-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240412073346.458116-1-richard.henderson@linaro.org> References: <20240412073346.458116-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62e.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 From: Philippe Mathieu-Daudé sprintf() is deprecated on Darwin since macOS 13.0 / XCode 14.1, resulting in painful developper experience. Use snprintf() instead. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Reviewed-by: Peter Maydell Message-Id: <20240411104340.6617-2-philmd@linaro.org> Signed-off-by: Richard Henderson --- disas/m68k.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/disas/m68k.c b/disas/m68k.c index 1f16e295ab..800b4145ac 100644 --- a/disas/m68k.c +++ b/disas/m68k.c @@ -1000,7 +1000,7 @@ print_indexed (int basereg, /* Generate the text for the index register. Where this will be output is not yet determined. */ - sprintf (buf, "%s:%c%s", + snprintf(buf, sizeof(buf), "%s:%c%s", reg_names[(word >> 12) & 0xf], (word & 0x800) ? 'l' : 'w', scales[(word >> 9) & 3]); From patchwork Fri Apr 12 07:33:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 788274 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp591450wrm; Fri, 12 Apr 2024 00:37:49 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUo9PsYA3uiMNDo9Ikpw1kBDquH6QpCXeqoBnkUCSwmiFD14gIWeL1gtRZwsTrG6JSfnlzdK0uFGj2QUba8EI/0 X-Google-Smtp-Source: AGHT+IEbkjlkZGUdiAqJ9/B0NubezcelFrX7Iaa4yaEFIAMJlv3evA9iWo2pKpOO9Gd+I9EViMvX X-Received: by 2002:a05:622a:c6:b0:434:ff34:afc2 with SMTP id p6-20020a05622a00c600b00434ff34afc2mr2454378qtw.14.1712907468955; Fri, 12 Apr 2024 00:37:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712907468; cv=none; d=google.com; s=arc-20160816; b=gS9sP7d1v2LeJ29WGbqLnvcpT8CMARp1zg5FXgL3olYOfk3IhPzLHjOGadyq1DUxQb 65QIYehOCOsSkbPQri/vDuT7lCQcIoEl6kVCrP/rhfp6cfrmjYkjL3iLa5Y9eGi/9Yw8 hu8BVqGRtGLlbKPoUDpMkwWOwKNosIUl4n/Tzt8BDlW7yTs3paULShnjMMvf7RDx3My2 QiihQkmJw3y6qYLZsaZZpEmYXP9olTthujQqgveHrwnGhZOwLbFRZ8Woy6jOzZuq8iWw zVEx7AKlhpvozITibf0CmB0lezgxf8f5VLhWfTZNSzA7k9atTZKZxkExiuhbzTHFUnAb 6OLg== 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=5eqjrZGd5HpdIOKB4IPvtcJuO95xZlA91V8rntFRy4Y=; fh=5npuwfIFBLevOBV801kjakwJI45ZchDf58buL9gi2tg=; b=rMbD5E6NKkvxjetKWE5xserYisrDHlUsnNdNkyXz42vH2BIf8RK9nDFghrEUkFj6od v38S4/0NeUBK2wMKg1cu2cYlNFAMGblzFFeFIx84x6pUUP5/LDYJ9jwy+kgG26h2lMU/ cB0igdooLbwiDgY63gpZyVlFQLVvflSjryiDepEO6F6HeT+3i1Z8u/G8cDMGGe40TOVw 9QMnWBAw5FGqnOIQRFcG75mHELLr+cHN4RuzQmzdh9mI1jhdSjei+m9eK15+7ZI5xcMf tfnyUCAfvsd5m517aq5InCxsp84FhUPSCkSMEm4KjUl0y3wR7JMoAX9lHVrVX0z9PNQE BbZw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GsxyWnq4; 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 v2-20020a05622a144200b004366ce6c2b8si1074807qtx.206.2024.04.12.00.37.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 12 Apr 2024 00:37:48 -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=GsxyWnq4; 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 1rvBQI-00074L-Rm; Fri, 12 Apr 2024 03:34:10 -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 1rvBQA-00070r-9f for qemu-devel@nongnu.org; Fri, 12 Apr 2024 03:34:03 -0400 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rvBQ7-0007Ab-Dp for qemu-devel@nongnu.org; Fri, 12 Apr 2024 03:34:01 -0400 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1e3c3aa8938so4339325ad.1 for ; Fri, 12 Apr 2024 00:33:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712907238; x=1713512038; 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=5eqjrZGd5HpdIOKB4IPvtcJuO95xZlA91V8rntFRy4Y=; b=GsxyWnq4SPm1F6qxQ7Er7HRkqR5DDdg2apELXOOdsttru4Erlo2D/uH1sSa9vSIwoD f6yyyPNGUWwi7qe1smpliAwLbJXWOKB1L8Ekdv2Q+p0iN3HnU93OVIq1LrIBTox5QmUh K4wse7xjKckIvfXuB6UJP9Pvtwh0fXKP/z6joiPAHxn9UasRybTZP0hvBEEg+aoXoSBw nocGumaEgJOn9VViOJeQ1zvI8RYjyn8zweCrBm3Kld1XzoFJ1nxVKbbsDNWy5g9GA6aK JV0qgRICARRuFryGdQ5er2ikjgW0dO/fscmtd9L9DPc9lPelolMmLn/EpHP709VyD1/m 4URQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712907238; x=1713512038; 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=5eqjrZGd5HpdIOKB4IPvtcJuO95xZlA91V8rntFRy4Y=; b=GYPCvFYMLqeAW4dh8rKKZM0QOZobk8DbxNAkHFmauZqov+OtF9scQq2rLTulogkgIW PQJhsFr1nO8vDy8kNYB8fT8P/j8QM0Z3DG/nuNLulYCaqCoJYy9YQnCPv5yP8WnGaJ4W EJtJ06Joe3xcEYzNi2suuo9fFIq+vFbuWCFfYFO/UXJbPgbXh5AtZp+HKdVnBVjk1wV4 QHZvA2EIyKaDrHuC4stewUQ5grnXx2Emgo0YEQgu4lYeeVK3eRscH5WXinPhh7rVSr9Y 1ej4a1aa5zuthMBEI239+LKfo1+31iVCqDhGi4wl8EIKpxwkySCQHwuZYs7H5wAaRhb4 pyjQ== X-Gm-Message-State: AOJu0YwyacDpnDYUoHuYn+VL4/4sltLnLE6ncVh+f+w3/ZdY5Zf/tUrY UPdzTG1jZSUlbiqIoSxOt9iHq25Tc0HC6+iDiNdwWoJQ5bIDCcuh7df2EOjlKa6/rJsZtJ/nzRj t X-Received: by 2002:a17:902:e882:b0:1e4:70d0:9337 with SMTP id w2-20020a170902e88200b001e470d09337mr2121487plg.45.1712907238090; Fri, 12 Apr 2024 00:33:58 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id e5-20020a17090301c500b001e556734814sm2206099plh.134.2024.04.12.00.33.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 00:33:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Edgar E . Iglesias" Subject: [PATCH v3 13/27] disas/microblaze: Replace sprintf() by snprintf() Date: Fri, 12 Apr 2024 00:33:32 -0700 Message-Id: <20240412073346.458116-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240412073346.458116-1-richard.henderson@linaro.org> References: <20240412073346.458116-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62d.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 From: Philippe Mathieu-Daudé sprintf() is deprecated on Darwin since macOS 13.0 / XCode 14.1, resulting in painful developper experience. Use snprintf() instead. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Edgar E. Iglesias Message-Id: <20240411104340.6617-3-philmd@linaro.org> Signed-off-by: Richard Henderson --- disas/microblaze.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/disas/microblaze.c b/disas/microblaze.c index 0b89b9c4fa..49a4c0fd40 100644 --- a/disas/microblaze.c +++ b/disas/microblaze.c @@ -600,7 +600,8 @@ static char * get_field (long instr, long mask, unsigned short low) { char tmpstr[25]; - sprintf(tmpstr, "%s%d", register_prefix, (int)((instr & mask) >> low)); + snprintf(tmpstr, sizeof(tmpstr), "%s%d", register_prefix, + (int)((instr & mask) >> low)); return(strdup(tmpstr)); } @@ -608,7 +609,8 @@ static char * get_field_imm (long instr) { char tmpstr[25]; - sprintf(tmpstr, "%d", (short)((instr & IMM_MASK) >> IMM_LOW)); + snprintf(tmpstr, sizeof(tmpstr), "%d", + (short)((instr & IMM_MASK) >> IMM_LOW)); return(strdup(tmpstr)); } @@ -616,7 +618,8 @@ static char * get_field_imm5 (long instr) { char tmpstr[25]; - sprintf(tmpstr, "%d", (short)((instr & IMM5_MASK) >> IMM_LOW)); + snprintf(tmpstr, sizeof(tmpstr), "%d", + (short)((instr & IMM5_MASK) >> IMM_LOW)); return(strdup(tmpstr)); } @@ -624,7 +627,8 @@ static char * get_field_rfsl (long instr) { char tmpstr[25]; - sprintf(tmpstr, "%s%d", fsl_register_prefix, (short)((instr & RFSL_MASK) >> IMM_LOW)); + snprintf(tmpstr, sizeof(tmpstr), "%s%d", fsl_register_prefix, + (short)((instr & RFSL_MASK) >> IMM_LOW)); return(strdup(tmpstr)); } @@ -632,7 +636,8 @@ static char * get_field_imm15 (long instr) { char tmpstr[25]; - sprintf(tmpstr, "%d", (short)((instr & IMM15_MASK) >> IMM_LOW)); + snprintf(tmpstr, sizeof(tmpstr), "%d", + (short)((instr & IMM15_MASK) >> IMM_LOW)); return(strdup(tmpstr)); } @@ -641,7 +646,8 @@ static char * get_field_unsigned_imm (long instr) { char tmpstr[25]; - sprintf(tmpstr, "%d", (int)((instr & IMM_MASK) >> IMM_LOW)); + snprintf(tmpstr, sizeof(tmpstr), "%d", + (int)((instr & IMM_MASK) >> IMM_LOW)); return(strdup(tmpstr)); } #endif @@ -653,7 +659,8 @@ get_field_unsigned_imm (long instr) { char tmpstr[25]; - sprintf(tmpstr, "%s%s", register_prefix, (((instr & IMM_MASK) >> IMM_LOW) & REG_MSR_MASK) == 0 ? "pc" : "msr"); + snprintf(tmpstr, sizeof(tmpstr), "%s%s", register_prefix, + (((instr & IMM_MASK) >> IMM_LOW) & REG_MSR_MASK) == 0 ? "pc" : "msr"); return(strdup(tmpstr)); } @@ -709,7 +716,7 @@ get_field_special(long instr, const struct op_code_struct *op) default : { if ( ((((instr & IMM_MASK) >> IMM_LOW) ^ op->immval_mask) & 0xE000) == REG_PVR_MASK) { - sprintf(tmpstr, "%s%u", pvr_register_prefix, + snprintf(tmpstr, sizeof(tmpstr), "%s%u", pvr_register_prefix, (unsigned short)(((instr & IMM_MASK) >> IMM_LOW) ^ op->immval_mask) ^ REG_PVR_MASK); return(strdup(tmpstr)); @@ -720,7 +727,7 @@ get_field_special(long instr, const struct op_code_struct *op) break; } - sprintf(tmpstr, "%s%s", register_prefix, spr); + snprintf(tmpstr, sizeof(tmpstr), "%s%s", register_prefix, spr); return(strdup(tmpstr)); } From patchwork Fri Apr 12 07:33:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 788272 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp591431wrm; Fri, 12 Apr 2024 00:37:46 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWvH0P1ZR4BK6KLmixvAgAwgrTbnyr8heY2EjQA1DxSnbChBmUNeha1wfFxs2IfSyhvmiCJbB1gZwI+dJl+m5Dp X-Google-Smtp-Source: AGHT+IFWuBIwBSllkEwnPwQ/TJPKHe1BKudHOb4FNuU0xnXrXDpHijAxP+/qgeNI6q8esnApRooB X-Received: by 2002:a0c:f846:0:b0:69b:155c:a775 with SMTP id g6-20020a0cf846000000b0069b155ca775mr1880334qvo.26.1712907466349; Fri, 12 Apr 2024 00:37:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712907466; cv=none; d=google.com; s=arc-20160816; b=DpljYYh/KCcG40w5KCNmFccAMuzveniAMX/QsuwAs384A8HkHd3Q7216msOV7yzQKH JyGjpcxEg5+hnpyi0Nzh74RG9B9KPvZGlQjM32XRCHCnhGIRwded64u+boUueNSp25HH fqqQ7agKkAQ6YsCLy+mErcJjU9udRu19SZhuLxZTxBk+EMqrGkTGPnGcodz71aALzakL cLmH0PHPqyePILehgGBmXOFW4Dgxt4U6Lg05/WYBu9ovjpnUExe7uMQfsLdilCc3eiNX RR8aetppQhbdWCrilKcHUAuO4bnK6rovslzOlpr9mDk5BL95TTxKiso6zW43eh9SuJJg WQMg== 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:to:from :dkim-signature; bh=rYVeh39A85lKzN367OYcjUFCWQI2goI5Bmql3JBqN/4=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=WEU9bpvYSWL6hNdfn4f4cqPaqe4OxVfm/lpMOJrIwVc5ed0HN6YnagL4w9Opsv2OXB mkFLu2rjoZaCZaxS3/zaIQepDW0uBSYO1crFoijLA9CUbr7Nq88TfvjtYrKe0VTQWBXn iZo9SD1NxIrcMajdQDFrzkEm8VrrsnpXX8gsHZwvN3uFFhrjaKxvcWGqwpB/3RNhIQKv IvTK5eB+XVluuV0WOib4xuxaViygnznNGWF/7rQ1Pxa3UrKY/CjBi4bbJaSXv+qpNohD 0Xxg6syQnXqPUmXNFTITj2Iss3IUPKbC3Go79FoVVuE0t9I/8pzMozYLFE/kb5rbdVTn NeKg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Oie4f+HN; 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 c23-20020a056214071700b0069b489250fdsi3160335qvz.583.2024.04.12.00.37.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 12 Apr 2024 00:37:46 -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=Oie4f+HN; 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 1rvBQI-00074H-3N; Fri, 12 Apr 2024 03:34:10 -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 1rvBQA-00070s-9l for qemu-devel@nongnu.org; Fri, 12 Apr 2024 03:34:03 -0400 Received: from mail-pl1-x634.google.com ([2607:f8b0: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 1rvBQ7-0007BB-Ve for qemu-devel@nongnu.org; Fri, 12 Apr 2024 03:34:01 -0400 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1e3c9300c65so6283825ad.0 for ; Fri, 12 Apr 2024 00:33:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712907239; x=1713512039; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=rYVeh39A85lKzN367OYcjUFCWQI2goI5Bmql3JBqN/4=; b=Oie4f+HNrso8VcxuLvXfbRirQR/F89QWTrudQ2ye6PCwB+7oi2KSKbEW9N04VEMGq2 ANF3azTIB8F9t9IGp7Fv/VeiSleiPBGuxD3h3oJHw58t0PUNHHQWx8mJsEwkZKv9ZZsX apktQXyVDnCXCXiDiADyRS2YYLDQlrRs6SAqbUIJO6Ed0HrYS9hPNeYKhMsqpWhUu4/t D2GhUOdeOvRsuUZDzpYfKz+i8btM5ke11yZpQTHtNEQLXcQqujxoWLv6hHiAbgqSh2Rg E/D31qHb3sSVpp6DpmUPfdmUA9XXDAseNRBw+ZZAHyQtstQa1vK3SBhleUxocFI1Ie8Q hFoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712907239; x=1713512039; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rYVeh39A85lKzN367OYcjUFCWQI2goI5Bmql3JBqN/4=; b=WZncITnH6S4EVZlyeZqUWxaL0SEdtu2StVU47NE5VnY8OBkq6C+QLjnDqi8snOmFQm 7wreJ+jx5HQJqY11eivmrZH2lpMCq4Pd2y+nhbDB0YnFXdTYdZHV22PiG/zq5m1c09mf hbEbJ1cSPiLJ8bjGYDLKG6P4iqonmOLtlHDQQlS58rh/ADwg9NxHMtmLu65sbRX7z3o9 MYmYMNSD2LdtohULfaf9w8zzYbN58RDXMTrVqZ11YeV6klIEGKf6p2aHo28x9QmQc6OH JwAi+m7YOpzneoVBh3/s5070QahgGjeqcQ7/1pZZXIfvhgvZgHYwpyTLE9mqlKtaRFCZ uShQ== X-Gm-Message-State: AOJu0Yxj0n74qo67S9Jsm/r6oeaUaJiIhaskbU2g3E9n+jF+qo29KJvl dO1pjtsQ+YcTlgmzZwDs+hULijd0EWYnn4yWnxcDyvzgLmehcMsYvbcOOf7ud/B3AVuMBb3nsEj T X-Received: by 2002:a17:902:ba84:b0:1e4:4a3f:9a88 with SMTP id k4-20020a170902ba8400b001e44a3f9a88mr1489311pls.46.1712907238778; Fri, 12 Apr 2024 00:33:58 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id e5-20020a17090301c500b001e556734814sm2206099plh.134.2024.04.12.00.33.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 00:33:58 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 14/27] disas/microblaze: Split out print_immval_addr Date: Fri, 12 Apr 2024 00:33:33 -0700 Message-Id: <20240412073346.458116-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240412073346.458116-1-richard.henderson@linaro.org> References: <20240412073346.458116-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::634; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-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=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 Unify the code blocks that try to print a symbolic address. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- disas/microblaze.c | 89 +++++++++++++++------------------------------- 1 file changed, 29 insertions(+), 60 deletions(-) diff --git a/disas/microblaze.c b/disas/microblaze.c index 49a4c0fd40..3473c94164 100644 --- a/disas/microblaze.c +++ b/disas/microblaze.c @@ -767,6 +767,24 @@ read_insn_microblaze (bfd_vma memaddr, return inst; } +static void print_immval_addr(struct disassemble_info *info, bool immfound, + int immval, unsigned inst, int addend) +{ + if (info->print_address_func && info->symbol_at_address_func) { + if (immfound) { + immval |= get_int_field_imm(inst) & 0x0000ffff; + } else { + immval = (int16_t)get_int_field_imm(inst); + } + immval += addend; + if (immval != 0 && info->symbol_at_address_func(immval, info)) { + info->fprintf_func(info->stream, "\t// "); + info->print_address_func (immval, info); + } else if (addend) { + info->fprintf_func(info->stream, "\t// %x", immval); + } + } +} int print_insn_microblaze (bfd_vma memaddr, struct disassemble_info * info) @@ -821,18 +839,8 @@ print_insn_microblaze (bfd_vma memaddr, struct disassemble_info * info) break; case INST_TYPE_RD_R1_IMM: fprintf_func(stream, "\t%s, %s, %s", get_field_rd(inst), get_field_r1(inst), get_field_imm(inst)); - if (info->print_address_func && get_int_field_r1(inst) == 0 && info->symbol_at_address_func) { - if (immfound) - immval |= (get_int_field_imm(inst) & 0x0000ffff); - else { - immval = get_int_field_imm(inst); - if (immval & 0x8000) - immval |= 0xFFFF0000; - } - if (immval > 0 && info->symbol_at_address_func(immval, info)) { - fprintf_func (stream, "\t// "); - info->print_address_func (immval, info); - } + if (get_int_field_r1(inst) == 0) { + print_immval_addr(info, immfound, immval, inst, 0); } break; case INST_TYPE_RD_R1_IMM5: @@ -860,61 +868,22 @@ print_insn_microblaze (bfd_vma memaddr, struct disassemble_info * info) fprintf_func(stream, "\t%s, %s", get_field_r1(inst), get_field_imm(inst)); /* The non-pc relative instructions are returns, which shouldn't have a label printed */ - if (info->print_address_func && op->inst_offset_type == INST_PC_OFFSET && info->symbol_at_address_func) { - if (immfound) - immval |= (get_int_field_imm(inst) & 0x0000ffff); - else { - immval = get_int_field_imm(inst); - if (immval & 0x8000) - immval |= 0xFFFF0000; - } - immval += memaddr; - if (immval > 0 && info->symbol_at_address_func(immval, info)) { - fprintf_func (stream, "\t// "); - info->print_address_func (immval, info); - } else { - fprintf_func (stream, "\t\t// "); - fprintf_func (stream, "%x", immval); - } + if (op->inst_offset_type == INST_PC_OFFSET) { + print_immval_addr(info, immfound, immval, inst, memaddr); } break; case INST_TYPE_RD_IMM: fprintf_func(stream, "\t%s, %s", get_field_rd(inst), get_field_imm(inst)); - if (info->print_address_func && info->symbol_at_address_func) { - if (immfound) - immval |= (get_int_field_imm(inst) & 0x0000ffff); - else { - immval = get_int_field_imm(inst); - if (immval & 0x8000) - immval |= 0xFFFF0000; - } - if (op->inst_offset_type == INST_PC_OFFSET) - immval += (int) memaddr; - if (info->symbol_at_address_func(immval, info)) { - fprintf_func (stream, "\t// "); - info->print_address_func (immval, info); - } - } + print_immval_addr(info, immfound, immval, inst, + op->inst_offset_type == INST_PC_OFFSET + ? memaddr : 0); break; case INST_TYPE_IMM: fprintf_func(stream, "\t%s", get_field_imm(inst)); - if (info->print_address_func && info->symbol_at_address_func && op->instr != imm) { - if (immfound) - immval |= (get_int_field_imm(inst) & 0x0000ffff); - else { - immval = get_int_field_imm(inst); - if (immval & 0x8000) - immval |= 0xFFFF0000; - } - if (op->inst_offset_type == INST_PC_OFFSET) - immval += (int) memaddr; - if (immval > 0 && info->symbol_at_address_func(immval, info)) { - fprintf_func (stream, "\t// "); - info->print_address_func (immval, info); - } else if (op->inst_offset_type == INST_PC_OFFSET) { - fprintf_func (stream, "\t\t// "); - fprintf_func (stream, "%x", immval); - } + if (op->instr != imm) { + print_immval_addr(info, immfound, immval, inst, + op->inst_offset_type == INST_PC_OFFSET + ? memaddr : 0); } break; case INST_TYPE_RD_R2: From patchwork Fri Apr 12 07:33:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 788265 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp591177wrm; Fri, 12 Apr 2024 00:36:48 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXkkVhJwiP+n4Nyyd5HEO1pT6DwvYq8J7nbb7vmXMkEs3xynzbeQlPIY1IQqviaAEsEzY6ivW70v8H0wXg1bftX X-Google-Smtp-Source: AGHT+IGECtZMFmzi6J9I/892wLpPrNqCiYZnrApGMhAhzeBbShcveBpDrSIFJ0Czw17iyNhhFzm4 X-Received: by 2002:a0c:ec8e:0:b0:696:50bf:15d0 with SMTP id u14-20020a0cec8e000000b0069650bf15d0mr2232794qvo.56.1712907407871; Fri, 12 Apr 2024 00:36:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712907407; cv=none; d=google.com; s=arc-20160816; b=p3BzruYI6Djh3/sjyqeKYmd4oLXwAI6MJxRe6csXrKhZw9PRpEnEpBz/i1rkIzI6SS Pjshr3wLqmDuv7ou1sm5elCby1er0TKicIU41f82brfkruqFp9OZMZ04FOVNc7sIw8SR pNehGWanHDvzcJFwGNxk0FurWpQeFpcPkP5SZEEk7nJWzm+RUEUvB5mcDHp2dKPO/qWu egaP26ia6PaABp29R5c8YEsCVYDKjT25otle1c73ev0ozNDHmv5fdC2Yfbl8SLwwIBvm KQtla2pfMnd4V4pHheeWw+iDnHAavygkisH4hTNr5nZ9a+R+yGxnDhcu6nQrdiX4ViZL /rfA== 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:to:from :dkim-signature; bh=6HJ1SMmA8I+3QuAFdhuJVGFMyvOQ304pvIkGq8bmlYE=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=kqBj0a41pXxhHqkDImXxnqoIg6DHo0kRpx6Tnu4cwNXluhJ+f9+c6k8nxegOFA7QRc uLFNiC72ktYXnn6x8ezBQj3I+IdYwIHEhLaaUarfTr9L6radgJMX8SUvg9pDht61Zme+ LEfP/S0n8zL193QI/PVtZ/37qfHEaGvnRsM5VNrJ05olTaVzlYzZo8fNzqpQ3R1YE4Gs s88AkkMDhGyfoVT9O/rjnvejpSC7al6zfGKJztACusbiJOws0PXsfzVpS16sEsN8p8Zq mRCpDJIftbw2AVAktJkHax2b/MwLn8wa5T2RL+gDqrLWvdhcXjC7vK0upfoTYxr/EywB Pdwg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fRWCKJ16; 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 ct7-20020a056214178700b006990bba9572si3117609qvb.552.2024.04.12.00.36.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 12 Apr 2024 00:36:47 -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=fRWCKJ16; 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 1rvBQH-000740-Fl; Fri, 12 Apr 2024 03:34:09 -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 1rvBQB-00071Z-W9 for qemu-devel@nongnu.org; Fri, 12 Apr 2024 03:34:04 -0400 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rvBQ9-0007Bz-67 for qemu-devel@nongnu.org; Fri, 12 Apr 2024 03:34:02 -0400 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1e3cf5b171eso5656085ad.0 for ; Fri, 12 Apr 2024 00:34:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712907240; x=1713512040; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=6HJ1SMmA8I+3QuAFdhuJVGFMyvOQ304pvIkGq8bmlYE=; b=fRWCKJ16wj/9zLqvhGd1JWRQZn6wUegW8N9LV/hGOeVqc/SesWVm2f88wcSwSPJHfX hanCVfY8ysxdXySt4AZ+puG6mj5SPCEBp+ZrqJTcKwYK8zKIzv8lNHsYm9rzLwe/f1E+ RYGXp4c+/pA3FbV56bXlTNuSfKkokvKBfY14HhKNmgMQylu6OmfplbUKrFNm0XAmltZ8 xOB4U93KIjo5OGF0dL+2X9UL1/+fZet4Bz1pPyzaWfdaCI0ekZCNLLHyhxXZ8cdts4RK xo95E2UJ/NwlvSV5CHJSJtqnUtAcWzCNzGoACHd6kLl8mAlVKat89IjN5aVA+T+x8pRV CbZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712907240; x=1713512040; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6HJ1SMmA8I+3QuAFdhuJVGFMyvOQ304pvIkGq8bmlYE=; b=Fq8exkgfPAQswrPk2xWJfxOviWCoHPifXWBcfFhrWflnvp9jTd2eujHkh/n4FDKGfh yll7/roYMhCPOss2ULqcSNhJ2PSGvi+1vOzAQEA+xdKUHqEdQ13egZ9gGoGj/hnLv4um nWpx/RKqFHKsCvIwBTq5cTRZxhoxgAo4rn1alnf1BKAOuiYmdhD6d7PAPCahmhn/yisz mnwAN//S8KUbMeMbouGrDJltVKNty8suxmSeRQoYbaMTrndUdgafOLaocHmnu23o7GcU upIpzNrUL6aNi/pVIBsATBRH8Vfrwp7uAGLGq+FxZ4Npub+CAkhpD2o+DU3gwfyn2xe8 FBZw== X-Gm-Message-State: AOJu0YzZrnWgQD6UnicGSUe8Ghc2dKYQ/+N4Di+T9pmcs+QZVGEjrzP8 7uGgWZpWx1B8Fr2gwNL4t5RNK76DdziMZSsnT8y8uo9noz7sJH2EdUnVMvn9IKgh+qw8gAA54Z2 H X-Received: by 2002:a17:902:a98a:b0:1e3:de79:35d1 with SMTP id bh10-20020a170902a98a00b001e3de7935d1mr1685068plb.23.1712907239662; Fri, 12 Apr 2024 00:33:59 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id e5-20020a17090301c500b001e556734814sm2206099plh.134.2024.04.12.00.33.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 00:33:59 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 15/27] target/microblaze: Re-indent print_insn_microblaze Date: Fri, 12 Apr 2024 00:33:34 -0700 Message-Id: <20240412073346.458116-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240412073346.458116-1-richard.henderson@linaro.org> References: <20240412073346.458116-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::629; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x629.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 Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- disas/microblaze.c | 263 ++++++++++++++++++++++++--------------------- 1 file changed, 141 insertions(+), 122 deletions(-) diff --git a/disas/microblaze.c b/disas/microblaze.c index 3473c94164..c729c76585 100644 --- a/disas/microblaze.c +++ b/disas/microblaze.c @@ -787,134 +787,153 @@ static void print_immval_addr(struct disassemble_info *info, bool immfound, } int -print_insn_microblaze (bfd_vma memaddr, struct disassemble_info * info) +print_insn_microblaze(bfd_vma memaddr, struct disassemble_info *info) { - fprintf_function fprintf_func = info->fprintf_func; - void * stream = info->stream; - unsigned long inst, prev_inst; - const struct op_code_struct *op, *pop; - int immval = 0; - bfd_boolean immfound = FALSE; - static bfd_vma prev_insn_addr = -1; /*init the prev insn addr */ - static int prev_insn_vma = -1; /*init the prev insn vma */ - int curr_insn_vma = info->buffer_vma; + fprintf_function fprintf_func = info->fprintf_func; + void *stream = info->stream; + unsigned long inst, prev_inst; + const struct op_code_struct *op, *pop; + int immval = 0; + bool immfound = false; + static bfd_vma prev_insn_addr = -1; /*init the prev insn addr */ + static int prev_insn_vma = -1; /*init the prev insn vma */ + int curr_insn_vma = info->buffer_vma; - info->bytes_per_chunk = 4; + info->bytes_per_chunk = 4; - inst = read_insn_microblaze (memaddr, info, &op); - if (inst == 0) { - return -1; - } + inst = read_insn_microblaze (memaddr, info, &op); + if (inst == 0) { + return -1; + } - if (prev_insn_vma == curr_insn_vma) { - if (memaddr-(info->bytes_per_chunk) == prev_insn_addr) { - prev_inst = read_insn_microblaze (prev_insn_addr, info, &pop); - if (prev_inst == 0) - return -1; - if (pop->instr == imm) { - immval = (get_int_field_imm(prev_inst) << 16) & 0xffff0000; - immfound = TRUE; + if (prev_insn_vma == curr_insn_vma) { + if (memaddr - info->bytes_per_chunk == prev_insn_addr) { + prev_inst = read_insn_microblaze (prev_insn_addr, info, &pop); + if (prev_inst == 0) + return -1; + if (pop->instr == imm) { + immval = (get_int_field_imm(prev_inst) << 16) & 0xffff0000; + immfound = TRUE; + } + else { + immval = 0; + immfound = FALSE; + } + } } - else { - immval = 0; - immfound = FALSE; - } - } - } - /* make curr insn as prev insn */ - prev_insn_addr = memaddr; - prev_insn_vma = curr_insn_vma; + /* make curr insn as prev insn */ + prev_insn_addr = memaddr; + prev_insn_vma = curr_insn_vma; - if (op->name == 0) { - fprintf_func (stream, ".short 0x%04lx", inst); - } - else - { - fprintf_func (stream, "%s", op->name); + if (op->name == 0) { + fprintf_func (stream, ".short 0x%04lx", inst); + return 4; + } + + fprintf_func (stream, "%s", op->name); - switch (op->inst_type) - { - case INST_TYPE_RD_R1_R2: - fprintf_func(stream, "\t%s, %s, %s", get_field_rd(inst), get_field_r1(inst), get_field_r2(inst)); - break; - case INST_TYPE_RD_R1_IMM: - fprintf_func(stream, "\t%s, %s, %s", get_field_rd(inst), get_field_r1(inst), get_field_imm(inst)); - if (get_int_field_r1(inst) == 0) { - print_immval_addr(info, immfound, immval, inst, 0); - } - break; - case INST_TYPE_RD_R1_IMM5: - fprintf_func(stream, "\t%s, %s, %s", get_field_rd(inst), get_field_r1(inst), get_field_imm5(inst)); - break; - case INST_TYPE_RD_RFSL: - fprintf_func(stream, "\t%s, %s", get_field_rd(inst), get_field_rfsl(inst)); - break; - case INST_TYPE_R1_RFSL: - fprintf_func(stream, "\t%s, %s", get_field_r1(inst), get_field_rfsl(inst)); - break; - case INST_TYPE_RD_SPECIAL: - fprintf_func(stream, "\t%s, %s", get_field_rd(inst), get_field_special(inst, op)); - break; - case INST_TYPE_SPECIAL_R1: - fprintf_func(stream, "\t%s, %s", get_field_special(inst, op), get_field_r1(inst)); - break; - case INST_TYPE_RD_R1: - fprintf_func(stream, "\t%s, %s", get_field_rd(inst), get_field_r1(inst)); - break; - case INST_TYPE_R1_R2: - fprintf_func(stream, "\t%s, %s", get_field_r1(inst), get_field_r2(inst)); - break; - case INST_TYPE_R1_IMM: - fprintf_func(stream, "\t%s, %s", get_field_r1(inst), get_field_imm(inst)); - /* The non-pc relative instructions are returns, which shouldn't - have a label printed */ - if (op->inst_offset_type == INST_PC_OFFSET) { - print_immval_addr(info, immfound, immval, inst, memaddr); - } - break; - case INST_TYPE_RD_IMM: - fprintf_func(stream, "\t%s, %s", get_field_rd(inst), get_field_imm(inst)); - print_immval_addr(info, immfound, immval, inst, - op->inst_offset_type == INST_PC_OFFSET - ? memaddr : 0); - break; - case INST_TYPE_IMM: - fprintf_func(stream, "\t%s", get_field_imm(inst)); - if (op->instr != imm) { - print_immval_addr(info, immfound, immval, inst, - op->inst_offset_type == INST_PC_OFFSET - ? memaddr : 0); - } - break; - case INST_TYPE_RD_R2: - fprintf_func(stream, "\t%s, %s", get_field_rd(inst), get_field_r2(inst)); - break; - case INST_TYPE_R2: - fprintf_func(stream, "\t%s", get_field_r2(inst)); - break; - case INST_TYPE_R1: - fprintf_func(stream, "\t%s", get_field_r1(inst)); - break; - case INST_TYPE_RD_R1_SPECIAL: - fprintf_func(stream, "\t%s, %s", get_field_rd(inst), get_field_r2(inst)); - break; - case INST_TYPE_RD_IMM15: - fprintf_func(stream, "\t%s, %s", get_field_rd(inst), get_field_imm15(inst)); - break; - /* For tuqula instruction */ - case INST_TYPE_RD: - fprintf_func(stream, "\t%s", get_field_rd(inst)); - break; - case INST_TYPE_RFSL: - fprintf_func(stream, "\t%s", get_field_rfsl(inst)); - break; - default: - /* if the disassembler lags the instruction set */ - fprintf_func (stream, "\tundecoded operands, inst is 0x%04lx", inst); - break; - } + switch (op->inst_type) { + case INST_TYPE_RD_R1_R2: + fprintf_func(stream, "\t%s, %s, %s", + get_field_rd(inst), get_field_r1(inst), + get_field_r2(inst)); + break; + case INST_TYPE_RD_R1_IMM: + fprintf_func(stream, "\t%s, %s, %s", + get_field_rd(inst), get_field_r1(inst), + get_field_imm(inst)); + if (get_int_field_r1(inst) == 0) { + print_immval_addr(info, immfound, immval, inst, 0); + } + break; + case INST_TYPE_RD_R1_IMM5: + fprintf_func(stream, "\t%s, %s, %s", + get_field_rd(inst), get_field_r1(inst), + get_field_imm5(inst)); + break; + case INST_TYPE_RD_RFSL: + fprintf_func(stream, "\t%s, %s", + get_field_rd(inst), get_field_rfsl(inst)); + break; + case INST_TYPE_R1_RFSL: + fprintf_func(stream, "\t%s, %s", + get_field_r1(inst), get_field_rfsl(inst)); + break; + case INST_TYPE_RD_SPECIAL: + fprintf_func(stream, "\t%s, %s", + get_field_rd(inst), get_field_special(inst, op)); + break; + case INST_TYPE_SPECIAL_R1: + fprintf_func(stream, "\t%s, %s", + get_field_special(inst, op), get_field_r1(inst)); + break; + case INST_TYPE_RD_R1: + fprintf_func(stream, "\t%s, %s", + get_field_rd(inst), get_field_r1(inst)); + break; + case INST_TYPE_R1_R2: + fprintf_func(stream, "\t%s, %s", + get_field_r1(inst), get_field_r2(inst)); + break; + case INST_TYPE_R1_IMM: + fprintf_func(stream, "\t%s, %s", + get_field_r1(inst), get_field_imm(inst)); + /* + * The non-pc relative instructions are returns, + * which shouldn't have a label printed. + */ + if (op->inst_offset_type == INST_PC_OFFSET) { + print_immval_addr(info, immfound, immval, inst, memaddr); + } + break; + case INST_TYPE_RD_IMM: + fprintf_func(stream, "\t%s, %s", + get_field_rd(inst), get_field_imm(inst)); + print_immval_addr(info, immfound, immval, inst, + op->inst_offset_type == INST_PC_OFFSET + ? memaddr : 0); + break; + case INST_TYPE_IMM: + fprintf_func(stream, "\t%s", get_field_imm(inst)); + if (op->instr != imm) { + print_immval_addr(info, immfound, immval, inst, + op->inst_offset_type == INST_PC_OFFSET + ? memaddr : 0); + } + break; + case INST_TYPE_RD_R2: + fprintf_func(stream, "\t%s, %s", + get_field_rd(inst), get_field_r2(inst)); + break; + case INST_TYPE_R2: + fprintf_func(stream, "\t%s", + get_field_r2(inst)); + break; + case INST_TYPE_R1: + fprintf_func(stream, "\t%s", + get_field_r1(inst)); + break; + case INST_TYPE_RD_R1_SPECIAL: + fprintf_func(stream, "\t%s, %s", + get_field_rd(inst), get_field_r2(inst)); + break; + case INST_TYPE_RD_IMM15: + fprintf_func(stream, "\t%s, %s", + get_field_rd(inst), get_field_imm15(inst)); + break; + /* For tuqula instruction */ + case INST_TYPE_RD: + fprintf_func(stream, "\t%s", + get_field_rd(inst)); + break; + case INST_TYPE_RFSL: + fprintf_func(stream, "\t%s", + get_field_rfsl(inst)); + break; + default: + /* if the disassembler lags the instruction set */ + fprintf_func(stream, "\tundecoded operands, inst is 0x%04lx", inst); + break; } - - /* Say how many bytes we consumed? */ - return 4; + return 4; } From patchwork Fri Apr 12 07:33:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 788276 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp591497wrm; Fri, 12 Apr 2024 00:38:03 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXwV6pkcWUX5/0qvkG9vEkb2j+xgJFHhSL4ZVWYJzsAp+eUYtGFsI+t5b4D+InE0FrJAf/7pPWHVSg6to2RAefd X-Google-Smtp-Source: AGHT+IFj30AlDQALO535mQb9ueeRG7ez2eF+gv/MLzBRAZSDm0rgmo3ip6xRVLHsz+fnhLh7qyG7 X-Received: by 2002:a05:6102:3f51:b0:476:9ac0:e8c4 with SMTP id l17-20020a0561023f5100b004769ac0e8c4mr2027832vsv.34.1712907483528; Fri, 12 Apr 2024 00:38:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712907483; cv=none; d=google.com; s=arc-20160816; b=AEq3gWoiBkXMDRy9hZereq3rokIP3o3KzQrOaDoq/zM3QcLnZVlWzFPzmKkZJMpxyn 9KJOdNmGpN7OHFOikv95R6AYWkg06FZkjN8qkbxwdPNZT2uWNF1ikryd6/6basAbkUN9 r5C7vlh7ruod+iHVg+xw62M3Tmh1csrGbqEdHi55dyeAddTUt8L7KigirDSo45/C2fu3 jwEtGUO1CYw6CtkJu2mY7g67TCUBmpngL/Vg1tGwUneFNPT35gOQYLMWWv1O6SW9rRZK PFT3AFASvEoK46sTLY9p0s80GRp0yiikvbeSTos15XGwTDZuw5CBvWlQSQAuZ0RMgvnk Ej0w== 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:to:from :dkim-signature; bh=eklEK2wKipko2sVrTrkRStnjaxK8ouvGtZK4O7yNiB8=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=GD31LkC3V2kBAmfBmcsTu2M3rTl/eJQZDOfQMvrF5mEPeBjq1tp5sdyrks2tCgC+43 t1aOn8y3HP3+zE0IPnEvZMuxdObOnfZGrOtVC8YYVSd3QtXPUTQV6a0XfNQxfqlPNHGq aPm3sMZ2V2bwXR0UCRv6evEViuIOHPnF2Dgqj3VLm2dY2Eok+n4SsAYd8HpxDBt8v4th vdLnAw2iX9hPQiJza7sEUBmrI+dY9ntSAqC4a+eoplfH27uqAcFpvUZIdvQfmfMk3xbQ PtEUk9FcSe9T0wWvmQLjAsUXZHdQQhuoj8Y58HV+sQxIzY6rL+rWUg1z2bavqlMQF3/b AQlg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=z7SOZbES; 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 c16-20020ac87dd0000000b0043699f4c053si292209qte.4.2024.04.12.00.38.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 12 Apr 2024 00:38:03 -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=z7SOZbES; 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 1rvBQI-00074G-3a; Fri, 12 Apr 2024 03:34:10 -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 1rvBQF-00073N-MF for qemu-devel@nongnu.org; Fri, 12 Apr 2024 03:34:07 -0400 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rvBQA-0007CC-55 for qemu-devel@nongnu.org; Fri, 12 Apr 2024 03:34:06 -0400 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1e3f17c64daso5127205ad.3 for ; Fri, 12 Apr 2024 00:34:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712907240; x=1713512040; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=eklEK2wKipko2sVrTrkRStnjaxK8ouvGtZK4O7yNiB8=; b=z7SOZbESsgy6Oh1B6l6CTV/J+ZkpqBYBQ0l8DyLCVz8LWPrR1twOeLuxkmNhpVoVd1 ATx90Y8MkmqyZJkNxbYCiYoSvLW4sB3mhdLq511GdD2VX6sxqvGdZmIJ95voIBtRkVIX q2v44sC8BHE9hcM3FTOU9vkdauVzAywdEZlI75KpMz5qYdEf41yl0o0XS6MoOsP2B4r5 EjkydIFNXXy8DihOjzCWE8aZiTYPNnTI2+hwm3GLKRS85LSqC3bGmerxU/CV6HvaMqfH 4ch+tuIO1uoe+0M9nsGnTmfokQiUJFRoJ3GTnMIYTQGiPWnyeaHdTQoieTaKJt9tGst0 i4eQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712907240; x=1713512040; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eklEK2wKipko2sVrTrkRStnjaxK8ouvGtZK4O7yNiB8=; b=mz0CSWysTo4T7Z31NZGx8ghb8TvC/qbCDJALdSGsyhpVQuox8iW41Ns1mPUZgmSQgW qCTBZgBeQBNYsSQMpAYY5j/MLkVhlktwfox7AuSM12M1+s07yLApirZcAnAwrL46Ek62 oOq3Zd9jwWtJoZq0v35OcnKftd82MnPFkJZzdHI+OOOda/M2AoESgAXQWzbvyCffpNTD 61lhDKhEgSWynUPnOveRga/dPxpYVeH+AhJFbIq1WuckPTob+b2zX+neM2u2r0LZtwH5 eGSJgV2M8VBzRu49T59PDvjfgDfS23nDzpHLyK7/lD0i8S8PFyhSEaeIKGH5MHBuWgju 7SEg== X-Gm-Message-State: AOJu0Yz/O9Zf/RaIxmtVgyqRUPgdkyWOTXzP1w6foEBonIdBG6YN/ln/ XbNFkke7tp86xZo9Wua83fJcmL+BWwDi/ztoGE8eGV1Q7hpPaz+LgK9wq8XYLj575z3GUP2bwou M X-Received: by 2002:a17:903:2442:b0:1e0:bddf:7ed0 with SMTP id l2-20020a170903244200b001e0bddf7ed0mr1741815pls.27.1712907240555; Fri, 12 Apr 2024 00:34:00 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id e5-20020a17090301c500b001e556734814sm2206099plh.134.2024.04.12.00.34.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 00:34:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 16/27] disas/microblaze: Merge op->name output into each fprintf Date: Fri, 12 Apr 2024 00:33:35 -0700 Message-Id: <20240412073346.458116-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240412073346.458116-1-richard.henderson@linaro.org> References: <20240412073346.458116-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62f.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 In the common case, issue one single fprintf. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- disas/microblaze.c | 80 +++++++++++++++++++++++----------------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/disas/microblaze.c b/disas/microblaze.c index c729c76585..a537ac65dd 100644 --- a/disas/microblaze.c +++ b/disas/microblaze.c @@ -830,54 +830,52 @@ print_insn_microblaze(bfd_vma memaddr, struct disassemble_info *info) return 4; } - fprintf_func (stream, "%s", op->name); - switch (op->inst_type) { case INST_TYPE_RD_R1_R2: - fprintf_func(stream, "\t%s, %s, %s", - get_field_rd(inst), get_field_r1(inst), + fprintf_func(stream, "%s\t%s, %s, %s", + op->name, get_field_rd(inst), get_field_r1(inst), get_field_r2(inst)); break; case INST_TYPE_RD_R1_IMM: - fprintf_func(stream, "\t%s, %s, %s", - get_field_rd(inst), get_field_r1(inst), + fprintf_func(stream, "%s\t%s, %s, %s", + op->name, get_field_rd(inst), get_field_r1(inst), get_field_imm(inst)); if (get_int_field_r1(inst) == 0) { print_immval_addr(info, immfound, immval, inst, 0); } break; case INST_TYPE_RD_R1_IMM5: - fprintf_func(stream, "\t%s, %s, %s", - get_field_rd(inst), get_field_r1(inst), + fprintf_func(stream, "%s\t%s, %s, %s", + op->name, get_field_rd(inst), get_field_r1(inst), get_field_imm5(inst)); break; case INST_TYPE_RD_RFSL: - fprintf_func(stream, "\t%s, %s", - get_field_rd(inst), get_field_rfsl(inst)); + fprintf_func(stream, "%s\t%s, %s", + op->name, get_field_rd(inst), get_field_rfsl(inst)); break; case INST_TYPE_R1_RFSL: - fprintf_func(stream, "\t%s, %s", - get_field_r1(inst), get_field_rfsl(inst)); + fprintf_func(stream, "%s\t%s, %s", + op->name, get_field_r1(inst), get_field_rfsl(inst)); break; case INST_TYPE_RD_SPECIAL: - fprintf_func(stream, "\t%s, %s", - get_field_rd(inst), get_field_special(inst, op)); + fprintf_func(stream, "%s\t%s, %s", + op->name, get_field_rd(inst), get_field_special(inst, op)); break; case INST_TYPE_SPECIAL_R1: - fprintf_func(stream, "\t%s, %s", - get_field_special(inst, op), get_field_r1(inst)); + fprintf_func(stream, "%s\t%s, %s", + op->name, get_field_special(inst, op), get_field_r1(inst)); break; case INST_TYPE_RD_R1: - fprintf_func(stream, "\t%s, %s", - get_field_rd(inst), get_field_r1(inst)); + fprintf_func(stream, "%s\t%s, %s", + op->name, get_field_rd(inst), get_field_r1(inst)); break; case INST_TYPE_R1_R2: - fprintf_func(stream, "\t%s, %s", - get_field_r1(inst), get_field_r2(inst)); + fprintf_func(stream, "%s\t%s, %s", + op->name, get_field_r1(inst), get_field_r2(inst)); break; case INST_TYPE_R1_IMM: - fprintf_func(stream, "\t%s, %s", - get_field_r1(inst), get_field_imm(inst)); + fprintf_func(stream, "%s\t%s, %s", + op->name, get_field_r1(inst), get_field_imm(inst)); /* * The non-pc relative instructions are returns, * which shouldn't have a label printed. @@ -887,14 +885,15 @@ print_insn_microblaze(bfd_vma memaddr, struct disassemble_info *info) } break; case INST_TYPE_RD_IMM: - fprintf_func(stream, "\t%s, %s", - get_field_rd(inst), get_field_imm(inst)); + fprintf_func(stream, "%s\t%s, %s", + op->name, get_field_rd(inst), get_field_imm(inst)); print_immval_addr(info, immfound, immval, inst, op->inst_offset_type == INST_PC_OFFSET ? memaddr : 0); break; case INST_TYPE_IMM: - fprintf_func(stream, "\t%s", get_field_imm(inst)); + fprintf_func(stream, "%s\t%s", + op->name, get_field_imm(inst)); if (op->instr != imm) { print_immval_addr(info, immfound, immval, inst, op->inst_offset_type == INST_PC_OFFSET @@ -902,37 +901,38 @@ print_insn_microblaze(bfd_vma memaddr, struct disassemble_info *info) } break; case INST_TYPE_RD_R2: - fprintf_func(stream, "\t%s, %s", - get_field_rd(inst), get_field_r2(inst)); + fprintf_func(stream, "%s\t%s, %s", + op->name, get_field_rd(inst), get_field_r2(inst)); break; case INST_TYPE_R2: - fprintf_func(stream, "\t%s", - get_field_r2(inst)); + fprintf_func(stream, "%s\t%s", + op->name, get_field_r2(inst)); break; case INST_TYPE_R1: - fprintf_func(stream, "\t%s", - get_field_r1(inst)); + fprintf_func(stream, "%s\t%s", + op->name, get_field_r1(inst)); break; case INST_TYPE_RD_R1_SPECIAL: - fprintf_func(stream, "\t%s, %s", - get_field_rd(inst), get_field_r2(inst)); + fprintf_func(stream, "%s\t%s, %s", + op->name, get_field_rd(inst), get_field_r2(inst)); break; case INST_TYPE_RD_IMM15: - fprintf_func(stream, "\t%s, %s", - get_field_rd(inst), get_field_imm15(inst)); + fprintf_func(stream, "%s\t%s, %s", + op->name, get_field_rd(inst), get_field_imm15(inst)); break; /* For tuqula instruction */ case INST_TYPE_RD: - fprintf_func(stream, "\t%s", - get_field_rd(inst)); + fprintf_func(stream, "%s\t%s", + op->name, get_field_rd(inst)); break; case INST_TYPE_RFSL: - fprintf_func(stream, "\t%s", - get_field_rfsl(inst)); + fprintf_func(stream, "%s\t%s", + op->name, get_field_rfsl(inst)); break; default: /* if the disassembler lags the instruction set */ - fprintf_func(stream, "\tundecoded operands, inst is 0x%04lx", inst); + fprintf_func(stream, "%s\tundecoded operands, inst is 0x%04lx", + op->name, inst); break; } return 4; From patchwork Fri Apr 12 07:33:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 788255 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp590890wrm; Fri, 12 Apr 2024 00:35:49 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU008YByWGeFmczWtaL6pOFCo/YYsR/PT8fHaLeQtciAKd9A3/db2GsicZBhiOcoxjkui/5BGREccBx/MwmUE8/ X-Google-Smtp-Source: AGHT+IGERTrEk2nKARCy2vk0egDFWTxEnkifUNk/3Sb4Rt+tYuC118LYn7AJJSql6Mz/FRg7JYy2 X-Received: by 2002:a05:620a:2443:b0:78e:bb89:4831 with SMTP id h3-20020a05620a244300b0078ebb894831mr2597937qkn.8.1712907349688; Fri, 12 Apr 2024 00:35:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712907349; cv=none; d=google.com; s=arc-20160816; b=z9tDxBKqYbnsLowUGwhPekHXCdMCFMKX/gxiJrxVW+ybFQ74Sby4ZeChQ0KMESz1Ng 0TyfwwEC/o3sbz9auojc6tF+ZyaFYkCI7w1qzV3K27vQgCaD4J1jJivK58qIDbb8YBs0 hShmzv9QsUdfH05fNWd/0DIe5eKQO1F+76HBdRzms/53aZ+nBA8DtGZzWRVeDP3eTLu3 LPNleVvd849mKou4QEuxPy0kPTIfAsp5SyFkI/Bf9RW2ipDsy2BGWDjeo7gxUxGXCAEh ROJ07Evc8nReg/vaSRMd42fvjTR1dAwuz3u1jAaGGCHG1Ah4MXpATo0QOzwmVamSwgpc eJsw== 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:to:from :dkim-signature; bh=Pu90wwD72TTj1mq3bNLzC0zO16JxlBLO+eSavapzOrI=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=Q/uJsBZbhLw4/niGxd4LPsiV5sVZH5LIiO/Ul0Sd9it1j4TJzOJDGPuTRi5TzjGdEQ SFrXh00TAkHha0vpAzhM6BTveXZxWIj32l1DnAkKp40WhxMkCjL2Tm/Iux9eOzmkHljo NW5IEIw1tfUZCOGFZ7skeENIcZbLkxDGM6ygIGsRTePnBEPBiiC7oL2KwFCbMmF0nbnF Xk6W98mSqQqfvnfXYjAFwLiRotfsyVn86MivdAOqY1IPb143SYVsNj4LhLSf8omzdY8o OyReQITk+3XRBfGDHf6oH4XBonNCC5hvhVc0cAFAsTYni4fzvnm9dxMqwIVT68oXA7Q1 wqxg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=W5raVVAF; 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 p16-20020a05620a22f000b0078d5a02973asi3036426qki.516.2024.04.12.00.35.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 12 Apr 2024 00:35: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=W5raVVAF; 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 1rvBQN-00075u-4V; Fri, 12 Apr 2024 03:34:15 -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 1rvBQJ-00074g-E3 for qemu-devel@nongnu.org; Fri, 12 Apr 2024 03:34:11 -0400 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rvBQB-0007CG-Ng for qemu-devel@nongnu.org; Fri, 12 Apr 2024 03:34:08 -0400 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1e2b1cd446fso5267825ad.3 for ; Fri, 12 Apr 2024 00:34:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712907241; x=1713512041; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=Pu90wwD72TTj1mq3bNLzC0zO16JxlBLO+eSavapzOrI=; b=W5raVVAFG3uH/G6LN6F8cS0MOTDvyauQI2tujfTRv6zjTjiAx2LdWdLjVa1I+v8wV0 film3L0YrhNq42+mwu7s/ddP+teljBQLWDZYP/IXu/2ir0T6UNpNbu9IxMyhBMPxpo1O 0GZ7fSIaHWCMByLowsqYzXwwBgcDnbWE7yXorcIckdiHwPI04UvCh2bhsvphbDbWUEBf TwZHZu63hwQfIlAizKK9svaCLjhgT3ODhkEo+E28bZn0qbsKWNpMdejC/TQk0/qdXqwi BB3oU+XArzClJayeFMZ8/kQl8PUQQb4H5ja49QOodQjTO+QAUwu+F+9Pbk/PNa7E8C3B wcgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712907241; x=1713512041; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Pu90wwD72TTj1mq3bNLzC0zO16JxlBLO+eSavapzOrI=; b=FHsfcRuQQRI16qX517Vtaeq4zl2IocOwNkz1rq5zfclWDZONK80hg9WgqkohfhlZHn 6viBrN5yNrb95oSIx/cVGtFYMjnwTGC1s+Q6DU3gL2o5ENu2c3983deraeBLPoTxDMss i0M6ymjedSMBfRaqU4BUq3fE/nVOvCwg4+4oHs31wiasX/BpquZZlRUBDg7sJbf22lIK J4LotCm4iPEIBNBSFNk3vsq6Ww0hR27q5a1NBjsEOo1Q4kbn37wjhoHfCYjfgGXPskeR 0VnD5SAV4qg5NQnh0oMah8MkAJR6YT8ScygIpyrt8grB3PlKT8WvUbUa8xewT34UNgk/ K5vQ== X-Gm-Message-State: AOJu0YwY9Kddw25g44O5vyQS5JKEWay1XdDLUvW9+AzBPPk2aOR0SBHo 9c36KusivELnIbveyNUDxdhATOr0kNjOBSR+KtLlMMSd1TeDp5wFylhY09gpqXW9QideZ+vD/Zm s X-Received: by 2002:a17:902:d481:b0:1e3:cfc5:589c with SMTP id c1-20020a170902d48100b001e3cfc5589cmr1958541plg.28.1712907241263; Fri, 12 Apr 2024 00:34:01 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id e5-20020a17090301c500b001e556734814sm2206099plh.134.2024.04.12.00.34.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 00:34:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 17/27] disas/microblaze: Print registers directly with PRIreg Date: Fri, 12 Apr 2024 00:33:36 -0700 Message-Id: <20240412073346.458116-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240412073346.458116-1-richard.henderson@linaro.org> References: <20240412073346.458116-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62e.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=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 Use a printf format instead of sprintf into a buffer. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- disas/microblaze.c | 54 ++++++++++++++++++++-------------------------- 1 file changed, 23 insertions(+), 31 deletions(-) diff --git a/disas/microblaze.c b/disas/microblaze.c index a537ac65dd..c12968f3b9 100644 --- a/disas/microblaze.c +++ b/disas/microblaze.c @@ -563,7 +563,7 @@ static const struct op_code_struct { }; /* prefix for register names */ -static const char register_prefix[] = "r"; +#define register_prefix "r" static const char fsl_register_prefix[] = "rfsl"; static const char pvr_register_prefix[] = "rpvr"; @@ -579,15 +579,16 @@ static const char pvr_register_prefix[] = "rpvr"; #include "disas/dis-asm.h" -#define get_field_rd(instr) get_field(instr, RD_MASK, RD_LOW) -#define get_field_r1(instr) get_field(instr, RA_MASK, RA_LOW) -#define get_field_r2(instr) get_field(instr, RB_MASK, RB_LOW) +#define PRIreg register_prefix "%ld" + +#define get_field_rd(instr) ((instr & RD_MASK) >> RD_LOW) +#define get_field_r1(instr) ((instr & RA_MASK) >> RA_LOW) +#define get_field_r2(instr) ((instr & RB_MASK) >> RB_LOW) #define get_int_field_imm(instr) ((instr & IMM_MASK) >> IMM_LOW) #define get_int_field_r1(instr) ((instr & RA_MASK) >> RA_LOW) /* Local function prototypes. */ -static char * get_field (long instr, long mask, unsigned short low); static char * get_field_imm (long instr); static char * get_field_imm5 (long instr); static char * get_field_rfsl (long instr); @@ -596,15 +597,6 @@ static char * get_field_imm15 (long instr); static char * get_field_unsigned_imm (long instr); #endif -static char * -get_field (long instr, long mask, unsigned short low) -{ - char tmpstr[25]; - snprintf(tmpstr, sizeof(tmpstr), "%s%d", register_prefix, - (int)((instr & mask) >> low)); - return(strdup(tmpstr)); -} - static char * get_field_imm (long instr) { @@ -832,12 +824,12 @@ print_insn_microblaze(bfd_vma memaddr, struct disassemble_info *info) switch (op->inst_type) { case INST_TYPE_RD_R1_R2: - fprintf_func(stream, "%s\t%s, %s, %s", + fprintf_func(stream, "%s\t" PRIreg ", " PRIreg ", " PRIreg, op->name, get_field_rd(inst), get_field_r1(inst), get_field_r2(inst)); break; case INST_TYPE_RD_R1_IMM: - fprintf_func(stream, "%s\t%s, %s, %s", + fprintf_func(stream, "%s\t" PRIreg ", " PRIreg ", %s", op->name, get_field_rd(inst), get_field_r1(inst), get_field_imm(inst)); if (get_int_field_r1(inst) == 0) { @@ -845,36 +837,36 @@ print_insn_microblaze(bfd_vma memaddr, struct disassemble_info *info) } break; case INST_TYPE_RD_R1_IMM5: - fprintf_func(stream, "%s\t%s, %s, %s", + fprintf_func(stream, "%s\t" PRIreg ", " PRIreg ", %s", op->name, get_field_rd(inst), get_field_r1(inst), get_field_imm5(inst)); break; case INST_TYPE_RD_RFSL: - fprintf_func(stream, "%s\t%s, %s", + fprintf_func(stream, "%s\t" PRIreg ", %s", op->name, get_field_rd(inst), get_field_rfsl(inst)); break; case INST_TYPE_R1_RFSL: - fprintf_func(stream, "%s\t%s, %s", + fprintf_func(stream, "%s\t" PRIreg ", %s", op->name, get_field_r1(inst), get_field_rfsl(inst)); break; case INST_TYPE_RD_SPECIAL: - fprintf_func(stream, "%s\t%s, %s", + fprintf_func(stream, "%s\t" PRIreg ", %s", op->name, get_field_rd(inst), get_field_special(inst, op)); break; case INST_TYPE_SPECIAL_R1: - fprintf_func(stream, "%s\t%s, %s", + fprintf_func(stream, "%s\t%s, " PRIreg, op->name, get_field_special(inst, op), get_field_r1(inst)); break; case INST_TYPE_RD_R1: - fprintf_func(stream, "%s\t%s, %s", + fprintf_func(stream, "%s\t" PRIreg ", " PRIreg, op->name, get_field_rd(inst), get_field_r1(inst)); break; case INST_TYPE_R1_R2: - fprintf_func(stream, "%s\t%s, %s", + fprintf_func(stream, "%s\t" PRIreg ", " PRIreg, op->name, get_field_r1(inst), get_field_r2(inst)); break; case INST_TYPE_R1_IMM: - fprintf_func(stream, "%s\t%s, %s", + fprintf_func(stream, "%s\t" PRIreg ", %s", op->name, get_field_r1(inst), get_field_imm(inst)); /* * The non-pc relative instructions are returns, @@ -885,7 +877,7 @@ print_insn_microblaze(bfd_vma memaddr, struct disassemble_info *info) } break; case INST_TYPE_RD_IMM: - fprintf_func(stream, "%s\t%s, %s", + fprintf_func(stream, "%s\t" PRIreg ", %s", op->name, get_field_rd(inst), get_field_imm(inst)); print_immval_addr(info, immfound, immval, inst, op->inst_offset_type == INST_PC_OFFSET @@ -901,28 +893,28 @@ print_insn_microblaze(bfd_vma memaddr, struct disassemble_info *info) } break; case INST_TYPE_RD_R2: - fprintf_func(stream, "%s\t%s, %s", + fprintf_func(stream, "%s\t" PRIreg ", " PRIreg, op->name, get_field_rd(inst), get_field_r2(inst)); break; case INST_TYPE_R2: - fprintf_func(stream, "%s\t%s", + fprintf_func(stream, "%s\t" PRIreg, op->name, get_field_r2(inst)); break; case INST_TYPE_R1: - fprintf_func(stream, "%s\t%s", + fprintf_func(stream, "%s\t" PRIreg, op->name, get_field_r1(inst)); break; case INST_TYPE_RD_R1_SPECIAL: - fprintf_func(stream, "%s\t%s, %s", + fprintf_func(stream, "%s\t" PRIreg ", " PRIreg, op->name, get_field_rd(inst), get_field_r2(inst)); break; case INST_TYPE_RD_IMM15: - fprintf_func(stream, "%s\t%s, %s", + fprintf_func(stream, "%s\t" PRIreg ", %s", op->name, get_field_rd(inst), get_field_imm15(inst)); break; /* For tuqula instruction */ case INST_TYPE_RD: - fprintf_func(stream, "%s\t%s", + fprintf_func(stream, "%s\t" PRIreg, op->name, get_field_rd(inst)); break; case INST_TYPE_RFSL: From patchwork Fri Apr 12 07:33:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 788271 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp591429wrm; Fri, 12 Apr 2024 00:37:46 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWnaIRqgsFSf0oyniGLhWI9QOryr0o0JYtWX9oBF/7ZbvVNvLl99WlwKsibhYUb6QrmWpzA5uFea85rGm+LkZak X-Google-Smtp-Source: AGHT+IHqN5XrPbKHc5ZenZdb8DFfc2woiCf91OSPROhm92Lco9fav2aYo8xkgiMX2eRQ1hJIqdCE X-Received: by 2002:a05:6214:410e:b0:69b:2675:e466 with SMTP id kc14-20020a056214410e00b0069b2675e466mr2284230qvb.29.1712907465917; Fri, 12 Apr 2024 00:37:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712907465; cv=none; d=google.com; s=arc-20160816; b=KVu5s9k84l/Bu+gdy/PuKW4sWyHrA7hC+Pe2JE+veKKNORvYAOBDix4BLErTxTU+/U 1wkieddX6peDW14Nc90JeyutGaNAqAxKrqfYBKJvkDXjHD55Pu9vEa9EPwBwVsjX3FcU 8Lgvap2Uuili+zkPxU/eS9eQTAG/dxVHIpXobmiQuulBhnqoKYoc7cUSlKXvEBPITtL6 +D6WZD73EHNXunQvIcCHFHaz7iArRLQB06h9j2JA2W55lwcciEmYs5s9YM0ue+fkMh1W Bk0Bz4XmzfIvQEL9rxM/+vdyLzp+0GweEOiT9R8JmUVuSSgAv5zrkvoA5wX45Xjy46yx lhjw== 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:to:from :dkim-signature; bh=P54+4fCIsAAc0bVMNSYixg4SDN1lDlZ7gzm2KMiAs9s=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=yXVavjR6A32GKdFMUN8JVpCPMc8TT8SRlo+FXAmdcfW2r9WQl+2i4xuUwEKrff/1OP mVNzyXEr1mhdWDTMueteiTsUB0H2kSDPPHpxewj+SNRS2Uhnm2gFT3BN9kXv0en45orw BKu34C1abLJm6fhYkTxg3ir1R5AaS2cXm6N0lB7hZ+qXpuuJUfvAH9d/XIkIJZ0PONRE MLtuZAq+MvjtYFFsiC9UHlHk5fN+JEfL4x7hPfib7vOv+M5Keb1etbKXQEzWhOrGlBHu 4IOGvxKIM6gEK8Yz44koHdc3FT2eDtUlQd/03aeiUmyOm/R3jpbvQBtCvLWbeQyEMn9Z TFxg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tpTyIsUA; 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 dk5-20020a056214092500b0069b16ced7b0si3074640qvb.233.2024.04.12.00.37.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 12 Apr 2024 00:37:45 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tpTyIsUA; 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 1rvBQN-00076E-TS; Fri, 12 Apr 2024 03:34:15 -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 1rvBQJ-00074f-DW for qemu-devel@nongnu.org; Fri, 12 Apr 2024 03:34:11 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0: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 1rvBQB-0007CW-OL for qemu-devel@nongnu.org; Fri, 12 Apr 2024 03:34:08 -0400 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1e2bbc2048eso5649145ad.3 for ; Fri, 12 Apr 2024 00:34:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712907242; x=1713512042; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=P54+4fCIsAAc0bVMNSYixg4SDN1lDlZ7gzm2KMiAs9s=; b=tpTyIsUAm7ryE46ydOJ/Xkhlq+UQK7abWiVVTN4ACh6QckrdoU7LinmRUvs3KQ55hX AU3G37Sd1pi7CCrXnzoRFOimA7fFLOK9VmfuWzzUHdhY827SF0lb8ZlICVUrmfcPMFEH HeANxQxhI7EUDBNBPtLek0qzeRQdAcoZU0TRSB+EjI2P2/RNd1J9efiX74+B6TA090r0 P3XhgLyGx8g2RpKRXThMHwUxRH6flC+2CpzE87xKvmftviZI713yd6QTTAhL02z7I43N o6lEZGwTLWl2I6OcKjg9Z5TGuJj5oStDdNdjDwNNh4mYnvCVdWq3BtJMVHGU4n//T0mE 6vkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712907242; x=1713512042; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=P54+4fCIsAAc0bVMNSYixg4SDN1lDlZ7gzm2KMiAs9s=; b=aEiat/dY6DIswfjwmSHdTtPc3hlrwHwiOT1kDHp+q019rPXNU5iGZZ2e2WqEh+W8+2 yczGY0X89Dlzv4wyO28ClwkdDwKjXBcpW3XwfqiMkawU4okBBLQI1Y0rLdvdzkBQq97Y zEWCv3bAW2sWfgrUWYS6XzsjoGGJ6eE9gIq5ENqak400HVXhOH+IWwDbGt6ehkVaG2W/ fmj1V0AYWZBcCTey3rfrp/EvuVNo+fUwxbKm6+E8fkfZlxgsw8GxSFX4Wc5n5U+uM5a/ PTtIUgKAvelPRLdSOCVY1wVTg77PkHnmJ8HRrp4rp/lL1sO9OfVBR0UeUjcr1MuPYDs9 tXbg== X-Gm-Message-State: AOJu0YwoDtuF0khjGYoA/tjlVjjSYWR3IY+NalVbhuJtxZJlOEheMZTG qXrLNTOLPmlfMzMQx40GYWOdDjmRtdadOIu2McvxSc33sUY+9v44hmYQp6+K0WlMqYn30VyPMho Y X-Received: by 2002:a17:903:228e:b0:1e3:c9f6:c4b with SMTP id b14-20020a170903228e00b001e3c9f60c4bmr2135075plh.10.1712907242144; Fri, 12 Apr 2024 00:34:02 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id e5-20020a17090301c500b001e556734814sm2206099plh.134.2024.04.12.00.34.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 00:34:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 18/27] disas/microblaze: Print immediates directly with PRIimm Date: Fri, 12 Apr 2024 00:33:37 -0700 Message-Id: <20240412073346.458116-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240412073346.458116-1-richard.henderson@linaro.org> References: <20240412073346.458116-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-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=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 Use a printf format instead of sprintf into a buffer. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- disas/microblaze.c | 61 +++++++++------------------------------------- 1 file changed, 11 insertions(+), 50 deletions(-) diff --git a/disas/microblaze.c b/disas/microblaze.c index c12968f3b9..390f98c0a3 100644 --- a/disas/microblaze.c +++ b/disas/microblaze.c @@ -580,40 +580,21 @@ static const char pvr_register_prefix[] = "rpvr"; #include "disas/dis-asm.h" #define PRIreg register_prefix "%ld" +#define PRIimm "%d" #define get_field_rd(instr) ((instr & RD_MASK) >> RD_LOW) #define get_field_r1(instr) ((instr & RA_MASK) >> RA_LOW) #define get_field_r2(instr) ((instr & RB_MASK) >> RB_LOW) +#define get_field_imm(instr) ((int16_t)instr) +#define get_field_imm5(instr) ((int)instr & IMM5_MASK) +#define get_field_imm15(instr) ((int)instr & IMM15_MASK) + #define get_int_field_imm(instr) ((instr & IMM_MASK) >> IMM_LOW) #define get_int_field_r1(instr) ((instr & RA_MASK) >> RA_LOW) /* Local function prototypes. */ -static char * get_field_imm (long instr); -static char * get_field_imm5 (long instr); static char * get_field_rfsl (long instr); -static char * get_field_imm15 (long instr); -#if 0 -static char * get_field_unsigned_imm (long instr); -#endif - -static char * -get_field_imm (long instr) -{ - char tmpstr[25]; - snprintf(tmpstr, sizeof(tmpstr), "%d", - (short)((instr & IMM_MASK) >> IMM_LOW)); - return(strdup(tmpstr)); -} - -static char * -get_field_imm5 (long instr) -{ - char tmpstr[25]; - snprintf(tmpstr, sizeof(tmpstr), "%d", - (short)((instr & IMM5_MASK) >> IMM_LOW)); - return(strdup(tmpstr)); -} static char * get_field_rfsl (long instr) @@ -624,26 +605,6 @@ get_field_rfsl (long instr) return(strdup(tmpstr)); } -static char * -get_field_imm15 (long instr) -{ - char tmpstr[25]; - snprintf(tmpstr, sizeof(tmpstr), "%d", - (short)((instr & IMM15_MASK) >> IMM_LOW)); - return(strdup(tmpstr)); -} - -#if 0 -static char * -get_field_unsigned_imm (long instr) -{ - char tmpstr[25]; - snprintf(tmpstr, sizeof(tmpstr), "%d", - (int)((instr & IMM_MASK) >> IMM_LOW)); - return(strdup(tmpstr)); -} -#endif - /* char * get_field_special (instr) @@ -829,7 +790,7 @@ print_insn_microblaze(bfd_vma memaddr, struct disassemble_info *info) get_field_r2(inst)); break; case INST_TYPE_RD_R1_IMM: - fprintf_func(stream, "%s\t" PRIreg ", " PRIreg ", %s", + fprintf_func(stream, "%s\t" PRIreg ", " PRIreg ", " PRIimm, op->name, get_field_rd(inst), get_field_r1(inst), get_field_imm(inst)); if (get_int_field_r1(inst) == 0) { @@ -837,7 +798,7 @@ print_insn_microblaze(bfd_vma memaddr, struct disassemble_info *info) } break; case INST_TYPE_RD_R1_IMM5: - fprintf_func(stream, "%s\t" PRIreg ", " PRIreg ", %s", + fprintf_func(stream, "%s\t" PRIreg ", " PRIreg ", " PRIimm, op->name, get_field_rd(inst), get_field_r1(inst), get_field_imm5(inst)); break; @@ -866,7 +827,7 @@ print_insn_microblaze(bfd_vma memaddr, struct disassemble_info *info) op->name, get_field_r1(inst), get_field_r2(inst)); break; case INST_TYPE_R1_IMM: - fprintf_func(stream, "%s\t" PRIreg ", %s", + fprintf_func(stream, "%s\t" PRIreg ", " PRIimm, op->name, get_field_r1(inst), get_field_imm(inst)); /* * The non-pc relative instructions are returns, @@ -877,14 +838,14 @@ print_insn_microblaze(bfd_vma memaddr, struct disassemble_info *info) } break; case INST_TYPE_RD_IMM: - fprintf_func(stream, "%s\t" PRIreg ", %s", + fprintf_func(stream, "%s\t" PRIreg ", " PRIimm, op->name, get_field_rd(inst), get_field_imm(inst)); print_immval_addr(info, immfound, immval, inst, op->inst_offset_type == INST_PC_OFFSET ? memaddr : 0); break; case INST_TYPE_IMM: - fprintf_func(stream, "%s\t%s", + fprintf_func(stream, "%s\t" PRIimm, op->name, get_field_imm(inst)); if (op->instr != imm) { print_immval_addr(info, immfound, immval, inst, @@ -909,7 +870,7 @@ print_insn_microblaze(bfd_vma memaddr, struct disassemble_info *info) op->name, get_field_rd(inst), get_field_r2(inst)); break; case INST_TYPE_RD_IMM15: - fprintf_func(stream, "%s\t" PRIreg ", %s", + fprintf_func(stream, "%s\t" PRIreg ", " PRIimm, op->name, get_field_rd(inst), get_field_imm15(inst)); break; /* For tuqula instruction */ From patchwork Fri Apr 12 07:33:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 788275 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp591473wrm; Fri, 12 Apr 2024 00:37:55 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV5BV6qB8tU1i/qkPMOOZZAkPB8jiJCdQe8kfBZktHC1HKE7Fprbp2qgAPpYNmpwwMsaht4iQ5gXIyHt7EwRl/Q X-Google-Smtp-Source: AGHT+IE0Vq0ojR9p/j94bHkF/I3cGFoYbn0dI3t4RBNp2w4eS2tMg+wlsCVi+2Rx5fcSunYMvmwe X-Received: by 2002:a05:6214:508e:b0:69b:203a:f47a with SMTP id kk14-20020a056214508e00b0069b203af47amr2022194qvb.37.1712907474955; Fri, 12 Apr 2024 00:37:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712907474; cv=none; d=google.com; s=arc-20160816; b=tLesqQhYBtnHQPsMuC80ws6XmBaL8Ga/oXYZ7pUUf3VijEw2huhA/PTC9RuOw9tp5I BDDxXLWhNTqB0wwToq4LpbspE44wOddm+YFyPCcIsCCilHwsAIgVHh/dtlYyKD9rRv7I FFi1npZciET/7keotzqC7a9j6Za1haGfzJZR1H5ZQEC6XJhlJQb9OlaXrI/t10SLBWWh kdv4jrxW2rE1fIMGaQK+vMf/uzIzDSCYa0GSkj3MWMxhyQEenKLCN1w4zjqRpGgpyY8w Wr+UywIj1nuCPsqA12gWZXa18pUd/zgymy/aMQlj3t9QB0ZpaZMsvsPYYFtwrwqC/QE/ z1ng== 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:to:from :dkim-signature; bh=hxqYH9ScX+ObdWXnIbuV9Gxb9Me9BqWqhyTqw11fwnA=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=TT/nquduFrcXO8OERyfY9QMaJNnpcEQ/G5DUlk1cgktjQ9LDPt67kdKmEq1TefLP12 IGWp8LU9Ra//OmJzjrmP8WObnpM0YUK1/jjlKhzkAB7LoKa9vVFkyZ7necLf9okrspXq 9W/4w28C6HpcDckEMvI6ELtnFiuaXlpFWPVCr5ld0LMG9x+mGrvH00QTz3qnghtv0DO6 Jc4H0EN4f53ZkTG9d+rRc9XuuiseGmBqLx4SdMGGXAX4VTnUFnzS4hgzaH2guC9Wf9we o6hrhtasTvRn/VCWWC0isfl8TkZkjv8ndheAoiLHjTi5bXDuViiKfMuO3Dn6nr9vGeBW ++IQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YLihk81p; 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 t4-20020ad45bc4000000b0069b1dd3261csi3492121qvt.91.2024.04.12.00.37.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 12 Apr 2024 00:37:54 -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=YLihk81p; 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 1rvBQQ-000779-0m; Fri, 12 Apr 2024 03:34:18 -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 1rvBQJ-00074i-Du for qemu-devel@nongnu.org; Fri, 12 Apr 2024 03:34:11 -0400 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rvBQE-0007Ca-KR for qemu-devel@nongnu.org; Fri, 12 Apr 2024 03:34:08 -0400 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-6eaf1005fcaso453921b3a.3 for ; Fri, 12 Apr 2024 00:34:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712907243; x=1713512043; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=hxqYH9ScX+ObdWXnIbuV9Gxb9Me9BqWqhyTqw11fwnA=; b=YLihk81p1f8ULXc1LC+UchZQm94JPAgc/rpzZlnVbZtOBpyvxt0CwMJ7yI02ycPW+O LCtxUvdS34kEJUPjzx58Usnje/qM1ERTnW0mWJasTZADnSVl7YNI1oYF1DZuIwMFCwWS ut8uCET6yysqMLyL4+NJuiMykOh1qxksr5rp7hGHl49ArS6P9UTLouR4fIWUMsn4Uixo ktLS8oor/y3DYla3s7Ay7NpbfG0a+Xj71pmIYCO5cPzF/VuWMNYukwwyF/njyxk6k0p3 9v8s2gWwg2GUoc2z0P3lWq/HyzxcfiBQKOPemN7rtypy8Dw7Sl27DQlTVQB7GzRFO9Dj jmDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712907243; x=1713512043; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hxqYH9ScX+ObdWXnIbuV9Gxb9Me9BqWqhyTqw11fwnA=; b=fFyiTD0MZAlSWJhDXTTAfhVKehEfWhjrh5sXbVykmR2JqnlcUi7ZfWr46hLdiZpYyS kQAdkirzf6pB6zNc2CdN+v8HDVIvmr9iS9yM2bi83tqMDUGjDjoPFSKPCdlBDg64xSAw CidHmA2grudVut5gsHb9kj+PmrNcbkvEd6n1MIjT09upeqyu6C/lkJF+xCDCxkdysZmf 6DCzdfizY4aJzgYO175w9d83PfnKfTGDKtIK5pKCIx9crqVDRgKXLpeqYisKKiq4U5Ui Cg4iKr3Pj2BJEKw0mcRvlFhanP6picGBQmFsDmGizDPJs3klPMrE/4FgWFQpP7k33ee0 NSTg== X-Gm-Message-State: AOJu0YysYVs3EC7w/RF0rSJPKxbuFAHdscyZDyQsuuK/z66QB116Bl8N axHKI64tskcUqnRyaYE979augtlP6FLkCaKxvgom4eIXSJVRGNjSNNJ8p9kitlH39o6vdVeJSLq H X-Received: by 2002:a05:6a21:6d9a:b0:1a7:4867:7301 with SMTP id wl26-20020a056a216d9a00b001a748677301mr2179010pzb.5.1712907242824; Fri, 12 Apr 2024 00:34:02 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id e5-20020a17090301c500b001e556734814sm2206099plh.134.2024.04.12.00.34.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 00:34:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 19/27] disas/microblaze: Print registers directly with PRIrfsl Date: Fri, 12 Apr 2024 00:33:38 -0700 Message-Id: <20240412073346.458116-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240412073346.458116-1-richard.henderson@linaro.org> References: <20240412073346.458116-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::435; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x435.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 Use a printf format instead of sprintf into a buffer. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier Reviewed-by: Pierrick Bouvier --- disas/microblaze.c | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/disas/microblaze.c b/disas/microblaze.c index 390f98c0a3..24febfdea9 100644 --- a/disas/microblaze.c +++ b/disas/microblaze.c @@ -564,7 +564,6 @@ static const struct op_code_struct { /* prefix for register names */ #define register_prefix "r" -static const char fsl_register_prefix[] = "rfsl"; static const char pvr_register_prefix[] = "rpvr"; @@ -580,11 +579,13 @@ static const char pvr_register_prefix[] = "rpvr"; #include "disas/dis-asm.h" #define PRIreg register_prefix "%ld" +#define PRIrfsl register_prefix "fsl%ld" #define PRIimm "%d" #define get_field_rd(instr) ((instr & RD_MASK) >> RD_LOW) #define get_field_r1(instr) ((instr & RA_MASK) >> RA_LOW) #define get_field_r2(instr) ((instr & RB_MASK) >> RB_LOW) +#define get_field_rfsl(instr) (instr & RFSL_MASK) #define get_field_imm(instr) ((int16_t)instr) #define get_field_imm5(instr) ((int)instr & IMM5_MASK) #define get_field_imm15(instr) ((int)instr & IMM15_MASK) @@ -592,19 +593,6 @@ static const char pvr_register_prefix[] = "rpvr"; #define get_int_field_imm(instr) ((instr & IMM_MASK) >> IMM_LOW) #define get_int_field_r1(instr) ((instr & RA_MASK) >> RA_LOW) -/* Local function prototypes. */ - -static char * get_field_rfsl (long instr); - -static char * -get_field_rfsl (long instr) -{ - char tmpstr[25]; - snprintf(tmpstr, sizeof(tmpstr), "%s%d", fsl_register_prefix, - (short)((instr & RFSL_MASK) >> IMM_LOW)); - return(strdup(tmpstr)); -} - /* char * get_field_special (instr) @@ -803,11 +791,11 @@ print_insn_microblaze(bfd_vma memaddr, struct disassemble_info *info) get_field_imm5(inst)); break; case INST_TYPE_RD_RFSL: - fprintf_func(stream, "%s\t" PRIreg ", %s", + fprintf_func(stream, "%s\t" PRIreg ", " PRIrfsl, op->name, get_field_rd(inst), get_field_rfsl(inst)); break; case INST_TYPE_R1_RFSL: - fprintf_func(stream, "%s\t" PRIreg ", %s", + fprintf_func(stream, "%s\t" PRIreg ", " PRIrfsl, op->name, get_field_r1(inst), get_field_rfsl(inst)); break; case INST_TYPE_RD_SPECIAL: @@ -879,7 +867,7 @@ print_insn_microblaze(bfd_vma memaddr, struct disassemble_info *info) op->name, get_field_rd(inst)); break; case INST_TYPE_RFSL: - fprintf_func(stream, "%s\t%s", + fprintf_func(stream, "%s\t" PRIrfsl, op->name, get_field_rfsl(inst)); break; default: From patchwork Fri Apr 12 07:33:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 788258 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp590956wrm; Fri, 12 Apr 2024 00:36:01 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX/v033tEemVhjksMotbFDrkZCGCVF3gZc53zJyImzs3T1FV9L57JzcuYyRkj+JkUuniStCJEUQk+hSF7nRzDnx X-Google-Smtp-Source: AGHT+IFxoP/OrqCviVejPyu/n8qP3T39IyYMj9DI3cxZ4Fp6gmyQhefB+vsQPgWgNQAtSL/yUald X-Received: by 2002:a05:6808:984:b0:3c5:ee83:5205 with SMTP id a4-20020a056808098400b003c5ee835205mr1806995oic.37.1712907361387; Fri, 12 Apr 2024 00:36:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712907361; cv=none; d=google.com; s=arc-20160816; b=nFgpTX0yBvPyia3c6JeJBB1fEP7OHwn3wFKapW04lNbrkPPrLIUhV0mzcsWG/o6cCl CXBRxqncIDbA8leD3XVAu054u8owZx5fnh7mIZzI9YNqwYp2mvJ884sTguk+zJAWhz+D N5rb9+AHU/zzSH4aIrtVQWIfYsk6SRwoKml7Q2Pj5CSDESyk8HqloaBLGEstvVHpKL7I acV2cS0tx9U15P8UoTdZmocvro9cJg+gBJByEghH4BX+5AqNnXF4c7tRdQZVBKxiuVkX nIC4MDCVKmkOYXYsDVjDwHmzMx5wYHmrJV/HF/Fi59v0WyipoAtAOvM1RQE3yWA9UVvy 4QzQ== 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:to:from :dkim-signature; bh=AgGhBfcq1sGSX/QZG2Od2RrYyCzuXj5RVatE7xiS5E8=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=xh6/U2IVGLX1+is//u/KEmWxUZcbp8tvsaOA00kGaYnHsxrsC6Nw1mDc52wo0dIYJY S0vqFMo8JObJGFoHJd4IP/INOPRmeyWTPoX6ur8X+EEeyk/lkY6hnGIfy8d7Qgm0aKsB IV6kfg++A/4pH6heMA6mt+MV61oDAk2/gLrnjPxxSdsfGo2xJsGKQ9BppljFGRgAkQ/S 5tc2wiLq7DMMFWsZxmAGwgHmo63PL8ecp92CFvaZGQrArWL1sWDKIS3D59OydTqG1wZ/ S7rB0hmNUlDpReeCRZCl9xMs9CEV835vlooJjsf4DSeC6Ga3d/5DUZOeNWyepdueUfSb rXKA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gLxsOA2W; 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-20020ac85ac4000000b00434ee028f48si3164440qtd.285.2024.04.12.00.36.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 12 Apr 2024 00:36:01 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gLxsOA2W; 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 1rvBQS-00078X-QI; Fri, 12 Apr 2024 03:34:20 -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 1rvBQJ-00074h-Dz for qemu-devel@nongnu.org; Fri, 12 Apr 2024 03:34:11 -0400 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rvBQF-0007Cq-D1 for qemu-devel@nongnu.org; Fri, 12 Apr 2024 03:34:09 -0400 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1e455b630acso3259765ad.1 for ; Fri, 12 Apr 2024 00:34:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712907243; x=1713512043; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=AgGhBfcq1sGSX/QZG2Od2RrYyCzuXj5RVatE7xiS5E8=; b=gLxsOA2WwL0b9xr/Ux4/Tu3GoGnidWSQfSXUdei1Y06Ri1HwtzKfDosvL+6eNVO0lj Q9azJiPq5r4ZezMZTYX/IeX9GtX+/EGNENs8Rjh1oYDDSQdlD4u271AG+BlyrPfNcMCH U4SIHMMOs2VmYKW4zRWhRt4qjQiCxS7lNOmHefn7pTjonGNo1mFfHKxM5CjkiZQIU8v6 5/NL57Cv3/PvsMErOEd4Xmkg+CGAhZhqYIWpMLMVyD5YV2QeUmJN7MGrMyC4w+ocnNW2 rUAwQ2j5sTiuC6uY2PwQrE5jwByYI40lS1ZxCc9bZPuZu3eOGpwPzRQg+dsWO7ndD3LK Nz2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712907243; x=1713512043; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AgGhBfcq1sGSX/QZG2Od2RrYyCzuXj5RVatE7xiS5E8=; b=HGuQNV7K8/vH1j6JsB8LhE49x82e/V48y8mLLlVu+PsRPedOEL0BRiIO1pK/kUKpGd xsjpjjnbiSrjuHJIAjmdL2aiOtXquqi/gJOuL1V4UhukHJTwo+YA188lilwQjo6SAJpf Gmx3v+E6ddpDbb1KGX0JbeLA1MiZWd7rR/P4LpyAN2GThLsZZu7e1MsEJ/H1CdbegSIZ tVnU1hiScrzwdBSqYFxdaJBtq4lLNqUeA5V43iwKbuAEkavSrhQYUK1wWl/947UdpI4p 0MmZWoXb/U1kLzOVdO+EnDPOMJmSFYJzu1qOwVifzKeaXrkoLXYsJyeaEkW2nM8h6N+t W6mw== X-Gm-Message-State: AOJu0Yx9FTrxWgIb8AcztSlM5OLLJfvYP7yp7U+Dw2QZGIAHCdSad/58 egJZyOA8wAcB1UdcspdXbIjoVhcnfZyyJTIc9hAHOtbhQ14QlR3mNk08teWoWBSmRmJOexWCnUq W X-Received: by 2002:a17:902:f545:b0:1e2:6b5d:5b18 with SMTP id h5-20020a170902f54500b001e26b5d5b18mr1965285plf.51.1712907243634; Fri, 12 Apr 2024 00:34:03 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id e5-20020a17090301c500b001e556734814sm2206099plh.134.2024.04.12.00.34.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 00:34:03 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 20/27] disas/microblaze: Split get_field_special Date: Fri, 12 Apr 2024 00:33:39 -0700 Message-Id: <20240412073346.458116-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240412073346.458116-1-richard.henderson@linaro.org> References: <20240412073346.458116-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.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 Extract the raw special index and a function to lookup a name. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- disas/microblaze.c | 142 +++++++++++++++++++-------------------------- 1 file changed, 61 insertions(+), 81 deletions(-) diff --git a/disas/microblaze.c b/disas/microblaze.c index 24febfdea9..197327fae4 100644 --- a/disas/microblaze.c +++ b/disas/microblaze.c @@ -564,8 +564,6 @@ static const struct op_code_struct { /* prefix for register names */ #define register_prefix "r" -static const char pvr_register_prefix[] = "rpvr"; - /* #defines for valid immediate range */ #define MIN_IMM ((int) 0x80000000) @@ -580,6 +578,7 @@ static const char pvr_register_prefix[] = "rpvr"; #define PRIreg register_prefix "%ld" #define PRIrfsl register_prefix "fsl%ld" +#define PRIpvr register_prefix "pvr%d" #define PRIimm "%d" #define get_field_rd(instr) ((instr & RD_MASK) >> RD_LOW) @@ -593,83 +592,48 @@ static const char pvr_register_prefix[] = "rpvr"; #define get_int_field_imm(instr) ((instr & IMM_MASK) >> IMM_LOW) #define get_int_field_r1(instr) ((instr & RA_MASK) >> RA_LOW) -/* - char * - get_field_special (instr) - long instr; - { - char tmpstr[25]; - - snprintf(tmpstr, sizeof(tmpstr), "%s%s", register_prefix, - (((instr & IMM_MASK) >> IMM_LOW) & REG_MSR_MASK) == 0 ? "pc" : "msr"); - - return(strdup(tmpstr)); - } -*/ - -static char * -get_field_special(long instr, const struct op_code_struct *op) +static int get_field_special(long instr, const struct op_code_struct *op) { - char tmpstr[25]; - char spr[6]; + return ((instr & IMM_MASK) >> IMM_LOW) ^ op->immval_mask; +} - switch ( (((instr & IMM_MASK) >> IMM_LOW) ^ op->immval_mask) ) { - - case REG_MSR_MASK : - strcpy(spr, "msr"); - break; - case REG_PC_MASK : - strcpy(spr, "pc"); - break; - case REG_EAR_MASK : - strcpy(spr, "ear"); - break; - case REG_ESR_MASK : - strcpy(spr, "esr"); - break; - case REG_FSR_MASK : - strcpy(spr, "fsr"); - break; - case REG_BTR_MASK : - strcpy(spr, "btr"); - break; - case REG_EDR_MASK : - strcpy(spr, "edr"); - break; - case REG_PID_MASK : - strcpy(spr, "pid"); - break; - case REG_ZPR_MASK : - strcpy(spr, "zpr"); - break; - case REG_TLBX_MASK : - strcpy(spr, "tlbx"); - break; - case REG_TLBLO_MASK : - strcpy(spr, "tlblo"); - break; - case REG_TLBHI_MASK : - strcpy(spr, "tlbhi"); - break; - case REG_TLBSX_MASK : - strcpy(spr, "tlbsx"); - break; - default : - { - if ( ((((instr & IMM_MASK) >> IMM_LOW) ^ op->immval_mask) & 0xE000) == REG_PVR_MASK) { - snprintf(tmpstr, sizeof(tmpstr), "%s%u", pvr_register_prefix, - (unsigned short)(((instr & IMM_MASK) >> IMM_LOW) ^ - op->immval_mask) ^ REG_PVR_MASK); - return(strdup(tmpstr)); - } else { - strcpy(spr, "pc"); - } - } - break; - } - - snprintf(tmpstr, sizeof(tmpstr), "%s%s", register_prefix, spr); - return(strdup(tmpstr)); +/* Returns NULL for PVR registers, which should be rendered differently. */ +static const char *get_special_name(int special) +{ + switch (special) { + case REG_MSR_MASK: + return register_prefix "msr"; + case REG_PC_MASK: + return register_prefix "pc"; + case REG_EAR_MASK: + return register_prefix "ear"; + case REG_ESR_MASK: + return register_prefix "esr"; + case REG_FSR_MASK: + return register_prefix "fsr"; + case REG_BTR_MASK: + return register_prefix "btr"; + case REG_EDR_MASK: + return register_prefix "edr"; + case REG_PID_MASK: + return register_prefix "pid"; + case REG_ZPR_MASK: + return register_prefix "zpr"; + case REG_TLBX_MASK: + return register_prefix "tlbx"; + case REG_TLBLO_MASK: + return register_prefix "tlblo"; + case REG_TLBHI_MASK: + return register_prefix "tlbhi"; + case REG_TLBSX_MASK: + return register_prefix "tlbsx"; + default: + if ((special & 0xE000) == REG_PVR_MASK) { + /* pvr register */ + return NULL; + } + return register_prefix "pc"; + } } static unsigned long @@ -739,6 +703,8 @@ print_insn_microblaze(bfd_vma memaddr, struct disassemble_info *info) static bfd_vma prev_insn_addr = -1; /*init the prev insn addr */ static int prev_insn_vma = -1; /*init the prev insn vma */ int curr_insn_vma = info->buffer_vma; + int special; + const char *special_name; info->bytes_per_chunk = 4; @@ -799,12 +765,26 @@ print_insn_microblaze(bfd_vma memaddr, struct disassemble_info *info) op->name, get_field_r1(inst), get_field_rfsl(inst)); break; case INST_TYPE_RD_SPECIAL: - fprintf_func(stream, "%s\t" PRIreg ", %s", - op->name, get_field_rd(inst), get_field_special(inst, op)); + special = get_field_special(inst, op); + special_name = get_special_name(special); + if (special_name) { + fprintf_func(stream, "%s\t" PRIreg ", %s", + op->name, get_field_rd(inst), special_name); + } else { + fprintf_func(stream, "%s\t" PRIreg ", " PRIpvr, + op->name, get_field_rd(inst), special ^ REG_PVR_MASK); + } break; case INST_TYPE_SPECIAL_R1: - fprintf_func(stream, "%s\t%s, " PRIreg, - op->name, get_field_special(inst, op), get_field_r1(inst)); + special = get_field_special(inst, op); + special_name = get_special_name(special); + if (special_name) { + fprintf_func(stream, "%s\t%s, " PRIreg, + op->name, special_name, get_field_r1(inst)); + } else { + fprintf_func(stream, "%s\t" PRIpvr ", " PRIreg, + op->name, special ^ REG_PVR_MASK, get_field_r1(inst)); + } break; case INST_TYPE_RD_R1: fprintf_func(stream, "%s\t" PRIreg ", " PRIreg, From patchwork Fri Apr 12 07:33:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 788277 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp591505wrm; Fri, 12 Apr 2024 00:38:05 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUI5Zup85MBpIvAhwAUC6wKVihdF+kw+37Nzrwxs4psUqxp0VrgEVWGo+Oz8JGf14jlzWyMm4DB72GJfXTDAnxR X-Google-Smtp-Source: AGHT+IFq6lh1DZWiT2grR5UeYKvixVsCVF9EP6fD4QA+aEPWu9yuRbDQv3g4Tjb5SnqO7upeox3+ X-Received: by 2002:a0c:eecb:0:b0:69b:5a11:b41 with SMTP id h11-20020a0ceecb000000b0069b5a110b41mr738061qvs.46.1712907485313; Fri, 12 Apr 2024 00:38:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712907485; cv=none; d=google.com; s=arc-20160816; b=RsKnpj8SxZXClLIsC5XfqIJYC2t6wurFFgPhhkS02387Vsr/OHm6hBmB+1fwfwxg0e CaXK2DC3RXA8AT+CZil3Wc5H9+rxsgogDzGb13EbVm6NYHpFuCf+GM/y34+kj/g+HCHe JzQ04RqeKv98koxrn+2bEu/NbXBrkzPCCHS55Pk2YWiOq3zNEb6ru0LZQP2UDGM1k4eL /B5+jfHbj8bK1NHlbR7UAT8ef0AgFufVtKluAesdMJ4qKSDYDO5jQETpxOO+oB8dp8B2 0S4MY1YOnwDhNYuoCQ9emwrXdiEcFEJfBDaYwTuhG0S5ETorTUzkqw5fB4oQyZUILUit mLig== 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:to:from :dkim-signature; bh=smvoXLUw3BuxX5tHBSXGd4u7jZ3WHwKVh8sT00cge+w=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=wbpbiyr3yOHAqcolT4kY6LZ5vMXBgHgLaMAiufROkZ6z+BeW07cCVELA2/QO4Q44v5 RxdrHMhX5fa5cKuY2DZGzUz9vCGA5COgBU/ChVYPQhtjE/bhMqC+QKU/8iyp/f1XkdXj vBswp7VJ5+G6RfOjSmdnBqtDbAj0c8Haiu3Jhk3Nb5VGrj6genKrQ5MToYugDEEoFJhM oYdqet+29rm+peDpeOTWagGkeZ/H36kBJq70C/GkzGpEopt6iEviZ/U6N0lW7KPsmSm1 1tywnLpKidqr65PotgEUWVUdXwp7lTDYqA/PdbcJF6dw1SXVfXLA/lqG4wHy6Jjtwya7 3y0w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=He7mBsOG; 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 z4-20020a0ce984000000b0069b32626e59si3043220qvn.54.2024.04.12.00.38.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 12 Apr 2024 00:38:05 -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=He7mBsOG; 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 1rvBQQ-00077F-DB; Fri, 12 Apr 2024 03:34:18 -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 1rvBQJ-00074j-Ei for qemu-devel@nongnu.org; Fri, 12 Apr 2024 03:34:11 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rvBQF-0007Cu-Cj for qemu-devel@nongnu.org; Fri, 12 Apr 2024 03:34:10 -0400 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1e2232e30f4so6022085ad.2 for ; Fri, 12 Apr 2024 00:34:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712907244; x=1713512044; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=smvoXLUw3BuxX5tHBSXGd4u7jZ3WHwKVh8sT00cge+w=; b=He7mBsOGO8bYHOXKdPQPilPQG/SMoHzYldeUkD0YGCPfemutEvf9WpsdGoFwud7097 Qoy0U1YO/LePYKvBBtlzeahL9/SFAoT0Mde9EcGDGicb8lWx6TR9qdMJ+0hsMy6NeYiR 3qbQC6dLIz08v+MbfnkrZRPe17wc8gY22Sdh4cQLszSwFCJ0LrLVzalGHz+uDPW31mA5 HxMsyTmKGFLAU6pU8SX66arHKEQdw/A3A5fWvLqpIVTd0wPAky+0Sq75sN07SJz0xoKE kYqXR/Vdyl6y9ciCUEzNtnJCYthT+G2s7TTd0I2qqmPWEh/OIJ35rSBy4C+Inruc+h/a ht/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712907244; x=1713512044; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=smvoXLUw3BuxX5tHBSXGd4u7jZ3WHwKVh8sT00cge+w=; b=nqPfdjmQD05RN/s4Ra7V1jjhoIjxDhIbjnoMaI3BRl1Ozph/fNNqy6aiXV0dWgZG24 6q3l6F0Bml9dyAPtcVyy5st6/GZtWbl+/w8ASFVxBhyH9hkLDJKNeOSG7TeD+KAnbGLa Vctb4cAeiICk4hqpoccPvPrDwRFExDxoEjoGchW3nZwwp0tnJNp2RXZt/09WjQws3AUS xHdXfy5wZQAfv67mC1sblxSf21vH59GUV4gVIjxld838QJ4PaXnD/h3saybm+Dt5ZEgQ toTSi+DsMJUuRjNFq+tJv/dGt1oV5F0Q/c8NH4w/J57ekxZ5mxRRFmDQqUSyNCOBtljQ nXPA== X-Gm-Message-State: AOJu0Yx/Qf0yX2rh893H9xYIOBWTAAk6FvkvLZiE5OXTYdADDv/t0JI6 EVNTUM2+hPdEWeTlXeMPDDkCHrvPXAKPapDwiXkJ+BlNLtTCerLnsbqecJy48UaHHmUtztxs8pd x X-Received: by 2002:a17:902:654b:b0:1e2:578:2c32 with SMTP id d11-20020a170902654b00b001e205782c32mr1743224pln.0.1712907244487; Fri, 12 Apr 2024 00:34:04 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id e5-20020a17090301c500b001e556734814sm2206099plh.134.2024.04.12.00.34.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 00:34:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 21/27] disas/riscv: Use GString in format_inst Date: Fri, 12 Apr 2024 00:33:40 -0700 Message-Id: <20240412073346.458116-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240412073346.458116-1-richard.henderson@linaro.org> References: <20240412073346.458116-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.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 Allocate and fill a GString instead of snprintf and appending to a fixed sized buffer. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier Reviewed-by: Alistair Francis --- disas/riscv.c | 209 ++++++++++++++++++++++---------------------------- 1 file changed, 92 insertions(+), 117 deletions(-) diff --git a/disas/riscv.c b/disas/riscv.c index e236c8b5b7..f60f9bda43 100644 --- a/disas/riscv.c +++ b/disas/riscv.c @@ -4757,272 +4757,249 @@ static size_t inst_length(rv_inst inst) /* format instruction */ -static void append(char *s1, const char *s2, size_t n) -{ - size_t l1 = strlen(s1); - if (n - l1 - 1 > 0) { - strncat(s1, s2, n - l1); - } -} - -static void format_inst(char *buf, size_t buflen, size_t tab, rv_decode *dec) +static GString *format_inst(size_t tab, rv_decode *dec) { const rv_opcode_data *opcode_data = dec->opcode_data; - char tmp[64]; + GString *buf = g_string_sized_new(64); const char *fmt; fmt = opcode_data[dec->op].format; while (*fmt) { switch (*fmt) { case 'O': - append(buf, opcode_data[dec->op].name, buflen); + g_string_append(buf, opcode_data[dec->op].name); break; case '(': - append(buf, "(", buflen); - break; case ',': - append(buf, ",", buflen); - break; case ')': - append(buf, ")", buflen); - break; case '-': - append(buf, "-", buflen); + g_string_append_c(buf, *fmt); break; case 'b': - snprintf(tmp, sizeof(tmp), "%d", dec->bs); - append(buf, tmp, buflen); + g_string_append_printf(buf, "%d", dec->bs); break; case 'n': - snprintf(tmp, sizeof(tmp), "%d", dec->rnum); - append(buf, tmp, buflen); + g_string_append_printf(buf, "%d", dec->rnum); break; case '0': - append(buf, rv_ireg_name_sym[dec->rd], buflen); + g_string_append(buf, rv_ireg_name_sym[dec->rd]); break; case '1': - append(buf, rv_ireg_name_sym[dec->rs1], buflen); + g_string_append(buf, rv_ireg_name_sym[dec->rs1]); break; case '2': - append(buf, rv_ireg_name_sym[dec->rs2], buflen); + g_string_append(buf, rv_ireg_name_sym[dec->rs2]); break; case '3': - append(buf, dec->cfg->ext_zfinx ? rv_ireg_name_sym[dec->rd] : - rv_freg_name_sym[dec->rd], - buflen); + if (dec->cfg->ext_zfinx) { + g_string_append(buf, rv_ireg_name_sym[dec->rd]); + } else { + g_string_append(buf, rv_freg_name_sym[dec->rd]); + } break; case '4': - append(buf, dec->cfg->ext_zfinx ? rv_ireg_name_sym[dec->rs1] : - rv_freg_name_sym[dec->rs1], - buflen); + if (dec->cfg->ext_zfinx) { + g_string_append(buf, rv_ireg_name_sym[dec->rs1]); + } else { + g_string_append(buf, rv_freg_name_sym[dec->rs1]); + } break; case '5': - append(buf, dec->cfg->ext_zfinx ? rv_ireg_name_sym[dec->rs2] : - rv_freg_name_sym[dec->rs2], - buflen); + if (dec->cfg->ext_zfinx) { + g_string_append(buf, rv_ireg_name_sym[dec->rs2]); + } else { + g_string_append(buf, rv_freg_name_sym[dec->rs2]); + } break; case '6': - append(buf, dec->cfg->ext_zfinx ? rv_ireg_name_sym[dec->rs3] : - rv_freg_name_sym[dec->rs3], - buflen); + if (dec->cfg->ext_zfinx) { + g_string_append(buf, rv_ireg_name_sym[dec->rs3]); + } else { + g_string_append(buf, rv_freg_name_sym[dec->rs3]); + } break; case '7': - snprintf(tmp, sizeof(tmp), "%d", dec->rs1); - append(buf, tmp, buflen); + g_string_append_printf(buf, "%d", dec->rs1); break; case 'i': - snprintf(tmp, sizeof(tmp), "%d", dec->imm); - append(buf, tmp, buflen); + g_string_append_printf(buf, "%d", dec->imm); break; case 'u': - snprintf(tmp, sizeof(tmp), "%u", ((uint32_t)dec->imm & 0b111111)); - append(buf, tmp, buflen); + g_string_append_printf(buf, "%u", ((uint32_t)dec->imm & 0b111111)); break; case 'j': - snprintf(tmp, sizeof(tmp), "%d", dec->imm1); - append(buf, tmp, buflen); + g_string_append_printf(buf, "%d", dec->imm1); break; case 'o': - snprintf(tmp, sizeof(tmp), "%d", dec->imm); - append(buf, tmp, buflen); - while (strlen(buf) < tab * 2) { - append(buf, " ", buflen); + g_string_append_printf(buf, "%d", dec->imm); + while (buf->len < tab * 2) { + g_string_append_c(buf, ' '); } - snprintf(tmp, sizeof(tmp), "# 0x%" PRIx64, - dec->pc + dec->imm); - append(buf, tmp, buflen); + g_string_append_printf(buf, "# 0x%" PRIx64, dec->pc + dec->imm); break; case 'U': fmt++; - snprintf(tmp, sizeof(tmp), "%d", dec->imm >> 12); - append(buf, tmp, buflen); + g_string_append_printf(buf, "%d", dec->imm >> 12); if (*fmt == 'o') { - while (strlen(buf) < tab * 2) { - append(buf, " ", buflen); + while (buf->len < tab * 2) { + g_string_append_c(buf, ' '); } - snprintf(tmp, sizeof(tmp), "# 0x%" PRIx64, - dec->pc + dec->imm); - append(buf, tmp, buflen); + g_string_append_printf(buf, "# 0x%" PRIx64, dec->pc + dec->imm); } break; case 'c': { const char *name = csr_name(dec->imm & 0xfff); if (name) { - append(buf, name, buflen); + g_string_append(buf, name); } else { - snprintf(tmp, sizeof(tmp), "0x%03x", dec->imm & 0xfff); - append(buf, tmp, buflen); + g_string_append_printf(buf, "0x%03x", dec->imm & 0xfff); } break; } case 'r': switch (dec->rm) { case rv_rm_rne: - append(buf, "rne", buflen); + g_string_append(buf, "rne"); break; case rv_rm_rtz: - append(buf, "rtz", buflen); + g_string_append(buf, "rtz"); break; case rv_rm_rdn: - append(buf, "rdn", buflen); + g_string_append(buf, "rdn"); break; case rv_rm_rup: - append(buf, "rup", buflen); + g_string_append(buf, "rup"); break; case rv_rm_rmm: - append(buf, "rmm", buflen); + g_string_append(buf, "rmm"); break; case rv_rm_dyn: - append(buf, "dyn", buflen); + g_string_append(buf, "dyn"); break; default: - append(buf, "inv", buflen); + g_string_append(buf, "inv"); break; } break; case 'p': if (dec->pred & rv_fence_i) { - append(buf, "i", buflen); + g_string_append_c(buf, 'i'); } if (dec->pred & rv_fence_o) { - append(buf, "o", buflen); + g_string_append_c(buf, 'o'); } if (dec->pred & rv_fence_r) { - append(buf, "r", buflen); + g_string_append_c(buf, 'r'); } if (dec->pred & rv_fence_w) { - append(buf, "w", buflen); + g_string_append_c(buf, 'w'); } break; case 's': if (dec->succ & rv_fence_i) { - append(buf, "i", buflen); + g_string_append_c(buf, 'i'); } if (dec->succ & rv_fence_o) { - append(buf, "o", buflen); + g_string_append_c(buf, 'o'); } if (dec->succ & rv_fence_r) { - append(buf, "r", buflen); + g_string_append_c(buf, 'r'); } if (dec->succ & rv_fence_w) { - append(buf, "w", buflen); + g_string_append_c(buf, 'w'); } break; case '\t': - while (strlen(buf) < tab) { - append(buf, " ", buflen); + while (buf->len < tab) { + g_string_append_c(buf, ' '); } break; case 'A': if (dec->aq) { - append(buf, ".aq", buflen); + g_string_append(buf, ".aq"); } break; case 'R': if (dec->rl) { - append(buf, ".rl", buflen); + g_string_append(buf, ".rl"); } break; case 'l': - append(buf, ",v0", buflen); + g_string_append(buf, ",v0"); break; case 'm': if (dec->vm == 0) { - append(buf, ",v0.t", buflen); + g_string_append(buf, ",v0.t"); } break; case 'D': - append(buf, rv_vreg_name_sym[dec->rd], buflen); + g_string_append(buf, rv_vreg_name_sym[dec->rd]); break; case 'E': - append(buf, rv_vreg_name_sym[dec->rs1], buflen); + g_string_append(buf, rv_vreg_name_sym[dec->rs1]); break; case 'F': - append(buf, rv_vreg_name_sym[dec->rs2], buflen); + g_string_append(buf, rv_vreg_name_sym[dec->rs2]); break; case 'G': - append(buf, rv_vreg_name_sym[dec->rs3], buflen); + g_string_append(buf, rv_vreg_name_sym[dec->rs3]); break; case 'v': { - char nbuf[32] = {0}; const int sew = 1 << (((dec->vzimm >> 3) & 0b111) + 3); - sprintf(nbuf, "%d", sew); const int lmul = dec->vzimm & 0b11; const int flmul = (dec->vzimm >> 2) & 1; const char *vta = (dec->vzimm >> 6) & 1 ? "ta" : "tu"; const char *vma = (dec->vzimm >> 7) & 1 ? "ma" : "mu"; - append(buf, "e", buflen); - append(buf, nbuf, buflen); - append(buf, ",m", buflen); + + g_string_append_printf(buf, "e%d,m", sew); if (flmul) { switch (lmul) { case 3: - sprintf(nbuf, "f2"); + g_string_append(buf, "f2"); break; case 2: - sprintf(nbuf, "f4"); + g_string_append(buf, "f4"); break; case 1: - sprintf(nbuf, "f8"); - break; + g_string_append(buf, "f8"); + break; } - append(buf, nbuf, buflen); } else { - sprintf(nbuf, "%d", 1 << lmul); - append(buf, nbuf, buflen); + g_string_append_printf(buf, "%d", 1 << lmul); } - append(buf, ",", buflen); - append(buf, vta, buflen); - append(buf, ",", buflen); - append(buf, vma, buflen); + g_string_append_c(buf, ','); + g_string_append(buf, vta); + g_string_append_c(buf, ','); + g_string_append(buf, vma); break; } case 'x': { switch (dec->rlist) { case 4: - snprintf(tmp, sizeof(tmp), "{ra}"); + g_string_append(buf, "{ra}"); break; case 5: - snprintf(tmp, sizeof(tmp), "{ra, s0}"); + g_string_append(buf, "{ra, s0}"); break; case 15: - snprintf(tmp, sizeof(tmp), "{ra, s0-s11}"); + g_string_append(buf, "{ra, s0-s11}"); break; default: - snprintf(tmp, sizeof(tmp), "{ra, s0-s%d}", dec->rlist - 5); + g_string_append_printf(buf, "{ra, s0-s%d}", dec->rlist - 5); break; } - append(buf, tmp, buflen); break; } case 'h': - append(buf, rv_fli_name_const[dec->imm], buflen); + g_string_append(buf, rv_fli_name_const[dec->imm]); break; default: break; } fmt++; } + + return buf; } /* lift instruction to pseudo-instruction */ @@ -5108,9 +5085,8 @@ static void decode_inst_decompress(rv_decode *dec, rv_isa isa) /* disassemble instruction */ -static void -disasm_inst(char *buf, size_t buflen, rv_isa isa, uint64_t pc, rv_inst inst, - RISCVCPUConfig *cfg) +static GString *disasm_inst(rv_isa isa, uint64_t pc, rv_inst inst, + RISCVCPUConfig *cfg) { rv_decode dec = { 0 }; dec.pc = pc; @@ -5157,7 +5133,7 @@ disasm_inst(char *buf, size_t buflen, rv_isa isa, uint64_t pc, rv_inst inst, decode_inst_operands(&dec, isa); decode_inst_decompress(&dec, isa); decode_inst_lift_pseudo(&dec); - format_inst(buf, buflen, 24, &dec); + return format_inst(24, &dec); } #define INST_FMT_2 "%04" PRIx64 " " @@ -5168,7 +5144,6 @@ disasm_inst(char *buf, size_t buflen, rv_isa isa, uint64_t pc, rv_inst inst, static int print_insn_riscv(bfd_vma memaddr, struct disassemble_info *info, rv_isa isa) { - char buf[128] = { 0 }; bfd_byte packet[2]; rv_inst inst = 0; size_t len = 2; @@ -5209,9 +5184,9 @@ print_insn_riscv(bfd_vma memaddr, struct disassemble_info *info, rv_isa isa) } } - disasm_inst(buf, sizeof(buf), isa, memaddr, inst, - (RISCVCPUConfig *)info->target_info); - (*info->fprintf_func)(info->stream, "%s", buf); + g_autoptr(GString) str = + disasm_inst(isa, memaddr, inst, (RISCVCPUConfig *)info->target_info); + (*info->fprintf_func)(info->stream, "%s", str->str); return len; } From patchwork Fri Apr 12 07:33:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 788257 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp590949wrm; Fri, 12 Apr 2024 00:36:00 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUaVFTDDi1KibAJCaeWY2UAjggMSQadOQOO5q/ggsqhlQOccXgxI04Ql6grWddoZ26ba+bGSU31tNHZLmSn1tzb X-Google-Smtp-Source: AGHT+IEjhhpIx31+RCdVUIf4S7eRwDNSLyTK1YFvG4zMOgztnHR5TYKFYCW5av6rie9mbTHct91V X-Received: by 2002:a0c:e14f:0:b0:69b:5516:d547 with SMTP id c15-20020a0ce14f000000b0069b5516d547mr1669806qvl.24.1712907360100; Fri, 12 Apr 2024 00:36:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712907360; cv=none; d=google.com; s=arc-20160816; b=x68l73e3Lpz1cGg+/57LfP3bKzsuXe8h6zhp4CHnJfLqYLxFk+lpRqxZupAM6w9riY EXnH7dwJ3iBURlz+ljcLIsbwQD/AYq7s/rUBjs1r3Q8C0dgSuGbzwPyYPgm3Pau3UP6r QtgPkWEdGNG5bIVzr0jstsZ4hFXD6nL2lQ+guoyuCCFuDwK2G69eGN70n6GIX02zez8n 4dukGXJVsd1gq82VwD/6KmqOSQlipq8SphlQTKBkUfy+F9i24HClbFOG9FCTsUf2W/oC LLVyJI1UCLKvMd0pBRMOLP/oKrOUhmQKnBN9Ne6CfyFo7EMXXwAceRueAozdrufhI5iv /Vgg== 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=SD4AFTXyCoH1gQiMjEXl2qngbfpinlSjJhmj7iTFm1s=; fh=kQadAhxV42GJ3cd2VUw1RyURv/zJQGvmUdF7iLEVTtc=; b=SfCSbH8iT2O78Y11YlXapj3IdmChMR8ocZFN0BYOjON3HqHKFrA8bHlB1l6HxAVDwE TWKrz8/WBunLz+xvAn/U7I8QXPqtW6cnrIhSGEVyFMlnRxyi6Y+4BNpi5ta3+SzidGRu j5V3Qz5gKN6TFvBZJQx9CQj2ql3kN3V9kd7UcsnJIxZpF7bPQCH4i+fRV72llzTyn21P fvqsS5TD6GSoFioiDpnqTC9ERVwn0xw0XNC2Bweayk0NSno5k/nicjBIuNRhyN4RcKGm FVc5EEgHPfPw2uh4ftNRB2IsZK3iECwa1scgEHB5PX1tGDhdt4X+s8H6MV8nYSJeKmG2 35+g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=d8kiwJ09; 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 cs5-20020ad44c45000000b006993a4735d5si3207704qvb.187.2024.04.12.00.35.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 12 Apr 2024 00:36:00 -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=d8kiwJ09; 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 1rvBQO-00076F-Op; Fri, 12 Apr 2024 03:34:16 -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 1rvBQL-00075o-Lr for qemu-devel@nongnu.org; Fri, 12 Apr 2024 03:34:15 -0400 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rvBQH-0007Cx-Bu for qemu-devel@nongnu.org; Fri, 12 Apr 2024 03:34:12 -0400 Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-6ecf3943040so590694b3a.0 for ; Fri, 12 Apr 2024 00:34:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712907245; x=1713512045; 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=SD4AFTXyCoH1gQiMjEXl2qngbfpinlSjJhmj7iTFm1s=; b=d8kiwJ09tTOoem0RH9l2oMbxyLJKBTUoO0z3VB1eh9vG/Nwc2lCspwuLIMp3MlK3l0 1eKDaiUNHcUBYEdjXX8lTd/qT4Xm7TEGKThRtgFtulHFFQjyAdbkNjc0T/bWnPYY72yU aqvLOIh+l3yuFxzrPXXDvqAa/YqKqYZkzLsii2Ew0sM9Oy7vMP6yUKO6bxucpTESm4qu yJ/3z2nlKXuEtwzlkW/eFIebjPEdJmvd0+6AS6aTfVJ0/2golKD1IDbJfeR3S1Z7xX60 UX3Kp7TWE8ECkPwVmYbAfrH5rjYzI76SldtqpNSO9ZhJAdK26AI2CovzAh+eM3lc5Uw9 JykQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712907245; x=1713512045; 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=SD4AFTXyCoH1gQiMjEXl2qngbfpinlSjJhmj7iTFm1s=; b=M6DPhfE1DJRWMa3M9akWKuVPvWbX7DZlsPGnCKlpTX77uaXSHeBrGLWF9+FZ86w/x6 CYIhDVx5WIIWkg6rcPLvP0or8rzD//qpwpxWFFago9m6iggqvmWQOBL0uvWS3Cy4qM+5 Tn1ydAeJDm9YIhA0d/CmL4JR4FhRS6k7286LTEfQKtifmh7onmBgRVKiB/qoJqB+49FH 385Ug6e7+Zi3R5m/lZB7sIRsxlmw9r2SjGNJpb3w6HEZj65zXc+9T/u4EnrHioAOhUsk VNFwWJAKHleo1sqIf0jjpGJf0WNEGGtZc1A+p4pMLfb7iEJTSoIaG6FhySgIU2VAaLms tnWA== X-Gm-Message-State: AOJu0Yxh0zmok7czmxzmoL75LIDFcZsF4nKlHlDQwzhP3sQx0pnt81eE yVSmDrrHDsChFBXcG0MS34NFe1Q9ZbNl3tvZ2Gvhz0abRbVSuUj9j/UbS0/5FWzqmmH3bVRI18Z j X-Received: by 2002:a05:6300:630e:b0:1a7:a21b:66f9 with SMTP id jn14-20020a056300630e00b001a7a21b66f9mr1823376pzc.43.1712907245187; Fri, 12 Apr 2024 00:34:05 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id e5-20020a17090301c500b001e556734814sm2206099plh.134.2024.04.12.00.34.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 00:34:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 22/27] linux-user/flatload: Replace sprintf() by snprintf() Date: Fri, 12 Apr 2024 00:33:41 -0700 Message-Id: <20240412073346.458116-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240412073346.458116-1-richard.henderson@linaro.org> References: <20240412073346.458116-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::430; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x430.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 From: Philippe Mathieu-Daudé sprintf() is deprecated on Darwin since macOS 13.0 / XCode 14.1, resulting in painful developper experience. Use snprintf() instead. Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20240411104340.6617-5-philmd@linaro.org> Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- linux-user/flatload.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/flatload.c b/linux-user/flatload.c index 5b62aa0a2b..1bb2f400bc 100644 --- a/linux-user/flatload.c +++ b/linux-user/flatload.c @@ -692,7 +692,7 @@ static int load_flat_shared_library(int id, struct lib_info *libs) char buf[16]; /* Create the file name */ - sprintf(buf, "/lib/lib%d.so", id); + snprintf(buf, sizeof(buf), "/lib/lib%d.so", id); /* Open the file up */ bprm.filename = buf; From patchwork Fri Apr 12 07:33:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 788262 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp591110wrm; Fri, 12 Apr 2024 00:36:35 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV0DDHNU2+XZQmkrVtbNMgWt6Ev71yPHSrdnibpnDOa6V6C7JQlKksgSw0ZBv7JftJoG2HqtqqOeQ9UcC375WNr X-Google-Smtp-Source: AGHT+IFYNcjCtEzeOF09bYfw7n4Y+w1cVGetW6zPbqHeCX7OzkK86+WWFHV0fW90rVpSbtyhmf4D X-Received: by 2002:a05:690c:1c:b0:618:822a:e69a with SMTP id bc28-20020a05690c001c00b00618822ae69amr891063ywb.9.1712907395312; Fri, 12 Apr 2024 00:36:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712907395; cv=none; d=google.com; s=arc-20160816; b=lq/sawX+AH7fnmeU2BobRwcNJ7mEkP3/Y3sZnx0o7RyuGrzklblwz0VmzC80Khpjei brHi9EKrq4nKNM5qYzWB/E0TBIKFgvznEhrIwLreLGfZRqz8cudUnO+JO5J7NeNLx69D sn85t0tz2OdNQy9O5iLyzwVZu3GPzheLlU7KD3DGiZFsLSBycrjTm/DBe4XQSiydkpbW A1XnfWl1+CenAuRSgSeFCrPTcE6I4SsFtXiueou0QuGBw2Rv9kIuzh4BzRmjronzqO+r fV8W0j6U1/MVI0YtB9ZHQ0eUjuKeTen3dOROwaSAdo7f3KNROg9z7QYeCVas9+hax0sy nHSg== 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=Yt7XTd0PVkVIabRbeCb1YqLB6pmup83tW4MV6eKsa+A=; fh=XWTD8Z9WAMjh+M8BxQj8k30uAZD5B0T9z1nl1AeO1vA=; b=hsAgVRloS4zXfwjCaJRoxm+GQg7LFlA9pTA50Ai+4Ii9JXM/oX6sUu2Eoqn5uAtu4u cTDJgjIKPNgr9HGEIvw4pGnBRVdf0COlQVOxPyc7I4R++nC9jbGvfXswJp5KtMojZqzG VATPPQ2jjUclyhDamQZNiMgC79Ce5W/IQPpWXa7BGgPWSpW4EOLUGcbagDqfrDKpOaLZ PCh4Yml/O1IlKTIxlUxGPUXQWJYksvdwKj7NS0ZYyan25Jm91uXo9LeOvUSnLXJVe10v 8XoGVTTyQbwEzNRSEnL1o6kN7yc9gMTg3P65p4MUJPI0VPGUBbs/5dh/Df6HX3/Zdk/c ZIzA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VHio1MKA; 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 bk37-20020a05620a1a2500b0078d6349929dsi3555881qkb.458.2024.04.12.00.36.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 12 Apr 2024 00:36:35 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VHio1MKA; 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 1rvBQN-00076D-Pm; Fri, 12 Apr 2024 03:34:15 -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 1rvBQJ-00074k-Et for qemu-devel@nongnu.org; Fri, 12 Apr 2024 03:34:11 -0400 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rvBQF-0007D3-DV for qemu-devel@nongnu.org; Fri, 12 Apr 2024 03:34:09 -0400 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1e3cf5b171eso5656715ad.0 for ; Fri, 12 Apr 2024 00:34:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712907246; x=1713512046; 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=Yt7XTd0PVkVIabRbeCb1YqLB6pmup83tW4MV6eKsa+A=; b=VHio1MKAPNeHvgol8km1xhIArWWaWECtb38vXpWymSJsrkFWe/vPWgbed1WmHv+7pl X5g92+qaFIhzCabPh9CC74SvhK1Pegae2GuZA65vAi4E7Qy4lMGxpk0NaeOeZ6dAvNz6 ewU0l2eudYVDUrOGHItGX0pLgVxZ9Gr1X/X+l4xs/UtKruO4R4vWgoaVIRu3lf5PAwox NlDV5hlTAMud5P3cHaX7TwFoAoj3YtSS/I3wiXpnv67Eac/5RXKblb3go3cRxeumeM8E U7IFXgXRrR3PqWTdlQLm1VDIpFzskm9wQDe5K3OlKAUijDcZEQ9JN8MRxA6i+E9WHfCR VwOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712907246; x=1713512046; 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=Yt7XTd0PVkVIabRbeCb1YqLB6pmup83tW4MV6eKsa+A=; b=Fw3ZORSuFV0D3WtvxTFH1dNlpGip+CHLsrxU1OwLURivoHJCAnU2/2JgXcg/jzTeyy 5ies9edKA9cIh+9TSJ7RiX7Am5OTvQtWM7/gA/mxOQSFDi/46i7kmgv5M7ES7q/ICaDt aNksF66jsnGEimeQr810BaH5zdx2bf9jlvX+O9ctACUFRWqSMahkSxpkQq/Q4nJhIWpw ylzulcsGJlDfNpR9DkvRlsFCAG1GSsN35j/YpGdY52ldzLgs642kWDfjJw2w15fhD6KU DaqFPhSwWgH/k0YR/fVHMvJRyl7Uw1AAyjSLRnDTrB4mRmUGXHVIaUGrueo0re9o9piC ydYw== X-Gm-Message-State: AOJu0YxVbCoQcoOhsMIA9ekUF2gitc4AecQsUNMzNBcF8104TJk1IkGo Likpc6sVvb5w0kfNf5Hu9ayAWlQn/+LMBqEICNYlflWZDMDF8mQrGLKL9uRBqw9n6sb3RB8f24m W X-Received: by 2002:a17:902:ebc4:b0:1e2:96d3:1bc1 with SMTP id p4-20020a170902ebc400b001e296d31bc1mr2001016plg.1.1712907245985; Fri, 12 Apr 2024 00:34:05 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id e5-20020a17090301c500b001e556734814sm2206099plh.134.2024.04.12.00.34.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 00:34:05 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell Subject: [PATCH v3 23/27] hw/misc/imx: Replace sprintf() by snprintf() Date: Fri, 12 Apr 2024 00:33:42 -0700 Message-Id: <20240412073346.458116-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240412073346.458116-1-richard.henderson@linaro.org> References: <20240412073346.458116-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62d.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 From: Philippe Mathieu-Daudé sprintf() is deprecated on Darwin since macOS 13.0 / XCode 14.1, resulting in painful developper experience. Use snprintf() instead. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Peter Maydell Message-Id: <20240411104340.6617-6-philmd@linaro.org> Signed-off-by: Richard Henderson --- hw/misc/imx25_ccm.c | 2 +- hw/misc/imx31_ccm.c | 2 +- hw/misc/imx6_ccm.c | 4 ++-- hw/misc/imx6_src.c | 2 +- hw/misc/imx6ul_ccm.c | 4 ++-- hw/misc/imx7_src.c | 2 +- hw/net/imx_fec.c | 2 +- hw/ssi/imx_spi.c | 2 +- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/hw/misc/imx25_ccm.c b/hw/misc/imx25_ccm.c index d888966014..faa726a86a 100644 --- a/hw/misc/imx25_ccm.c +++ b/hw/misc/imx25_ccm.c @@ -91,7 +91,7 @@ static const char *imx25_ccm_reg_name(uint32_t reg) case IMX25_CCM_LPIMR1_REG: return "lpimr1"; default: - sprintf(unknown, "[%u ?]", reg); + snprintf(unknown, sizeof(unknown), "[%u ?]", reg); return unknown; } } diff --git a/hw/misc/imx31_ccm.c b/hw/misc/imx31_ccm.c index a9059bb1f7..125d4fceeb 100644 --- a/hw/misc/imx31_ccm.c +++ b/hw/misc/imx31_ccm.c @@ -89,7 +89,7 @@ static const char *imx31_ccm_reg_name(uint32_t reg) case IMX31_CCM_PDR2_REG: return "PDR2"; default: - sprintf(unknown, "[%u ?]", reg); + snprintf(unknown, sizeof(unknown), "[%u ?]", reg); return unknown; } } diff --git a/hw/misc/imx6_ccm.c b/hw/misc/imx6_ccm.c index 56489d8b57..b1def7f05b 100644 --- a/hw/misc/imx6_ccm.c +++ b/hw/misc/imx6_ccm.c @@ -85,7 +85,7 @@ static const char *imx6_ccm_reg_name(uint32_t reg) case CCM_CMEOR: return "CMEOR"; default: - sprintf(unknown, "%u ?", reg); + snprintf(unknown, sizeof(unknown), "%u ?", reg); return unknown; } } @@ -224,7 +224,7 @@ static const char *imx6_analog_reg_name(uint32_t reg) case USB_ANALOG_DIGPROG: return "USB_ANALOG_DIGPROG"; default: - sprintf(unknown, "%u ?", reg); + snprintf(unknown, sizeof(unknown), "%u ?", reg); return unknown; } } diff --git a/hw/misc/imx6_src.c b/hw/misc/imx6_src.c index 0c6003559f..3766bdf561 100644 --- a/hw/misc/imx6_src.c +++ b/hw/misc/imx6_src.c @@ -68,7 +68,7 @@ static const char *imx6_src_reg_name(uint32_t reg) case SRC_GPR10: return "SRC_GPR10"; default: - sprintf(unknown, "%u ?", reg); + snprintf(unknown, sizeof(unknown), "%u ?", reg); return unknown; } } diff --git a/hw/misc/imx6ul_ccm.c b/hw/misc/imx6ul_ccm.c index bbc0be9921..0ac49ea34b 100644 --- a/hw/misc/imx6ul_ccm.c +++ b/hw/misc/imx6ul_ccm.c @@ -143,7 +143,7 @@ static const char *imx6ul_ccm_reg_name(uint32_t reg) case CCM_CMEOR: return "CMEOR"; default: - sprintf(unknown, "%u ?", reg); + snprintf(unknown, sizeof(unknown), "%u ?", reg); return unknown; } } @@ -274,7 +274,7 @@ static const char *imx6ul_analog_reg_name(uint32_t reg) case USB_ANALOG_DIGPROG: return "USB_ANALOG_DIGPROG"; default: - sprintf(unknown, "%u ?", reg); + snprintf(unknown, sizeof(unknown), "%u ?", reg); return unknown; } } diff --git a/hw/misc/imx7_src.c b/hw/misc/imx7_src.c index b3725ff6e7..d19f0450d4 100644 --- a/hw/misc/imx7_src.c +++ b/hw/misc/imx7_src.c @@ -75,7 +75,7 @@ static const char *imx7_src_reg_name(uint32_t reg) case SRC_GPR10: return "SRC_GPR10"; default: - sprintf(unknown, "%u ?", reg); + snprintf(unknown, sizeof(unknown), "%u ?", reg); return unknown; } } diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c index cee84af7ba..8c91d20d44 100644 --- a/hw/net/imx_fec.c +++ b/hw/net/imx_fec.c @@ -41,7 +41,7 @@ static const char *imx_default_reg_name(IMXFECState *s, uint32_t index) { static char tmp[20]; - sprintf(tmp, "index %d", index); + snprintf(tmp, sizeof(tmp), "index %d", index); return tmp; } diff --git a/hw/ssi/imx_spi.c b/hw/ssi/imx_spi.c index d8a7583ff3..12d897d306 100644 --- a/hw/ssi/imx_spi.c +++ b/hw/ssi/imx_spi.c @@ -53,7 +53,7 @@ static const char *imx_spi_reg_name(uint32_t reg) case ECSPI_MSGDATA: return "ECSPI_MSGDATA"; default: - sprintf(unknown, "%u ?", reg); + snprintf(unknown, sizeof(unknown), "%u ?", reg); return unknown; } } From patchwork Fri Apr 12 07:33:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 788256 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp590936wrm; Fri, 12 Apr 2024 00:35:58 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU7gcawecRgsywLm84awvGpLkkGZkoRxJnJRDG45vCHmLJtSZGwdx3OcGnmVQeIAKwXRifdv3gDqHSgaFYX0GyU X-Google-Smtp-Source: AGHT+IH2U6DWbyecngcLMNWEOW8zUGWBqXMRX1yYBlW3sRgg1YmUn4lBpnSesYS68XqSnvmVTXzs X-Received: by 2002:ac8:7f47:0:b0:434:61a4:5738 with SMTP id g7-20020ac87f47000000b0043461a45738mr8185929qtk.28.1712907357881; Fri, 12 Apr 2024 00:35:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712907357; cv=none; d=google.com; s=arc-20160816; b=S7ovKIf4IoIASVOdGAF7Vd+20xn1QkkLSM+jmAsUf/Gz8XXXAhM9BP+aWiK/BSyd59 3OUEi8zSO6+YqWWahrbMSGgcJtrDspOJuB12r0Xzq81EihBeXi7iwpOdLmTvFgBD87gJ vkI5W22GylZ7P6WmTPZKIxNfeIxVQeU1w5EoeJFmRFhPcYANADN9dAxaXbUaw72RPS4t XXk1/iL5Ti8Nz1eDMwItjNnHVIEwO9bs7dnilvaqXMqXdxdZpR/vCVn6IHSa3c/NW7cq uplzatDNO5nsBZewGdVxGyrLdWu70AvNPgtSBf4/Ur5dIdB1J1OuO1G08ISQm6lIfHoG 7e/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=wEe+ZpGNanZOUW1LiPHIpYdRRTuUQOyTjtk3qA26K5Y=; fh=kQadAhxV42GJ3cd2VUw1RyURv/zJQGvmUdF7iLEVTtc=; b=ujecDg+Vj+bTlQCIPaPYM5Xldfd3utnUoJKcPJsuEzTrWIBEy5bnoW8GT5q9rOa7Uh 8S3dOoj5peMbzCVfqEe+VahqPptH+ySnQGh5QAgaWOO3mEmCsLYLZWgAk7fEzaVdveM5 muccxdxx8M/5Krk5mDPsjY2NAhPCGLqhyIdSRkimVa4hhpzZujyohQwCRkTzU/yxcZPV FUGDqJVU5L9pqPgR3ImgnlmaN7eddLN7Y2W6i+aJ2Cj5b6yTHQjmspRUcCBxwxKApfkG 3NLNhpDFoRd7N5LmLihqRbpI9iTrwGrRPpGktm7rQB9nkg5u/fZSaCaxagnCxZpbs8Br EENQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ju+CyyB8; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id dh4-20020a05622a4e0400b00434e49e8caasi2947198qtb.32.2024.04.12.00.35.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 12 Apr 2024 00:35:57 -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=ju+CyyB8; 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 1rvBQS-00078V-MV; Fri, 12 Apr 2024 03:34:20 -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 1rvBQK-00075e-Qr for qemu-devel@nongnu.org; Fri, 12 Apr 2024 03:34:13 -0400 Received: from mail-pl1-x634.google.com ([2607:f8b0: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 1rvBQH-0007DE-A7 for qemu-devel@nongnu.org; Fri, 12 Apr 2024 03:34:12 -0400 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1e2c725e234so12523275ad.1 for ; Fri, 12 Apr 2024 00:34:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712907247; x=1713512047; 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=wEe+ZpGNanZOUW1LiPHIpYdRRTuUQOyTjtk3qA26K5Y=; b=ju+CyyB8H/xP0uZt1P/D835pJdNc16qzsApQ9QFWceiOsBgAfjxqUgI8qCK1N5/TC+ idjaYceaQXRjQ1Stf3QLaHhK4OjXmdbwE8Jx+xm3mFhnZvOB8VklnGAplSGiTqR55wON 9MWVwH7qCf0Y+q2HqeEaTk6sHrmneLuiLbxkfTdvXcZJvk/HyXpgrYcGt9owRWgnSzE7 kBrHdECCAcQwvJhYkrqvP7zfF9U3FAJElwQhwQS53Ct8FhDbj8Muk5/aWtfSuWO7Zuf9 vB2LsFL3KWv17dtAZOMo3MF1SN2jJDDHoAzr2iO+xZ9bI7YOJYIFtKAgTnxC6JKXFAO9 qm7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712907247; x=1713512047; 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=wEe+ZpGNanZOUW1LiPHIpYdRRTuUQOyTjtk3qA26K5Y=; b=RihPQAYOAdCIYXPkHdgJpkr/2x5XTaIH5NOzJiEmw0431EkW9qq/SJkQDIJIX5rXAA +yi+llV3lfL8nRnQ7Xndss3afYvlaPpWglXX19Df888iUcmV/Fk1+cSKiWWSbE7SASsB kox0NQC6sxrdEaOlcZZhGht4KNbKj20A4b2e5GyDXJfsuSpo0v5mX+g7tXlkqfKQjb2G 8BHk4QJE/XoJIPF5yMeAet9Mma7fY9Qbl0zOQpBrb5ZtZqTfrusgtHEQyFRgEdaLxwKw 7NLLrCU/+H2NSLzkdyvYvmPNyQZEIJPsWYdJDsuYlHtt0CCsJNF/tyaXN0+/x/drzPTx h2/Q== X-Gm-Message-State: AOJu0YxQunpUGjeAlRJQwtaZ1uXONBJVxQLlGN6SUrU2PBGFz0mXjNkW +UtN0bvDbxq/+c/74SOYpYloQ5BKaSYKB9p4URGYmB9GvvgqN0SugjDYUWMlYLe7kaOhcH5zTbs u X-Received: by 2002:a17:902:e542:b0:1e4:320b:4311 with SMTP id n2-20020a170902e54200b001e4320b4311mr6221348plf.34.1712907246671; Fri, 12 Apr 2024 00:34:06 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id e5-20020a17090301c500b001e556734814sm2206099plh.134.2024.04.12.00.34.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 00:34:06 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 24/27] hw/net/rocker: Replace sprintf() by snprintf() Date: Fri, 12 Apr 2024 00:33:43 -0700 Message-Id: <20240412073346.458116-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240412073346.458116-1-richard.henderson@linaro.org> References: <20240412073346.458116-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::634; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-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=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 From: Philippe Mathieu-Daudé sprintf() is deprecated on Darwin since macOS 13.0 / XCode 14.1, resulting in painful developper experience. Use snprintf() instead. Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20240411104340.6617-7-philmd@linaro.org> Signed-off-by: Richard Henderson --- hw/net/rocker/rocker.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/hw/net/rocker/rocker.c b/hw/net/rocker/rocker.c index 7ea8eb6ba5..03ac7a7ae9 100644 --- a/hw/net/rocker/rocker.c +++ b/hw/net/rocker/rocker.c @@ -915,40 +915,40 @@ static const char *rocker_reg_name(void *opaque, hwaddr addr) switch (index) { case 0: - sprintf(ring_name, "cmd"); + snprintf(ring_name, sizeof(ring_name), "cmd"); break; case 1: - sprintf(ring_name, "event"); + snprintf(ring_name, sizeof(ring_name), "event"); break; default: - sprintf(ring_name, "%s-%d", index % 2 ? "rx" : "tx", - (index - 2) / 2); + snprintf(ring_name, sizeof(ring_name), "%s-%d", + index % 2 ? "rx" : "tx", (index - 2) / 2); } switch (offset) { case ROCKER_DMA_DESC_ADDR_OFFSET: - sprintf(buf, "Ring[%s] ADDR", ring_name); + snprintf(buf, sizeofbuf), "Ring[%s] ADDR", ring_name); return buf; case ROCKER_DMA_DESC_ADDR_OFFSET+4: - sprintf(buf, "Ring[%s] ADDR+4", ring_name); + snprintf(buf, sizeofbuf), "Ring[%s] ADDR+4", ring_name); return buf; case ROCKER_DMA_DESC_SIZE_OFFSET: - sprintf(buf, "Ring[%s] SIZE", ring_name); + snprintf(buf, sizeofbuf), "Ring[%s] SIZE", ring_name); return buf; case ROCKER_DMA_DESC_HEAD_OFFSET: - sprintf(buf, "Ring[%s] HEAD", ring_name); + snprintf(buf, sizeofbuf), "Ring[%s] HEAD", ring_name); return buf; case ROCKER_DMA_DESC_TAIL_OFFSET: - sprintf(buf, "Ring[%s] TAIL", ring_name); + snprintf(buf, sizeofbuf), "Ring[%s] TAIL", ring_name); return buf; case ROCKER_DMA_DESC_CTRL_OFFSET: - sprintf(buf, "Ring[%s] CTRL", ring_name); + snprintf(buf, sizeofbuf), "Ring[%s] CTRL", ring_name); return buf; case ROCKER_DMA_DESC_CREDITS_OFFSET: - sprintf(buf, "Ring[%s] CREDITS", ring_name); + snprintf(buf, sizeofbuf), "Ring[%s] CREDITS", ring_name); return buf; default: - sprintf(buf, "Ring[%s] ???", ring_name); + snprintf(buf, sizeofbuf), "Ring[%s] ???", ring_name); return buf; } } else { From patchwork Fri Apr 12 07:33:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 788264 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp591176wrm; Fri, 12 Apr 2024 00:36:47 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVZVrfKFqg3Bs6bpHuPawfcoqZ/8+2x6p6IrV2z/JtHV0aX3z1kOETL0EW1dMC/VdvhPKTdu3n4qkR3p2nHJvvz X-Google-Smtp-Source: AGHT+IH5tH+lmpy/n5HGu6QYsVSp+mvOXkk6kUNyvfdUzdjMx4/HADgLH9nALayGgX/ZZqlcXLPM X-Received: by 2002:a81:e305:0:b0:618:5b27:e12b with SMTP id q5-20020a81e305000000b006185b27e12bmr1811486ywl.7.1712907407707; Fri, 12 Apr 2024 00:36:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712907407; cv=none; d=google.com; s=arc-20160816; b=QkadQebohz1XYGcOr5hMDTeY2lpbv216AoZJXgvGQD53xW39A5YacxJ8hmQ7MzWzXY cMyPzAT6GKBFPTGeVDKxwhiy2UHWcDJgbt1CMYR+GbZMb+vAxOzKhKYHR4yTfRg5OBOR JT0nij18XwR0jodvpFmwGwQXwihCGQ6RvYmthgPtiuST51mgziyV/1I+XuYFBzqzaSuO dMP0W0mKpSyoVdJmskraqU691T5EE9nPUklDRXuosUs9b8uQiC8bDMDNtLsAdxvhwJL0 96HmL/f07+OSa1Rh3S4gdt4cHTD2u6NTsfoEG38eIamQsiPPscjHiSMJovLIfs7a7eCD jQxQ== 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=eRXCXUY4I/jEqq87nwbnLzBZIzxiWLj4iUBZS7Znhy0=; fh=kQadAhxV42GJ3cd2VUw1RyURv/zJQGvmUdF7iLEVTtc=; b=ussiJypf6E7invNkb4UFj1lWwQc01aDZ3oHWRf0KS4LTeHPSI22301P2b25zBInJLj D8F9toDYiMx6wnD4KYo4hZlw8VpSq2fiO0lDahk3kdgHLqQzXZEDq0X8iYXk9V9LM1yd pLEWDyYDDSku2oRs7t0Ng8rzuuh/RdGeSdb9SYOU2w8ZjX0lZVKF0HzCIZopNQWOO1A6 WRCclgIFKWbpLvbsW9p64LTSqY+ek+zM20cAMHlnS5yHZ90H10uYP8Eb9mh4sHScMzrb ki5VLXadCQO6GE2DcttFYRMCm+QbduOk0dIDxQJO7/fSeoSdMDYuBQTnVn1Gvwrz9Ovo iZPg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=luqGkJIM; 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 ye4-20020a05620a3b8400b0078d4eccd81esi3115171qkn.636.2024.04.12.00.36.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 12 Apr 2024 00:36:47 -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=luqGkJIM; 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 1rvBQR-00078D-3O; Fri, 12 Apr 2024 03:34:19 -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 1rvBQP-00076b-6e for qemu-devel@nongnu.org; Fri, 12 Apr 2024 03:34:17 -0400 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rvBQJ-0007DW-4P for qemu-devel@nongnu.org; Fri, 12 Apr 2024 03:34:16 -0400 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1e220e40998so4537685ad.1 for ; Fri, 12 Apr 2024 00:34:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712907247; x=1713512047; 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=eRXCXUY4I/jEqq87nwbnLzBZIzxiWLj4iUBZS7Znhy0=; b=luqGkJIMFNSaoXXMI7IAIDBSz1wvp3ZHFtASxtg7unvnkkxUcmsQ7Q4xbBVnkUVItV AV9tUxdLbCJwsqjfrdUYZUaYAa/pmfL5NpZ3ywwINw8GRKFvU8oGYL3VKaw7TWTnal+1 +JG7xCJtnmu1ex8veBWf6yC7vbqjv/m2UpUm4ejGVRWhxOpNFSl0HUktr7ccZZdSxE3P BWcWhNe1JaXL74ZOxa7QzQmvl2rZrMNbd+DLcIYpTgYdcnz1gSzBbuBlGh/PFH2ECMS5 1AKpbYI52v+ka4mDeOHKm5iXoWFktn6T24BFgMjswHA0yTGYcKS6SFgYxIX2yHR0G/I0 SY2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712907247; x=1713512047; 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=eRXCXUY4I/jEqq87nwbnLzBZIzxiWLj4iUBZS7Znhy0=; b=jhraScrkZZImigQoYfdMCQpUS9TCv0nmmMFaemyBlucj6REtrxf+yxHYZqAK+6ai/L RtGUbGmJY/PzQp5QsCWYZ60LHmL6VqGSFS/Vtp1qgNVOge3zZa8JebFPV31MRP+oWfRU 8UrwHvV6CX0STFrd8XJMvcNVll1xmCV5t7sL8js2wE+DOWJXeSYqfEng0AYmf1kWvOtG 5pFXekn+egNcI8cktWzMjjCz3dFVJhMVcH9hpBJPPMmACmJ9Q0+SxBj8eEiIe/Xu8xdJ ROMDRXgOUlEixpu1yOr0soGe9afchiPYjxnOMlM8iuW2s7jIINn8HH9FBcsQ8SgrAlcA DoAg== X-Gm-Message-State: AOJu0YzL3/ZyMJOKQ1bVszpANujlSN2Sjv2eZRTpMa8vqLGjuNsrhxru vAZmtyJ9y4bXjej8WuTFhmRRSpYsMhVqacnV+tsQ6BTYK+qmuEBK7BG9dn1C/GA302JqsXFVHot a X-Received: by 2002:a17:902:c101:b0:1e2:a5ee:c0a2 with SMTP id 1-20020a170902c10100b001e2a5eec0a2mr1613846pli.31.1712907247436; Fri, 12 Apr 2024 00:34:07 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id e5-20020a17090301c500b001e556734814sm2206099plh.134.2024.04.12.00.34.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 00:34:07 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 25/27] hw/riscv/virt: Replace sprintf by g_strdup_printf Date: Fri, 12 Apr 2024 00:33:44 -0700 Message-Id: <20240412073346.458116-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240412073346.458116-1-richard.henderson@linaro.org> References: <20240412073346.458116-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62e.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_PASS=-0.001, T_SPF_HELO_TEMPERROR=0.01 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 From: Philippe Mathieu-Daudé sprintf() is deprecated on Darwin since macOS 13.0 / XCode 14.1. Use g_strdup_printf instead. Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20240411104340.6617-8-philmd@linaro.org> [rth: Use g_strdup_printf] Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier Reviewed-by: Alistair Francis --- hw/riscv/virt.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index d171e74f7b..4fdb660525 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -1617,10 +1617,8 @@ static void virt_machine_instance_init(Object *obj) static char *virt_get_aia_guests(Object *obj, Error **errp) { RISCVVirtState *s = RISCV_VIRT_MACHINE(obj); - char val[32]; - sprintf(val, "%d", s->aia_guests); - return g_strdup(val); + return g_strdup_printf("%d", s->aia_guests); } static void virt_set_aia_guests(Object *obj, const char *val, Error **errp) @@ -1741,7 +1739,6 @@ static void virt_machine_device_plug_cb(HotplugHandler *hotplug_dev, static void virt_machine_class_init(ObjectClass *oc, void *data) { - char str[128]; MachineClass *mc = MACHINE_CLASS(oc); HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(oc); @@ -1767,7 +1764,6 @@ static void virt_machine_class_init(ObjectClass *oc, void *data) machine_class_allow_dynamic_sysbus_dev(mc, TYPE_TPM_TIS_SYSBUS); #endif - object_class_property_add_bool(oc, "aclint", virt_get_aclint, virt_set_aclint); object_class_property_set_description(oc, "aclint", @@ -1785,9 +1781,14 @@ static void virt_machine_class_init(ObjectClass *oc, void *data) object_class_property_add_str(oc, "aia-guests", virt_get_aia_guests, virt_set_aia_guests); - sprintf(str, "Set number of guest MMIO pages for AIA IMSIC. Valid value " - "should be between 0 and %d.", VIRT_IRQCHIP_MAX_GUESTS); - object_class_property_set_description(oc, "aia-guests", str); + { + g_autofree char *str = + g_strdup_printf("Set number of guest MMIO pages for AIA IMSIC. " + "Valid value should be between 0 and %d.", + VIRT_IRQCHIP_MAX_GUESTS); + object_class_property_set_description(oc, "aia-guests", str); + } + object_class_property_add(oc, "acpi", "OnOffAuto", virt_get_acpi, virt_set_acpi, NULL, NULL); From patchwork Fri Apr 12 07:33:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 788268 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp591292wrm; Fri, 12 Apr 2024 00:37:17 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX19U/+pV6t5DIUM777aU/LenarFVV3PcSv7LhKisAhHNR/wV+2iceWgke6jH/oyZRrFrb0WwWi2enHjdAqWGVT X-Google-Smtp-Source: AGHT+IFLeaNqRobNFMVpVnoUrnrsFmMGLk7HrcrGiswG3HEOntOHCFEETboXRdcR3IEzlVR8KvpK X-Received: by 2002:a05:620a:47ed:b0:78d:436e:f0af with SMTP id du45-20020a05620a47ed00b0078d436ef0afmr1931514qkb.58.1712907437050; Fri, 12 Apr 2024 00:37:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712907437; cv=none; d=google.com; s=arc-20160816; b=nogWxtM3tZxa/UPwFVONVpohFHHDLF2cKxl84hAkYNlAldXIbP03SuVXqM9U5JUgCE S2j6599JD7UqYhTvSMF/889MinH4orQkg6ThDE5u7bbXosN7kA5buKKIkX9+7Xcx1Oc4 Pe/iDJCKIYyz7JAccG6AkZej/wHhZCVzLQZppfT3f9o149IqaZjgsrewphawRFX8W8kR /FZt4fP91jsHiTLsBqPDp7/3IlxL8kSXukJCadWknU5izwWBGL0R43KixXthxhEHeQbn LgTJfj6zwoOx6aJLUd6QAd9W+78+NTuHyLnKHDG/kKi/iDw9HGOEH65zdLsNTBhgLj+8 rSnQ== 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=qYC/ppUfzbE2OTFde4QzYfLBrlyxo0ZotFcSEeLzOeA=; fh=XWTD8Z9WAMjh+M8BxQj8k30uAZD5B0T9z1nl1AeO1vA=; b=V8qzXqtIgLIKpdgJaimz8YUTrG2jgobp+oo4RADY2ZJ6MCexyAJeEFDoTGSQn+HhtO 6H/RwJzJwY/qTlLxV8nyGFVx1wvZWeX2iHWiUCo5MrGjBQdjPOEsHNDWC2CWDESlhWL6 qPyM3W8rOdfEm5fRaW+t1yhs3CS7UojYsNa0oFCxYEgZPaBg+jcxnWgE1MA7BZvbTYo9 lmbynSSFi4g5PXfKvJEHqST6sUfEU0NJPRPV70nUIfwIHKl/9zb6JUVk29mPN4T0UUOb i7k2UHDOspNAl9rShCFUyoV0J3qH/3E1spzzzj5P2deZAcfjwkdYqoB24NX08JW/Bs43 QJVA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=E9qaUeph; 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 u1-20020a05620a430100b0078a04c6a962si3390934qko.735.2024.04.12.00.37.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 12 Apr 2024 00:37: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=E9qaUeph; 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 1rvBQP-00076p-Eh; Fri, 12 Apr 2024 03:34:17 -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 1rvBQM-00075t-0K for qemu-devel@nongnu.org; Fri, 12 Apr 2024 03:34:15 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rvBQJ-0007Di-5Y for qemu-devel@nongnu.org; Fri, 12 Apr 2024 03:34:13 -0400 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1e424bd30fbso5372505ad.0 for ; Fri, 12 Apr 2024 00:34:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712907248; x=1713512048; 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=qYC/ppUfzbE2OTFde4QzYfLBrlyxo0ZotFcSEeLzOeA=; b=E9qaUephsaRJywbRSBnjfLIYMfTX8068vuSeuVDnoL6h5cbdSB2HlVBIXk1ElXsZ1w Kh1CWxeH2GFs89QTCFwzup+NSgEaNPjjhu+yYheHX9oOXNXlFDwrfUJF87lxGnyCxDWT kHFJnvAQ7lEpqKduizTQA61v41gxMDnqC/naoSGTJwY8yYKNVlI6/kPLBdbzqJU+JbuA F6/GAlnFmfzTvTboyj+zA+78LpMbsIPQtguyaRk20lNcVvigRbLPdo66NtzalYccXJRv 7MZSts1aUeDSmiQHr1H/Eg2BvYLbHgaFDZ+tl0JorODKTNraDFLSYbwtfaG/G0vywT+v LTSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712907248; x=1713512048; 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=qYC/ppUfzbE2OTFde4QzYfLBrlyxo0ZotFcSEeLzOeA=; b=o0Vyef+86dVdDiGtnH56r7xgjAuV+4/LLZtiZ6f2Gajuz3xkNz1gkXDi7bGr2lCsHo fmqsGLyDLa2E0TXSGM1fmtgauZ9TbTfl2Jaxou+p6F6qaBHdH6In37Qqikz+UPyHVz5G +xjvp7WsIYtdMyYtzQPyY85pymJ5bEiEbpeRITwF9OsUPpP1YKAtg72yfjPjJatfEap3 EzZfsS3ZAPePQ1wEDjhnVpNfaL/260DhkXsh75o1fjV1nFWknb8R0vox6b2OuMo+e4e1 +oveI3SxqSqx1TEaq0mqCyusv1qVbJol7+dQHB1NGY6l1hi2FO6X512d/kOxZuUVDAnT razQ== X-Gm-Message-State: AOJu0Yz+9KswDaSAFO0cNX7Ji2W4SsXYBRheb82grzfST5t4fGTDz1fi dwHeLwiaEsZJmiGGewl++XLJ6VPhPbf23W1AfnQyTz6jl4g3g6SmaX3OHNHbHud08cIpLokR6zX P X-Received: by 2002:a17:903:230b:b0:1e2:9676:c326 with SMTP id d11-20020a170903230b00b001e29676c326mr2221309plh.29.1712907248262; Fri, 12 Apr 2024 00:34:08 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id e5-20020a17090301c500b001e556734814sm2206099plh.134.2024.04.12.00.34.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 00:34:07 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell Subject: [PATCH v3 26/27] target/arm: Replace sprintf() by snprintf() Date: Fri, 12 Apr 2024 00:33:45 -0700 Message-Id: <20240412073346.458116-27-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240412073346.458116-1-richard.henderson@linaro.org> References: <20240412073346.458116-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::636; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x636.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 From: Philippe Mathieu-Daudé sprintf() is deprecated on Darwin since macOS 13.0 / XCode 14.1, resulting in painful developper experience. Use snprintf() instead. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Reviewed-by: Peter Maydell Message-Id: <20240411104340.6617-9-philmd@linaro.org> Signed-off-by: Richard Henderson --- target/arm/cpu64.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index 985b1efe16..f0f4fe6714 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -433,7 +433,7 @@ void aarch64_add_sve_properties(Object *obj) for (vq = 1; vq <= ARM_MAX_VQ; ++vq) { char name[8]; - sprintf(name, "sve%d", vq * 128); + snprintf(name, sizeof(name), "sve%d", vq * 128); object_property_add(obj, name, "bool", cpu_arm_get_vq, cpu_arm_set_vq, NULL, &cpu->sve_vq); } @@ -458,7 +458,7 @@ void aarch64_add_sme_properties(Object *obj) for (vq = 1; vq <= ARM_MAX_VQ; vq <<= 1) { char name[8]; - sprintf(name, "sme%d", vq * 128); + snprintf(name, sizeof(name), "sme%d", vq * 128); object_property_add(obj, name, "bool", cpu_arm_get_vq, cpu_arm_set_vq, NULL, &cpu->sme_vq); } From patchwork Fri Apr 12 07:33:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 788266 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp591258wrm; Fri, 12 Apr 2024 00:37:11 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX6wxiIwPKW7gH+ACE6FyX6t8DLO5AZJJ2/7FA8oElQWbBcc30YBj+eCT46LPDD1sFhVO9/Tm42HeWc9Fhco5wR X-Google-Smtp-Source: AGHT+IEdolfvSE9ZeSDSaIhIYUnP9d9JU6abeY7z916Ap1RK+RO9NJXUoH2UC2e2/XE8PHwoyPP4 X-Received: by 2002:ac8:57d2:0:b0:434:c13b:7b4a with SMTP id w18-20020ac857d2000000b00434c13b7b4amr2204639qta.32.1712907430922; Fri, 12 Apr 2024 00:37:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712907430; cv=none; d=google.com; s=arc-20160816; b=Y1Fddm9U0sSvucSzD90wLe3KSTlmpgdToLS7tiv1PLDER581rrEuVGG/JqA0dP0e36 VeY/uF1ER6KaVv7De+et5tQ6TkulpEtdoYtU0xvwiIlbvRQ8jQZQqRWf9QCfx/WMCRzm Q8mVL1Jyu07v8lyRONrJt44mLxwZSgM08GtQD5VxeKmC2A9pzuLvdahNIlIz81iSloE9 cVqJ8LAOeZjkdiqLMyxcJqCLQyGebOzCGsgBc+bhwYEkS+f3TkVlgCFTMJnV56hzC56F V/4fDcwwIZ2vc7n1+nf5s+kLiuaKQTXiJJWAdg5SSNJSfBlFWPHZ0JxVROGP1uzUEBrH rI7A== 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:to:from :dkim-signature; bh=3QxLZpCYn/H6Te2A9HVNEOscia45z8pGQiv2WcFZT0s=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=SYwlNys6Td5KU3GsT3TCPz9s910bAVLCfV798Bu0GNKmJsF34Zhud02+ouPXLQtZsZ BGW2+X+GEltTlhkzMJvSq+Z2qn0j+0ey40zs7BrZltWGygSDa6MMzbn9Dgeysa1cFFSX WOWklbYvY7Dl0Au5BJmpCY1ZiA5FTRK0C9xi3DWBk85qlv5HISIXNqIUFqF5dTxLoESm twv5fJfIhUZ4gL4a9Glrqx+W/aDWIHCatRTs49rl7TS+Zdof+Ka5xBJEutpEeuPPFvHr iBNxsOYssLwO66j76ZtdnDCpVEBSINpkttaCX22rfY4ejzaZ/wQSjykY9S2D6pK2MC0T DvRw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sqmwV4bc; 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 e13-20020ac8598d000000b004366ce5c326si2539939qte.351.2024.04.12.00.37.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 12 Apr 2024 00:37:10 -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=sqmwV4bc; 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 1rvBQU-00079P-DF; Fri, 12 Apr 2024 03:34:22 -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 1rvBQT-00078Z-7c for qemu-devel@nongnu.org; Fri, 12 Apr 2024 03:34:21 -0400 Received: from mail-pl1-x632.google.com ([2607:f8b0: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 1rvBQJ-0007Dr-5S for qemu-devel@nongnu.org; Fri, 12 Apr 2024 03:34:20 -0400 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1e3f17c64daso5128175ad.3 for ; Fri, 12 Apr 2024 00:34:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712907249; x=1713512049; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=3QxLZpCYn/H6Te2A9HVNEOscia45z8pGQiv2WcFZT0s=; b=sqmwV4bcV2mM3oMSICPtAvruRkJsxnk65pSTxClQmxUHHaRai22N9eQ9LJUT5vwie1 52MGSDVhIRL33nrl52nR5BpV224k+2zShb8eLuNQPdakNotfBRGFz0nz1kuZkRmdwnUI XyKAF3M+r9AbB7TLdVyf16TiQzpvw2RfX1XP0geMZuacpXbTunV6uJIs46cZHkLgEpv2 x30OuoVf1N6AvW4H1B+swjmU+bTTTRAAJygk/agqloXCnOURIZo7shVk43171+un6d1T rdDTzjKygy00fQgwUThsBAhNTGzCk9lnxXPDb4iwn5+owii4NiYVPaCXGQcAOQfWqJAn GxnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712907249; x=1713512049; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3QxLZpCYn/H6Te2A9HVNEOscia45z8pGQiv2WcFZT0s=; b=gO6UitRlUFFPy2Y5kl8KEnYLboqXOCc7slKnVGutn9APgNz0SKuwGtwNozIhGQQN0P JQ6/h7JVkWzwpWD8kZyM0TRlsm7B/TXGREtI4T2unMmhZCCiXllJ5rgkQ+xFDGXKilgc Jj2HFXdFqvsSbLqwwgcHzgoY2g8Za89pM7Yga+Ud6+f1QWBP00VXrfewGExNs0788DkD GgemT+gbhLHpQs8rDhS5W0ufjcaW+deRB5e4VzxuJNU9UyYA+a0i+QhWcAfcMFqQlYYN SmcmR2vm5usMcklGfmKmadoc9h0G0vN8Yi2VVLG1tz1nyaP0S3pA1qL6ouzwCbJrurhz KAnA== X-Gm-Message-State: AOJu0YzJzlDjCJNPEZ5gEd1JqM6exMNEq7gamlQndKOST/e/qsxuoYzg 2Fg5qghuX3jPEjd6/tXstPwPU21/dj2ZJpCWrKpiNI/JIfneapJvXm8e7ORwG/LxLE0ZOSoZYdh 9 X-Received: by 2002:a17:902:7008:b0:1e2:a5b3:e7 with SMTP id y8-20020a170902700800b001e2a5b300e7mr1477387plk.58.1712907249051; Fri, 12 Apr 2024 00:34:09 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id e5-20020a17090301c500b001e556734814sm2206099plh.134.2024.04.12.00.34.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 00:34:08 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 27/27] target/i386/kvm: Improve KVM_EXIT_NOTIFY warnings Date: Fri, 12 Apr 2024 00:33:46 -0700 Message-Id: <20240412073346.458116-28-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240412073346.458116-1-richard.henderson@linaro.org> References: <20240412073346.458116-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-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=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 Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Zhao Liu --- target/i386/kvm/kvm.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index e68cbe9293..1fc809b2f9 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -5275,7 +5275,6 @@ int kvm_arch_handle_exit(CPUState *cs, struct kvm_run *run) uint64_t code; int ret; bool ctx_invalid; - char str[256]; KVMState *state; switch (run->exit_reason) { @@ -5335,15 +5334,16 @@ int kvm_arch_handle_exit(CPUState *cs, struct kvm_run *run) case KVM_EXIT_NOTIFY: ctx_invalid = !!(run->notify.flags & KVM_NOTIFY_CONTEXT_INVALID); state = KVM_STATE(current_accel()); - sprintf(str, "Encounter a notify exit with %svalid context in" - " guest. There can be possible misbehaves in guest." - " Please have a look.", ctx_invalid ? "in" : ""); if (ctx_invalid || state->notify_vmexit == NOTIFY_VMEXIT_OPTION_INTERNAL_ERROR) { - warn_report("KVM internal error: %s", str); + warn_report("KVM internal error: Encountered a notify exit " + "with invalid context in guest."); ret = -1; } else { - warn_report_once("KVM: %s", str); + warn_report_once("KVM: Encounterd a notify exit with valid " + "context in guest. " + "The guest could be misbehaving. " + "Please have a look."); ret = 0; } break;