lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1422624373-16617-1-git-send-email-linux@rasmusvillemoes.dk>
Date:	Fri, 30 Jan 2015 14:26:13 +0100
From:	Rasmus Villemoes <linux@...musvillemoes.dk>
To:	Alexander Viro <viro@...iv.linux.org.uk>
Cc:	Rasmus Villemoes <linux@...musvillemoes.dk>,
	linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH] fs: Use strchrnul in get_fs_type

Using strchrnul yields smaller code and avoids extra strlen call.

Signed-off-by: Rasmus Villemoes <linux@...musvillemoes.dk>
---
 fs/filesystems.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/filesystems.c b/fs/filesystems.c
index 5797d45a78cb..d56a7bb09afa 100644
--- a/fs/filesystems.c
+++ b/fs/filesystems.c
@@ -271,14 +271,14 @@ static struct file_system_type *__get_fs_type(const char *name, int len)
 struct file_system_type *get_fs_type(const char *name)
 {
 	struct file_system_type *fs;
-	const char *dot = strchr(name, '.');
-	int len = dot ? dot - name : strlen(name);
+	const char *dot = strchrnul(name, '.');
+	int len = dot - name;
 
 	fs = __get_fs_type(name, len);
 	if (!fs && (request_module("fs-%.*s", len, name) == 0))
 		fs = __get_fs_type(name, len);
 
-	if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
+	if (*dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
 		put_filesystem(fs);
 		fs = NULL;
 	}
-- 
2.1.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ