From patchwork Thu Apr 11 10:15:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 787948 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp149974wrm; Thu, 11 Apr 2024 03:21:09 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXHjifcEhG1Vk0fsAaJIzrlahD2ZS5GNi9Ntp4WKT6b9/D4gyZF6A88ujy6PDPY7ORtDQsVfBNA0BCqD1deDYQo X-Google-Smtp-Source: AGHT+IEP4vsk3LIKZIUaeylLNRyPs/M6crd3HALRkZ2pX0rtXfEpY2Ncznc/IodaG9t9CBbE5UfN X-Received: by 2002:a05:620a:172a:b0:78d:4fee:62d7 with SMTP id az42-20020a05620a172a00b0078d4fee62d7mr7037493qkb.9.1712830869040; Thu, 11 Apr 2024 03:21:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712830869; cv=none; d=google.com; s=arc-20160816; b=Cfnk57p/iT0mV2l0MSUUy87M6anO6lf2G3WK0/lsKrXf1sTem1jJXm7Z1lrtpZu2Cl VbDWyUbqBitUg9/r1w3A7nUFEZjT94dHDm6RngOD3EZ1/G2Qe08oqnrhWorm3neTg2Hn lGKsuN6TQGecOFmHFb8RYX4dSUKWwken+semLNEMhfHqOdKKsWjc2kLll0Dwj1/v8vL4 m+20BDAIFCHghk2w/eGac+lmG7ab9v8IFK0tkoggK2j24vasbnLfqxawaoQH6srdXruZ NoUuxR/mZD6FFn5uAJ2Q+dB7sTmnL1oQU92qCk5ie3ZhXTqaKrpVDN6wcI8QusCNF2/x aZFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=F1NpFpUrBWuL7lYE+0KLDn2ZH8pFKE5VoepA/3Vy6uc=; fh=wiz1UHo9SeP7cKsyv7qV5qfZpy+eOFaJKdMduwsqX+g=; b=rsnONjtO2jnudaizA2cTwFYPLOVPjD/KgO5eE5OxNB07+at4qMlVXtRyAMiyVc4XKL TSeLJ3FpCB1eiVwEDhXKEQAjzGtD8HjjCAq43UzudAXCxNRfg7ALzzzfrEP16MdMZfMe sC1hixybtcUu65ukBL6BwzSuM+cifsUosve44Y9wJmhPmEWKu/Jq0TpOzOhEB2A4arNH sPQMrTe3pYMN/jRTvWgbzHDDS89o7Adcy1hMBjz45CO2dtdnEJ5lfBxdKoE4+MRYmOMk jJ5Pv4tFOvnKO1C8lfznsB7kOUhpyEQpJhN0fp2Ql7uqGK3bwB36+mdMx6EcdTNEIkxi 8H/w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bqWxbHYm; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id dt46-20020a05620a47ae00b0078ec4858ad7si485990qkb.670.2024.04.11.03.21.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 11 Apr 2024 03:21:09 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bqWxbHYm; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rurUt-00065k-EZ; Thu, 11 Apr 2024 06:17:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rurU8-0005Ig-GL for qemu-devel@nongnu.org; Thu, 11 Apr 2024 06:16:49 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rurTz-0007X5-JE for qemu-devel@nongnu.org; Thu, 11 Apr 2024 06:16:48 -0400 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-343f62d8124so4196147f8f.2 for ; Thu, 11 Apr 2024 03:16:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712830596; x=1713435396; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=F1NpFpUrBWuL7lYE+0KLDn2ZH8pFKE5VoepA/3Vy6uc=; b=bqWxbHYmOd1JWL1B1rM2r0OISujofCgTs0ans5zEtEhsPecQWJIKbbMRPRK2F2pRdl VwmcwGkGMw8LJTs/WoUfc9A9KgtBoeMifr6GaRJVmdK5toE2UsjbUkowam/3nTXUvTw2 MK2Jy+eWMMahZi9f32Ataaq87sGEN60EzyJssIdlt0vfjzJa2wQtfM3tHeUY1wXBmfRG R4j0NIqf5Vt8UhyKFCYRqlxy9kZGnIMTDHfVFMlXe98H0pfAYr72huj/L5wAmzykiyxL ky8FCdKOd4+AWXoUKWcA35GHwZWUQGromgyxsUtEHYsH84hzOTHS+dQ+X0HKAJlXXDDh sirQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712830596; x=1713435396; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=F1NpFpUrBWuL7lYE+0KLDn2ZH8pFKE5VoepA/3Vy6uc=; b=XPsda1wrZn7tHQKIwdYD3cymh5oTosWEUPbCGHQPrgxJAdD6LUtYi/Z1AGC15WcAzz LnIdwn9ies/NfpvEPzU8w4mY6eBllBgJmbze+nfGVUIcJHwRn26OglOJZdOrPBWIP/D/ PZGQoCmNLHkwtgS3KnyTE0It/zGaF0ULE0C0N6CfSz3E+xqUlG+wap6U+q2dRIXWeKFh GOCF950CxBjhvkC/V2pVFWP9VvYLauZMhB67fAkabFJlNpsPI4vssshCmjxAC1pmoBuK Usgo6bxeCIXJmTRWVaMgAW5mZa6ZNOQR6GFPdowXbKZtMCgdUZc1D1yXHpfQ0mQWtqWX m1Jw== X-Gm-Message-State: AOJu0YzZ1zHi4DgpM0hgM6Ur56Hb5OFZ90ymvjPNePykE+/hko5jYkEb RsYzJArhCsunALJVGQ6gsbz+uqzV45J1D/dsJ2MqDi3YUur8Vgke6c1QRn8eRNVP034JjOgTZIM f6rk= X-Received: by 2002:a5d:5609:0:b0:346:9903:d10f with SMTP id l9-20020a5d5609000000b003469903d10fmr1969474wrv.12.1712830596342; Thu, 11 Apr 2024 03:16:36 -0700 (PDT) Received: from localhost.localdomain (137.red-88-29-174.dynamicip.rima-tde.net. [88.29.174.137]) by smtp.gmail.com with ESMTPSA id bl40-20020adfe268000000b00346d886f3d8sm318488wrb.16.2024.04.11.03.16.35 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 11 Apr 2024 03:16:35 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-block@nongnu.org, qemu-ppc@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" Subject: [PATCH v2 07/13] util/hexdump: Rename @offset argument in qemu_hexdump_line() Date: Thu, 11 Apr 2024 12:15:43 +0200 Message-ID: <20240411101550.99392-8-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240411101550.99392-1-philmd@linaro.org> References: <20240411101550.99392-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=philmd@linaro.org; helo=mail-wr1-x433.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org @offset argument is more descriptive than @b. Inverse @bufptr <-> @offset arguments order. Document qemu_hexdump_line(). Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- include/qemu/cutils.h | 11 +++++++++-- hw/virtio/vhost-vdpa.c | 8 ++++---- util/hexdump.c | 16 ++++++++-------- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/include/qemu/cutils.h b/include/qemu/cutils.h index 92c927a6a3..70ca4b876b 100644 --- a/include/qemu/cutils.h +++ b/include/qemu/cutils.h @@ -252,12 +252,19 @@ static inline const char *yes_no(bool b) */ int parse_debug_env(const char *name, int max, int initial); -/* +/** + * qemu_hexdump_line: + * @line: Buffer to be filled by the hexadecimal/ASCII dump + * @bufptr: Buffer to dump + * @offset: Offset within @bufptr to start the dump + * @len: Length of the bytes do dump + * @ascii: Replace non-ASCII characters by the dot symbol + * * Hexdump a line of a byte buffer into a hexadecimal/ASCII buffer */ #define QEMU_HEXDUMP_LINE_BYTES 16 /* Number of bytes to dump */ #define QEMU_HEXDUMP_LINE_LEN 75 /* Number of characters in line */ -void qemu_hexdump_line(char *line, unsigned int b, const void *bufptr, +void qemu_hexdump_line(char *line, const void *bufptr, unsigned offset, unsigned int len, bool ascii); /* diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index e827b9175f..cf7cfa3f16 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -941,12 +941,12 @@ static int vhost_vdpa_set_config_call(struct vhost_dev *dev, static void vhost_vdpa_dump_config(struct vhost_dev *dev, const uint8_t *config, uint32_t config_len) { - int b, len; + int ofs, len; char line[QEMU_HEXDUMP_LINE_LEN]; - for (b = 0; b < config_len; b += 16) { - len = config_len - b; - qemu_hexdump_line(line, b, config, len, false); + for (ofs = 0; ofs < config_len; ofs += 16) { + len = config_len - ofs; + qemu_hexdump_line(line, config, ofs, len, false); trace_vhost_vdpa_dump_config(dev, line); } } diff --git a/util/hexdump.c b/util/hexdump.c index 9921114b3c..469083d8c0 100644 --- a/util/hexdump.c +++ b/util/hexdump.c @@ -16,7 +16,7 @@ #include "qemu/osdep.h" #include "qemu/cutils.h" -void qemu_hexdump_line(char *line, unsigned int b, const void *bufptr, +void qemu_hexdump_line(char *line, const void *bufptr, unsigned offset, unsigned int len, bool ascii) { const char *buf = bufptr; @@ -26,13 +26,13 @@ void qemu_hexdump_line(char *line, unsigned int b, const void *bufptr, len = QEMU_HEXDUMP_LINE_BYTES; } - line += snprintf(line, 6, "%04x:", b); + line += snprintf(line, 6, "%04x:", offset); for (i = 0; i < QEMU_HEXDUMP_LINE_BYTES; i++) { if ((i % 4) == 0) { *line++ = ' '; } if (i < len) { - line += sprintf(line, " %02x", (unsigned char)buf[b + i]); + line += sprintf(line, " %02x", (unsigned char)buf[offset + i]); } else { line += sprintf(line, " "); } @@ -40,7 +40,7 @@ void qemu_hexdump_line(char *line, unsigned int b, const void *bufptr, if (ascii) { *line++ = ' '; for (i = 0; i < len; i++) { - c = buf[b + i]; + c = buf[offset + i]; if (c < ' ' || c > '~') { c = '.'; } @@ -53,12 +53,12 @@ void qemu_hexdump_line(char *line, unsigned int b, const void *bufptr, void qemu_hexdump(FILE *fp, const char *prefix, const void *bufptr, size_t size) { - unsigned int b, len; + unsigned int ofs, len; char line[QEMU_HEXDUMP_LINE_LEN]; - for (b = 0; b < size; b += QEMU_HEXDUMP_LINE_BYTES) { - len = size - b; - qemu_hexdump_line(line, b, bufptr, len, true); + for (ofs = 0; ofs < size; ofs += QEMU_HEXDUMP_LINE_BYTES) { + len = size - ofs; + qemu_hexdump_line(line, bufptr, ofs, len, true); fprintf(fp, "%s: %s\n", prefix, line); }