chiark / gitweb /
tree-wide: make use of memory_startswith() at various places
[elogind.git] / src / libelogind / sd-bus / bus-socket.c
index 04839bada415d544db18f6b290dc8453f0424007..57c5391423edaded64e704672b8a859806e7693f 100644 (file)
@@ -248,16 +248,13 @@ static bool line_equals(const char *s, size_t m, const char *line) {
 }
 
 static bool line_begins(const char *s, size_t m, const char *word) {
-        size_t l;
-
-        l = strlen(word);
-        if (m < l)
-                return false;
+        const char *p;
 
-        if (memcmp(s, word, l) != 0)
+        p = memory_startswith(s, m, word);
+        if (!p)
                 return false;
 
-        return m == l || (m > l && s[l] == ' ');
+        return IN_SET(*p, 0, ' ');
 }
 
 static int verify_anonymous_token(sd_bus *b, const char *p, size_t l) {