From nobody Wed Apr 22 21:08:00 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4g1BdY470Gz6bKkv for ; Wed, 22 Apr 2026 21:08:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R13" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4g1BdX6pjWz3jhy for ; Wed, 22 Apr 2026 21:08:00 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1776892081; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=FCMI1NNCITrH6BmRcKVMC0QOU6lm9rnpq5/mTAdlNeQ=; b=EuFnoIJFovRVbXhP+pp9l73Dd5bcRgNqvqFaTziPao1qqAwbQnVQBcIWnHehDGdyu85qOr zzzQaC54MvQ7656rj5n2aTav1ezlHM5qKI/jVoUghA47QyM4GcG8Uw5lmRjzjOayOWrU5P pxvmRRDSmnJ1govZkfiv9WoY8BctpJBzyeNr2P4Zfe6YSoXLK+Lw6Yfni80pMt8SxjQpkf sYllgX40hvRap/eo+BimRJpP9FPu/V1JAynkVkKichNLUNVcPfG8xmA8UQlIhwgVycXKGE i1FCRVQZAScx3y7FxH0Bp8Q5eP/K1bBsi8Z+mVNHC0NH0i48XbiY66rMXYyXwA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1776892081; a=rsa-sha256; cv=none; b=j4zJxJodp6s9amKlWirxbV/FTvzFiDRl6E8W4RI9+/EcYyoDqfkpTQbyyxrr2BnvQ2q/Lv VnPfCYamszICyzDlzBpI4j7+7sFTWHlHvTE5frfPTb12S1iIX5g9aRRUxG+SCXC+IzL+gj uvtUzUMSb75QfrHVtQAV89eKEsIsZcskBpZjQEG+ldewuMcEI28JLGQdliwV7ouehatlj6 APrW5kQCFUZaWU4sILdMj2wnSFDrN2LSjL8wZDDS9N+KII8AInx5lZTx0o5QkbzKI+YMA7 Au4RA+1x54RLzz0VDYmfoOeh3/LF4H6ZvDqfrqMSiAtbt62fYZej34Y+NmzswA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1776892081; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=FCMI1NNCITrH6BmRcKVMC0QOU6lm9rnpq5/mTAdlNeQ=; b=W2s5PahHxhP1inUpkMnUas7+XESkKnDT0m32dBNp3eLYzyDarywXr2J8KNmh7+fn+S2A+R fI4XRA5k7hZDeiNJTCN50/j4ViVqC8qs6GI25kB6yF/+u41FAhpfMvU7OhIXiVghNZ/DUP ZgQohcwpCXwLWj51oKD63bDG5w1d7yG7UIXbvibQ/R7ru9TXZ5Au3YOVFNsRzGs7kzDZDI MIesIvyvH5N1ZmfvozD9LBk1KbTagFxAlxgt5fuaZ+Zk99opayiykmPbyRnCWvBGjibjZg r0usUboOdRRYr1zZh9xMX5XsRweFd9k5Q6iatQVeuDZnTC/OikTpdOQkKtXQMQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4g1BdX2RPCznWc for ; Wed, 22 Apr 2026 21:08:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 275e8 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 22 Apr 2026 21:08:00 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Cc: Jean-=?utf-8?Q?S=C3=A9bast?==?utf-8?Q?ien P=C3=A9?=dron From: Bjoern A. Zeeb Subject: git: c9e8d79da790 - stable/15 - linuxkpi: Avoid trailing whitespaces in lkpi_hex_dump() List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: c9e8d79da7907147215123324c4aea00a00451bd Auto-Submitted: auto-generated Date: Wed, 22 Apr 2026 21:08:00 +0000 Message-Id: <69e938b0.275e8.22db58e6@gitrepo.freebsd.org> The branch stable/15 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=c9e8d79da7907147215123324c4aea00a00451bd commit c9e8d79da7907147215123324c4aea00a00451bd Author: Jean-Sébastien Pédron AuthorDate: 2025-07-26 15:30:40 +0000 Commit: Bjoern A. Zeeb CommitDate: 2026-04-22 20:56:52 +0000 linuxkpi: Avoid trailing whitespaces in lkpi_hex_dump() We use the return value of the callback to track the number of bytes written. We use it to determine if a group of characters should be prepended with a whitespace. This way, we never add a trailing whitespace. We need to pay attention to the return value of the callback: if it is negative, it's an error and we return immediately. Otherwise, we would decrease the number of written bytes and possibly make it negative. Reviewed by: bz, christos Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D51558 (cherry picked from commit 38d757b6c29c990de72dc51ac123922d3f095f53) --- sys/compat/linuxkpi/common/src/linux_compat.c | 66 +++++++++++++++++++++------ 1 file changed, 53 insertions(+), 13 deletions(-) diff --git a/sys/compat/linuxkpi/common/src/linux_compat.c b/sys/compat/linuxkpi/common/src/linux_compat.c index 35430daf311d..03d866260dd9 100644 --- a/sys/compat/linuxkpi/common/src/linux_compat.c +++ b/sys/compat/linuxkpi/common/src/linux_compat.c @@ -1900,47 +1900,87 @@ lkpi_hex_dump(int(*_fpf)(void *, const char *, ...), void *arg1, typedef const struct { uint32_t value; } __packed *print_32p_t; typedef const struct { uint16_t value; } __packed *print_16p_t; const void *buf_old = buf; - int row; + int row, linelen, ret; while (len > 0) { - if (level != NULL) - _fpf(arg1, "%s", level); - if (prefix_str != NULL) - _fpf(arg1, "%s ", prefix_str); + linelen = 0; + if (level != NULL) { + ret = _fpf(arg1, "%s", level); + if (ret < 0) + break; + linelen += ret; + } + if (prefix_str != NULL) { + ret = _fpf( + arg1, "%s%s", linelen ? " " : "", prefix_str); + if (ret < 0) + break; + linelen += ret; + } switch (prefix_type) { case DUMP_PREFIX_ADDRESS: - _fpf(arg1, "[%p] ", buf); + ret = _fpf( + arg1, "%s[%p]", linelen ? " " : "", buf); + if (ret < 0) + return; + linelen += ret; break; case DUMP_PREFIX_OFFSET: - _fpf(arg1, "[%#tx] ", ((const char *)buf - - (const char *)buf_old)); + ret = _fpf( + arg1, "%s[%#tx]", linelen ? " " : "", + ((const char *)buf - (const char *)buf_old)); + if (ret < 0) + return; + linelen += ret; break; default: break; } for (row = 0; row != rowsize; row++) { if (groupsize == 8 && len > 7) { - _fpf(arg1, "%016llx ", ((print_64p_t)buf)->value); + ret = _fpf( + arg1, "%s%016llx", linelen ? " " : "", + ((print_64p_t)buf)->value); + if (ret < 0) + return; + linelen += ret; buf = (const uint8_t *)buf + 8; len -= 8; } else if (groupsize == 4 && len > 3) { - _fpf(arg1, "%08x ", ((print_32p_t)buf)->value); + ret = _fpf( + arg1, "%s%08x", linelen ? " " : "", + ((print_32p_t)buf)->value); + if (ret < 0) + return; + linelen += ret; buf = (const uint8_t *)buf + 4; len -= 4; } else if (groupsize == 2 && len > 1) { - _fpf(arg1, "%04x ", ((print_16p_t)buf)->value); + ret = _fpf( + arg1, "%s%04x", linelen ? " " : "", + ((print_16p_t)buf)->value); + if (ret < 0) + return; + linelen += ret; buf = (const uint8_t *)buf + 2; len -= 2; } else if (len > 0) { - _fpf(arg1, "%02x ", *(const uint8_t *)buf); + ret = _fpf( + arg1, "%s%02x", linelen ? " " : "", + *(const uint8_t *)buf); + if (ret < 0) + return; + linelen += ret; buf = (const uint8_t *)buf + 1; len--; } else { break; } } - _fpf(arg1, "\n"); + ret = _fpf(arg1, "\n"); + if (ret < 0) + break; } }