]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
utils: convert to strequal()
authorChristian Brauner <christian.brauner@ubuntu.com>
Sat, 13 Feb 2021 20:30:50 +0000 (21:30 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Sat, 13 Feb 2021 20:40:28 +0000 (21:40 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/utils.c

index 10a51232c7e87d86793bf80b79e6a1c9275a525a..56a3eeb133593b3388e46440c57c081cc7c55a88 100644 (file)
@@ -80,8 +80,8 @@ static int _recursive_rmdir(const char *dirname, dev_t pdev,
                int rc;
                struct stat mystat;
 
-               if (!strcmp(direntp->d_name, ".") ||
-                   !strcmp(direntp->d_name, ".."))
+               if (strequal(direntp->d_name, ".") ||
+                   strequal(direntp->d_name, ".."))
                        continue;
 
                rc = strnprintf(pathname, sizeof(pathname), "%s/%s", dirname, direntp->d_name);
@@ -91,7 +91,7 @@ static int _recursive_rmdir(const char *dirname, dev_t pdev,
                        continue;
                }
 
-               if (!level && exclude && !strcmp(direntp->d_name, exclude)) {
+               if (!level && exclude && strequal(direntp->d_name, exclude)) {
                        ret = rmdir(pathname);
                        if (ret < 0) {
                                switch (errno) {
@@ -625,7 +625,7 @@ bool is_shared_mountpoint(const char *path)
                        continue;
 
                *slider2 = '\0';
-               if (strcmp(slider1 + 1, path) == 0) {
+               if (strequal(slider1 + 1, path)) {
                        /* This is the path. Is it shared? */
                        slider1 = strchr(slider2 + 1, ' ');
                        if (slider1 && strstr(slider1, "shared:"))
@@ -706,7 +706,7 @@ bool detect_ramfs_rootfs(void)
                if (!p2)
                        continue;
                *p2 = '\0';
-               if (strcmp(p + 1, "/") == 0) {
+               if (strequal(p + 1, "/")) {
                        /* This is '/'. Is it the ramfs? */
                        p = strchr(p2 + 1, '-');
                        if (p && strncmp(p, "- rootfs ", 9) == 0)
@@ -1305,8 +1305,8 @@ int lxc_preserve_ns(const int pid, const char *ns)
         * string.
         */
        ret = strnprintf(path, sizeof(path), "/proc/%d/ns%s%s", pid,
-                        !ns || strcmp(ns, "") == 0 ? "" : "/",
-                        !ns || strcmp(ns, "") == 0 ? "" : ns);
+                        !ns || strequal(ns, "") ? "" : "/",
+                        !ns || strequal(ns, "") ? "" : ns);
        if (ret < 0)
                return ret_errno(EIO);
 
@@ -1629,7 +1629,7 @@ bool lxc_nic_exists(char *nic)
        int ret;
        struct stat sb;
 
-       if (!strcmp(nic, "none"))
+       if (strequal(nic, "none"))
                return true;
 
        ret = strnprintf(path, sizeof(path), "/sys/class/net/%s", nic);
@@ -1740,8 +1740,8 @@ int lxc_rm_rf(const char *dirname)
                __do_free char *pathname = NULL;
                struct stat mystat;
 
-               if (!strcmp(direntp->d_name, ".") ||
-                   !strcmp(direntp->d_name, ".."))
+               if (strequal(direntp->d_name, ".") ||
+                   strequal(direntp->d_name, ".."))
                        continue;
 
                pathname = must_make_path(dirname, direntp->d_name, NULL);