From nobody Sun Jan 4 09:56:19 2026 X-Original-To: dev-commits-src-main@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 4dkXrM4b9Pz6MnX4 for ; Sun, 04 Jan 2026 09:56:19 +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" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4dkXrM2v57z4D5K for ; Sun, 04 Jan 2026 09:56:19 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1767520579; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=fMHw6wv1wsvIEzmmuzVDcvQIIJNsqMGgTtq/s+dgaZo=; b=g/e+yszFgvUiuLi42S4lV75DqpsH1yQLkuwtq3IZpc/XaqBZIZ75XDLYEpBKyUk1XnKoYW R3UTdDLo4pHms3MuRQgYy7CzAAiUQHuf4UtYrQw9F33FA1kIwpGK355skcy//HYY/sIsSM ZIBIPHLG8uuDTQiW0MQ5RMAVV9xjDvLliu0LS41R8NWt9DPHLjIT3T3gQQRnhNGr8IQM8D 5Owc/09ZUi06qc3u3NVPKCxJaKjYpJZWLzzSUvdshN7RjRaX2SACxaGJ7+JFd67z+oBBL5 F9CKNDPG6xGPRbLz+hYgUcAWtUebtPRYUQc8A9eMVxWtNJt75jdb8c280FXINw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1767520579; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=fMHw6wv1wsvIEzmmuzVDcvQIIJNsqMGgTtq/s+dgaZo=; b=g5abnjj8eGlxf4Lj6PzJg+4BUuXSP6XOabOrXB4he1eAR/oF+xHX5PRXNrJw2DyKE3D6fV WNPFKxI6pF+Kt6zE6zplRIg4FY1SbBg+tic9WDnuqJ3p08f+e0VhPR0x4MxonAZAQIa6OR 4z37R105/eScqo/meYD4YZp5i6ypPBjUN7HJKeRpWbPYPWskAbd0XupCbeVS9c2PPtMf1Q hZtcSgrJzUqL3hmxG29whw1h8I0luvjG3uglX+8pGukPfM1MGtR4USDPW3b12EUGL2EbL8 8OKR7jQRKjHjmD7SE2IsZTIoEuIW7zGw9kUMJkc35gfCTK5lXWBfqkCMetolPA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1767520579; a=rsa-sha256; cv=none; b=Sbalpr0nO+gLfye4/RghsXFIKLX1NZfTO63ykgtwsfebnmBsAbodrVQkDSh86Hp8596Q21 vaBkucFCSaXXX0KVwaWAsmHBxmywtu3MLDmJd2K3DJPSBlZEj+T9S+6Cr+pUD+BmqBfZ27 lWNWxcL79dY3F2bI76nspqRCptZugA2ISj/cPrmjxIoEkqRj2RGjO7PPJGd7vEpznWyDzC jBnW57BI6xbP0qyPQFfN0UASw1tGpilGegKtM9umw4wuXIUzu28MIYxjEOZuV9GQLSFPDg NpxS4K9BwuEYJQYZUIvlh0VnctnODjQsS37a0tEFZWhP35pk+z+Q9NJ61qGLGg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4dkXrM25pzzDW8 for ; Sun, 04 Jan 2026 09:56:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id cd56 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sun, 04 Jan 2026 09:56:19 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Jean-=?utf-8?Q?S=C3=A9bast?==?utf-8?Q?ien P=C3=A9?=dron Subject: git: 38d757b6c29c - main - linuxkpi: Avoid trailing whitespaces in lkpi_hex_dump() List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dumbbell X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 38d757b6c29c990de72dc51ac123922d3f095f53 Auto-Submitted: auto-generated Date: Sun, 04 Jan 2026 09:56:19 +0000 Message-Id: <695a3943.cd56.2157529c@gitrepo.freebsd.org> The branch main has been updated by dumbbell: URL: https://cgit.FreeBSD.org/src/commit/?id=38d757b6c29c990de72dc51ac123922d3f095f53 commit 38d757b6c29c990de72dc51ac123922d3f095f53 Author: Jean-Sébastien Pédron AuthorDate: 2025-07-26 15:30:40 +0000 Commit: Jean-Sébastien Pédron CommitDate: 2026-01-04 09:44: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 --- 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; } }