From patchwork Thu Jan 5 19:02:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alejandro Colomar X-Patchwork-Id: 62753 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6F1243858C30 for ; Thu, 5 Jan 2023 19:03:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6F1243858C30 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1672945427; bh=NxPeAIxS09WE50B11Am9pyYt/NXTZqDeqCWqmVQsHN4=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=a+klbR2zHowtAyjEJsmWMkMal4eJjpsyFwfdpPcfPdJBCMakF2a+tMBAHJt4r4YgL k9Zms2F7A1K50tLJDv16qWFzvyN4Gv07NNPCgnrIkoHBL2ZLcKWvzhHf9tgo4k08bh U4Tbkai+bX9PM4oGKsM5n0WyryRRHYbbvTBFUM9A= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by sourceware.org (Postfix) with ESMTPS id 1CAB13858D28 for ; Thu, 5 Jan 2023 19:03:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1CAB13858D28 Received: by mail-wm1-x330.google.com with SMTP id ay2-20020a05600c1e0200b003d22e3e796dso2093465wmb.0 for ; Thu, 05 Jan 2023 11:03:22 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=NxPeAIxS09WE50B11Am9pyYt/NXTZqDeqCWqmVQsHN4=; b=agco+M5nGmZX9VAURyOZSapxZrhUY5dO4tsO806xtOzZ4e6HGw8d8t3z4Vyj9I2C6x MA6wm514NmD+F/x/1TJdBxZvW8adeOQSIp543M/oK2ylVGDJ16Bb4f5qZXVtO6ezQeC2 oCTblwodrNXxdOYHWNGtz7Rf9jaHC2KH62zhLmxT8ZqwQrT5tPXC0LWAgRSgHJxsMY4K leghaQqcvENCvdDoAwmOMt1r8AsLVLxr5JVWzNOLYqiS/Zoeg4wmvP5TgCRL1GyP4Sy6 ECq8p3jkI2uRW7t0+9PyNmSOlEKUebqdrIn5xGfNfIL45dLLBCax1j/0v3rJpC35NQNR zL+w== X-Gm-Message-State: AFqh2kqn6vEx3y7PDezqHY+Zz/A7IwSidgxNxYMfDRBIbzrxgjRE+mUe +QaJhfotRlT+hmPDXvNJD/4tb2dfJvU= X-Google-Smtp-Source: AMrXdXtE0Ao6yg/3yO7aMGMuOGGrM/X1BkR1a5ud+FolA3zEwP7pcdDE1HRk/PRjwkvv87tX6kJZFw== X-Received: by 2002:a7b:ce06:0:b0:3cf:a483:3100 with SMTP id m6-20020a7bce06000000b003cfa4833100mr37012012wmc.3.1672945400884; Thu, 05 Jan 2023 11:03:20 -0800 (PST) Received: from asus5775.alejandro-colomar.es ([170.253.36.171]) by smtp.googlemail.com with ESMTPSA id r7-20020a05600c458700b003c6b7f5567csm8837322wmo.0.2023.01.05.11.03.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Jan 2023 11:03:20 -0800 (PST) X-Google-Original-From: Alejandro Colomar To: linux-man@vger.kernel.org Cc: Alejandro Colomar , libc-alpha@sourceware.org, Wilco Dijkstra Subject: [PATCH] memchr.3: Deprecate rawmemchr(3) Date: Thu, 5 Jan 2023 20:02:47 +0100 Message-Id: <20230105190246.17819-1-alx@kernel.org> X-Mailer: git-send-email 2.39.0 MIME-Version: 1.0 X-Spam-Status: No, score=-10.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Alejandro Colomar via Libc-alpha From: Alejandro Colomar Reply-To: Alejandro Colomar Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" It is not optimized, and it calls either strlen(3) or memchr(3), so the caller can do it directly, and it will be better. Suggested-by: Wilco Dijkstra Signed-off-by: Alejandro Colomar --- man3/memchr.3 | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/man3/memchr.3 b/man3/memchr.3 index 68873964e..e03001bec 100644 --- a/man3/memchr.3 +++ b/man3/memchr.3 @@ -22,7 +22,8 @@ .SH SYNOPSIS .PP .BI "void *memchr(const void " s [. n "], int " c ", size_t " n ); .BI "void *memrchr(const void " s [. n "], int " c ", size_t " n ); -.BI "void *rawmemchr(const void " s [. n "], int " c ); +.PP +.BI "[[deprecated]] void *rawmemchr(const void " s [. n "], int " c ); .fi .PP .RS -4 @@ -66,26 +67,21 @@ .SH DESCRIPTION The .BR rawmemchr () function is similar to -.BR memchr (): -it assumes (i.e., the programmer knows for certain) +.BR memchr (), +but it assumes +(i.e., the programmer knows for certain) that an instance of .I c lies somewhere in the memory area starting at the location pointed to by -.IR s , -and so performs an optimized search for -.I c -(i.e., no use of a count argument to limit the range of the search). +.IR s . If an instance of .I c -is not found, the results are unpredictable. -The following call is a fast means of locating a string's -terminating null byte: -.PP -.in +4n -.EX -char *p = rawmemchr(s,\ \(aq\e0\(aq); -.EE -.in +is not found, the behavior is undefined. +Use either +.BR strlen (3) +or +.BR memchr (3) +instead. .SH RETURN VALUE The .BR memchr ()