dm crypt: Slightly simplify crypt_set_keyring_key()
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Sat, 28 Jan 2023 15:43:00 +0000 (16:43 +0100)
committerMike Snitzer <snitzer@kernel.org>
Thu, 2 Feb 2023 19:26:09 +0000 (14:26 -0500)
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, but gcc does already account for
optimizing this pattern thanks to it's fold_builtin_strpbrk().

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
drivers/md/dm-crypt.c

index 2653516..b9c41fd 100644 (file)
@@ -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;