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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1435743667-11987-4-git-send-email-tomeu.vizoso@collabora.com>
Date:	Wed,  1 Jul 2015 11:40:58 +0200
From:	Tomeu Vizoso <tomeu.vizoso@...labora.com>
To:	linux-kernel@...r.kernel.org
Cc:	Mark Brown <broonie@...nel.org>, linux-acpi@...r.kernel.org,
	dri-devel@...ts.freedesktop.org, linux-fbdev@...r.kernel.org,
	linux-gpio@...r.kernel.org, devicetree@...r.kernel.org,
	linux-pwm@...r.kernel.org, "Rafael J. Wysocki" <rjw@...ysocki.net>,
	alsa-devel@...a-project.org,
	Tomeu Vizoso <tomeu.vizoso@...labora.com>
Subject: [PATCH v2 03/12] string: Introduce strends()

To avoid duplicating code in upcoming patches that will check for
postfixes in strings, add strends().

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@...labora.com>
---

Changes in v2:
- Move strends to string.h

 include/linux/string.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/include/linux/string.h b/include/linux/string.h
index d5dfe3e..4244363 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -146,6 +146,19 @@ static inline bool strstarts(const char *str, const char *prefix)
 	return strncmp(str, prefix, strlen(prefix)) == 0;
 }
 
+/**
+ * strends - does @str end with @postfix?
+ * @str: string to examine
+ * @postfix: postfix to look for
+ */
+static inline bool strends(const char *str, const char *postfix)
+{
+	if (strlen(str) < strlen(postfix))
+		return false;
+
+	return strcmp(str + strlen(str) - strlen(postfix), postfix) == 0;
+}
+
 size_t memweight(const void *ptr, size_t bytes);
 void memzero_explicit(void *s, size_t count);
 
-- 
2.4.1

--
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