From nobody Thu Aug 01 22:27:18 2024 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 4WZk9M1ctlz5RYyw; Thu, 01 Aug 2024 22:27: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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WZk9L6QwJz4YGh; Thu, 1 Aug 2024 22:27:18 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1722551238; 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=fvw/L8ZQc8tbjkbEK+qeE8+9obEbRkmv0n1cBv18pa4=; b=sYDvSRPsQOAHLfiV/de0r1G3a4CZKaaGdBeltGRbIDW6G3uMPgFlH8Sceg0DZr+HWRgRwh pikA2EN3o2/cNQDrFuST0zszyO+68W+XihXFOYo2UYkIrok+whM9pxm6EhsU0xhbOknHfo QbBBJIkySkSdA6At/ig483kUqzB1RzL4r5wpUz39s6mvBHsbLZvrrDLzljIMHgrSdri2Ih A2AFkq/Eb0WfkiNh+opI3R50q+lgaRgt71jxSvprAxVe7RehOqKeSIdsS1bYPf2Ro2P8UU qWIJNMP25BxZ2PqdrA/KeyazkQ/k65XbrZ0cXrnni2t+e6CWHcOmaUOWBgjm0w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1722551238; a=rsa-sha256; cv=none; b=MwOHV4725AUXpzTj7uOTpNSHsUn3V9v5PnYfkyAOdJP1fZTRx6ctFPh/aYqHl+QRY1sxVk 7k0jaSEHX+SDYlMD53BO8vtUDroGBFo66K+68QEGqppvs6Mr970T9292J/ZWEQmJ0T3i68 B++vc3xo8qKzD18cjBJSluQJgdgpmIEaW3U7ZFq7RAR/HOLedBYvMy7kM1LmDbVZu0VQ6u /+8h143fQNNqI993D7ylsgOnnXmQ2oyP2aURpYGYdrUl+Km78pZSX/gVdUFFxmkI+xFfx0 PFIivUzhAdmw+4JPFGJqLwCswFDWLgTB9QnsqdeonPiBUu3TyvfaQHlmIxl7KQ== 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=1722551238; 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=fvw/L8ZQc8tbjkbEK+qeE8+9obEbRkmv0n1cBv18pa4=; b=lSQR7koaDfSNm//xmx8Uh5xubGDFPmsq1sTlebzL/s7vtTlNG4rYnvl2sUOKNf+AUJ4JA0 4KGN+gLME0XgT+bAsL+2ks/3yYxQlz1QBcq5pf0BUx0ZqaY0YbLzicuzd/nuFjwnEbVtrz Ug2JiJNojS/2JqF96nvxxC35415s7v34Rl6jObtI3dT6hXfLmTCQjig4LNKdV+xFhzL/wU vAZ3wlZ38NBAC7A8sv6CIRCjFe1uSuz6kre/+1iJVPdUf/1y5r+4uhzc1WJSCcLgU8Xq3M xKiZk6+FlL7c0JFGt1Xtx9zixoFGGSE0mC8daH0DnvkECInOCersv9ulFTwtoA== 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 4WZk9L5jstz12nl; Thu, 1 Aug 2024 22:27:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 471MRIXD026755; Thu, 1 Aug 2024 22:27:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 471MRIgW026752; Thu, 1 Aug 2024 22:27:18 GMT (envelope-from git) Date: Thu, 1 Aug 2024 22:27:18 GMT Message-Id: <202408012227.471MRIgW026752@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vladimir Kondratyev Subject: git: 9319e47c1ab5 - stable/14 - LinuxKPI: Add strnchr function 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: wulf X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 9319e47c1ab562d577d4359599aecb80a3dd7dbf Auto-Submitted: auto-generated The branch stable/14 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=9319e47c1ab562d577d4359599aecb80a3dd7dbf commit 9319e47c1ab562d577d4359599aecb80a3dd7dbf Author: Vladimir Kondratyev AuthorDate: 2024-04-08 06:47:42 +0000 Commit: Vladimir Kondratyev CommitDate: 2024-08-01 21:09:37 +0000 LinuxKPI: Add strnchr function strnchr() finds a character in a length limited string. Sponsored by: Serenity CyberSecurity, LLC Reviewed by: emaste MFC after: 1 month (cherry picked from commit 19703887666da09c79c571bc78f0923bae62be91) --- sys/compat/linuxkpi/common/include/linux/string.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/string.h b/sys/compat/linuxkpi/common/include/linux/string.h index 9302c95e8636..1fae23ad902a 100644 --- a/sys/compat/linuxkpi/common/include/linux/string.h +++ b/sys/compat/linuxkpi/common/include/linux/string.h @@ -226,6 +226,21 @@ strscpy_pad(char* dst, const char* src, size_t len) return (strscpy(dst, src, len)); } +static inline char * +strnchr(const char *cp, size_t n, int ch) +{ + char *p; + + for (p = __DECONST(char *, cp); n--; ++p) { + if (*p == ch) + return (p); + if (*p == '\0') + break; + } + + return (NULL); +} + static inline void * memset32(uint32_t *b, uint32_t c, size_t len) {