From patchwork Sat Jan 28 15:43:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 49867 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1400438wrn; Sat, 28 Jan 2023 08:03:26 -0800 (PST) X-Google-Smtp-Source: AMrXdXustyKVyo67Sf5HpoWlrrpIWmWl0YAq/wpyivw4lfLYXoRIe+oqJZIate4LCfkWdkCPk1G7 X-Received: by 2002:a17:907:3e18:b0:84d:3403:f4f2 with SMTP id hp24-20020a1709073e1800b0084d3403f4f2mr59705666ejc.62.1674921806693; Sat, 28 Jan 2023 08:03:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674921806; cv=none; d=google.com; s=arc-20160816; b=wjBp0PScWWJ67WZ6I+AbpZ2U7ix/Nc7xHrZf2WxQ7CfrGJWESGoCNzW47oaI4brCr/ Pp/Fb7f2PUeetPMdO+e9XYkyyR6cbOUuehkICWbnm/t4Ov4kHfrA+DrNOQjvJ3bRO7Yn m57gkZdht5JkiCg84uC2CFFdH5cKbMHaWbWq+7YGB8C6+/WpNRDg2tk9w/9v20f+kFjc xLNUKU2s7uJviC3XP+DdaLzJAYD2iGBLIoyfFPNntsFcDHGauNtRidqhvj8of5JgApli MP67l7p3zyVIPWWwSLUjLOyDRJ1u3K5jm+SWyy9QJaKpSiFxlsTzEuecxW+6q7Ki0HJX 23Ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=Yz7ld7QvAd+6XuhaNOFFSgJwRQudzVBBXWZOTjTja+I=; b=d+41U9t0VXiR842bXNN43W17VOnNzpxeW0Yj5ggQywU+ZqenIArEp0+uadQPOTXvTh OVSDqWONdtd+YwmH80tyAHs6cpq01359jLAGSkL4GH9juhzS9/Z/L5VPgl+G/rjoSR9s 8/07WFBqQNBfl6aKTLAspdr3Zsnjci4Go5clCDigF5t42R0fjOFl6knFU4A4iovTQWBV LagzxiV20x/r4z5EEo40fyW77QwUdfdiSo0ndHORCh+8zgM/4tGTY/V2cq3f3tJhSFjk ZNIR9mR7aKAWn5OH8UdclEzM0kCj3FW7EHYrCr9Yv2J6aAZDi5R7i30hHHklchlJDxDy gt7Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id aa8-20020a170907354800b008775c12ea85si8337383ejc.482.2023.01.28.08.03.03; Sat, 28 Jan 2023 08:03:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234039AbjA1PnR (ORCPT + 99 others); Sat, 28 Jan 2023 10:43:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229811AbjA1PnK (ORCPT ); Sat, 28 Jan 2023 10:43:10 -0500 Received: from smtp.smtpout.orange.fr (smtp-14.smtpout.orange.fr [80.12.242.14]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46B0318B35 for ; Sat, 28 Jan 2023 07:43:08 -0800 (PST) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id LnM9phWDqeUnHLnM9p9nzv; Sat, 28 Jan 2023 16:43:06 +0100 X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sat, 28 Jan 2023 16:43:06 +0100 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH] dm-crypt: Slightly simplify crypt_set_keyring_key() Date: Sat, 28 Jan 2023 16:43:00 +0100 Message-Id: X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756282808329713868?= X-GMAIL-MSGID: =?utf-8?q?1756282808329713868?= Use strchr() instead of strpbrk() when there is only 1 element in the set of characters to look for. This potentially saves a few cycles. Signed-off-by: Christophe JAILLET --- On my machine, the diff of the .s file shows that the generated code is the same: -- drivers/md/dm-crypt.old.s 2023-01-28 16:28:08.968026902 +0100 ++ drivers/md/dm-crypt.s 2023-01-28 16:28:32.056027335 +0100 @@ -17950,7 +17950,7 @@ call __sanitizer_cov_trace_const_cmp1 # testb %bl, %bl # _56 jne .L928 #, -# drivers/md/dm-crypt.c:2490: key_desc = strpbrk(key_string, ":"); +# drivers/md/dm-crypt.c:2490: key_desc = strchr(key_string, ':'); call __sanitizer_cov_trace_pc # movl $58, %esi #, movq %r12, %rdi # key_string, This is done thanks to fold_builtin_strpbrk() in gcc which already transforms such patterns. (https://github.com/gcc-mirror/gcc/blob/master/gcc/builtins.cc#L10238) --- drivers/md/dm-crypt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index 2653516bcdef..b9c41fd42e8a 100644 --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c @@ -2487,7 +2487,7 @@ static int crypt_set_keyring_key(struct crypt_config *cc, const char *key_string } /* look for next ':' separating key_type from key_description */ - key_desc = strpbrk(key_string, ":"); + key_desc = strchr(key_string, ':'); if (!key_desc || key_desc == key_string || !strlen(key_desc + 1)) return -EINVAL;