vfs: check userland buffers before reading them.
[haiku.git] / src / system / libroot / posix / string / strcmp.c
blob56e058e2cb58cb20566831d99647a4aa2aaf7b8c
1 /*
2 * Copyright 2008, Axel Dörfler, axeld@pinc-software.de.
3 * Distributed under the terms of the MIT license.
4 */
7 #include <stdbool.h>
8 #include <string.h>
9 #include <SupportDefs.h>
12 #define LACKS_ZERO_BYTE(value) \
13 (((value - 0x01010101) & ~value & 0x80808080) == 0)
15 int
16 strcmp(char const *a, char const *b)
18 while (true) {
19 int cmp = (unsigned char)*a - (unsigned char)*b++;
20 if (cmp != 0 || *a++ == '\0')
21 return cmp;