Replace some strncmp's with memcmp Signed-off-by: Ran Benita <ran234@gmail.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
diff --git a/src/compose/paths.c b/src/compose/paths.c
index c96d7d2..8deb1dd 100644
--- a/src/compose/paths.c
+++ b/src/compose/paths.c
@@ -115,13 +115,13 @@ resolve_name(const char *filename, enum resolve_name_direction direction,
s++;
if (direction == LEFT_TO_RIGHT) {
- if (left_len == name_len && strncmp(left, name, left_len) == 0) {
+ if (left_len == name_len && memcmp(left, name, left_len) == 0) {
match = strndup(right, right_len);
break;
}
}
else if (direction == RIGHT_TO_LEFT) {
- if (right_len == name_len && strncmp(right, name, right_len) == 0) {
+ if (right_len == name_len && memcmp(right, name, right_len) == 0) {
match = strndup(left, left_len);
break;
}
diff --git a/src/scanner-utils.h b/src/scanner-utils.h
index b60a100..5fdb22a 100644
--- a/src/scanner-utils.h
+++ b/src/scanner-utils.h
@@ -34,13 +34,13 @@ typedef darray(struct sval) darray_sval;
static inline bool
svaleq(struct sval s1, struct sval s2)
{
- return s1.len == s2.len && strncmp(s1.start, s2.start, s1.len) == 0;
+ return s1.len == s2.len && memcmp(s1.start, s2.start, s1.len) == 0;
}
static inline bool
svaleq_prefix(struct sval s1, struct sval s2)
{
- return s1.len <= s2.len && strncmp(s1.start, s2.start, s1.len) == 0;
+ return s1.len <= s2.len && memcmp(s1.start, s2.start, s1.len) == 0;
}
struct scanner {