string_utils: convert to strequal()

parent d2cfd2ba
...@@ -156,7 +156,7 @@ char *lxc_string_replace(const char *needle, const char *replacement, ...@@ -156,7 +156,7 @@ char *lxc_string_replace(const char *needle, const char *replacement,
bool lxc_string_in_array(const char *needle, const char **haystack) bool lxc_string_in_array(const char *needle, const char **haystack)
{ {
for (; haystack && *haystack; haystack++) for (; haystack && *haystack; haystack++)
if (!strcmp(needle, *haystack)) if (strequal(needle, *haystack))
return true; return true;
return false; return false;
...@@ -208,14 +208,14 @@ char **lxc_normalize_path(const char *path) ...@@ -208,14 +208,14 @@ char **lxc_normalize_path(const char *path)
/* resolve '.' and '..' */ /* resolve '.' and '..' */
for (pos = 0; pos < components_len;) { for (pos = 0; pos < components_len;) {
if (!strcmp(components[pos], ".") || if (strequal(components[pos], ".") ||
(!strcmp(components[pos], "..") && pos == 0)) { (strequal(components[pos], "..") && pos == 0)) {
/* eat this element */ /* eat this element */
free(components[pos]); free(components[pos]);
memmove(&components[pos], &components[pos + 1], memmove(&components[pos], &components[pos + 1],
sizeof(char *) * (components_len - pos)); sizeof(char *) * (components_len - pos));
components_len--; components_len--;
} else if (!strcmp(components[pos], "..")) { } else if (strequal(components[pos], "..")) {
/* eat this and the previous element */ /* eat this and the previous element */
free(components[pos - 1]); free(components[pos - 1]);
free(components[pos]); free(components[pos]);
...@@ -312,7 +312,7 @@ bool lxc_string_in_list(const char *needle, const char *haystack, char _sep) ...@@ -312,7 +312,7 @@ bool lxc_string_in_list(const char *needle, const char *haystack, char _sep)
str = must_copy_string(haystack); str = must_copy_string(haystack);
lxc_iterate_parts(token, str, sep) lxc_iterate_parts(token, str, sep)
if (strcmp(needle, token) == 0) if (strequal(needle, token))
return 1; return 1;
return 0; return 0;
...@@ -859,7 +859,7 @@ int parse_byte_size_string(const char *s, int64_t *converted) ...@@ -859,7 +859,7 @@ int parse_byte_size_string(const char *s, int64_t *converted)
char dup[INTTYPE_TO_STRLEN(int64_t)]; char dup[INTTYPE_TO_STRLEN(int64_t)];
char suffix[3] = {0}; char suffix[3] = {0};
if (!s || !strcmp(s, "")) if (!s || strequal(s, ""))
return ret_errno(EINVAL); return ret_errno(EINVAL);
end = stpncpy(dup, s, sizeof(dup) - 1); end = stpncpy(dup, s, sizeof(dup) - 1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment