From nobody Mon Nov 07 12:51:23 2022 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 4N5WLz3J4nz4gvjL; Mon, 7 Nov 2022 12:51:23 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4N5WLz2nMXz3hrQ; Mon, 7 Nov 2022 12:51:23 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1667825483; 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=iZkQ4+3UuYVnC2M1yE5cSzm+Fqe+8sdSid0DbAoThUg=; b=PIK8nNHQIPRPLQxSJPW0qk0KfUD9DnUqbcPxLwZ/bpiwbUuYOA06h4DJG4g4+LIxOhLXYq 0Wy7Yh6NAQNhi3XAduxt9hFwwXNodD4hahCYlU73eeOD/dVZqt3BXS2XbDvcJFlmtAPTfV RQwmjVwtDS25SKE+B8INpKiooZHMEJ3i4C3n1s8D+Q2nPwvNqO4Q6wTa7Qk1eDWOCBWCOs QZq8HdAIPCN5op293MJyRnxs18IZ2q8OK19PYxTIJRaPfXJCndINLpevU8cTDfPqtTx9ht JW+zbqbFAowl4V5PHxExBL99fxoJV42QZQ0wbeoqLHmjEhoWTLpdTsLW+V5bdA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4N5WLz1rvzz12Wn; Mon, 7 Nov 2022 12:51:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 2A7CpNuC018903; Mon, 7 Nov 2022 12:51:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2A7CpNwR018902; Mon, 7 Nov 2022 12:51:23 GMT (envelope-from git) Date: Mon, 7 Nov 2022 12:51:23 GMT Message-Id: <202211071251.2A7CpNwR018902@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: 6a647ae51409 - main - LinuxKPI: string.h implement memcpy_and_pad() 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: 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/main X-Git-Reftype: branch X-Git-Commit: 6a647ae51409cd56cc4a78d0a64ba3ff3aa3aac0 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1667825483; 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=iZkQ4+3UuYVnC2M1yE5cSzm+Fqe+8sdSid0DbAoThUg=; b=FXKK9mA60yNqhfRYdJf5g+JdGQwKRTSAhtb3tCynaT3LadkqJh3h+KVAVHdINct4XELfvh Wpw4FXrDHxnQv274xDiuk6CsMJ76LSL9+MXMRfiFdQ0EX6XYJr2t4t2g69R4qMBE8iWWON hmaARLaxQk92hbZDopyX3S/DWwe+kKckfS7rI32hqTMDas+fxE/ggxQQ3LIfGsSl2cItsJ g7qekn9Am4OwB+O/+75C0hNz7bIhmCqGntke2AExhxR5ySQQZvM32SueYXamxYBB7DYlxB fkDh6G1UtFZy0ORPh+pr5yGfwe3KpsslD3WEM1t/O5LVympS/iUFCMOB7j9B7g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1667825483; a=rsa-sha256; cv=none; b=JPHUrVWc41JlLHWV6jZ8FLGi4M0zs2w2F69V+RLqCGDueGDOCwJewF7Aa8g6l/cItf7kgb qzzerxy5Sja/YSKQYdP12vmFCGsUFkGiS1tz9oi/+UDeLdcyWlxXtpmRow/4T6mOmtDgga FdPyg098ityG8u6XVxinNtMNRkYyDIfJDhowYpIeI9/agUyAZ32d1lte37oPP0hqO7fSpL oZwO2siDFtVPXkloGjjREPwwtqhH7HJUq+D4lOfN476HBIeKSIGpb3aL5Do0WhsGTFCqMY rzJl7m2ZwTRzmb9gY0SZTjhXGsuvNByb0+90mkV5L6kCIxkj2hM/v9uO5G8vgQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=6a647ae51409cd56cc4a78d0a64ba3ff3aa3aac0 commit 6a647ae51409cd56cc4a78d0a64ba3ff3aa3aac0 Author: Bjoern A. Zeeb AuthorDate: 2022-10-31 22:17:00 +0000 Commit: Bjoern A. Zeeb CommitDate: 2022-11-07 12:49:01 +0000 LinuxKPI: string.h implement memcpy_and_pad() Add a memcpy variant which takes length of source and destination buffers and a padding character in case there is free space in the destination. This is used by a wireless driver. MFC after: 3 days Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D37226 --- sys/compat/linuxkpi/common/include/linux/string.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/string.h b/sys/compat/linuxkpi/common/include/linux/string.h index 52110feda6df..36f27a385d65 100644 --- a/sys/compat/linuxkpi/common/include/linux/string.h +++ b/sys/compat/linuxkpi/common/include/linux/string.h @@ -236,4 +236,17 @@ memset_p(void **p, void *v, size_t n) return (memset64((uint64_t *)p, (uintptr_t)v, n)); } +static inline void +memcpy_and_pad(void *dst, size_t dstlen, const void *src, size_t len, int ch) +{ + + if (len >= dstlen) { + memcpy(dst, src, dstlen); + } else { + memcpy(dst, src, len); + /* Pad with given padding character. */ + memset((char *)dst + len, ch, dstlen - len); + } +} + #endif /* _LINUXKPI_LINUX_STRING_H_ */