]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/core/namespace.c
coccinelle: make use of SYNTHETIC_ERRNO
[thirdparty/systemd.git] / src / core / namespace.c
index c7cc1c755046ee0f4f1b7ca226256f307db87977..01516072a05844054be5c779bb22565e08dd80fe 100644 (file)
@@ -235,10 +235,9 @@ static int append_access_mounts(MountEntry **p, char **strv, MountMode mode, boo
                         needs_prefix = true;
                 }
 
-                if (!path_is_absolute(e)) {
-                        log_debug("Path is not absolute: %s", e);
-                        return -EINVAL;
-                }
+                if (!path_is_absolute(e))
+                        return log_debug_errno(SYNTHETIC_ERRNO(EINVAL),
+                                               "Path is not absolute: %s", e);
 
                 *((*p)++) = (MountEntry) {
                         .path_const = e,
@@ -306,10 +305,10 @@ static int append_tmpfs_mounts(MountEntry **p, const TemporaryFileSystem *tmpfs,
                 unsigned long flags;
                 bool ro = false;
 
-                if (!path_is_absolute(t->path)) {
-                        log_debug("Path is not absolute: %s", t->path);
-                        return -EINVAL;
-                }
+                if (!path_is_absolute(t->path))
+                        return log_debug_errno(SYNTHETIC_ERRNO(EINVAL),
+                                               "Path is not absolute: %s",
+                                               t->path);
 
                 str = strjoin("mode=0755,", t->options);
                 if (!str)
@@ -575,10 +574,10 @@ static int clone_device_node(
         }
 
         if (!S_ISBLK(st.st_mode) &&
-            !S_ISCHR(st.st_mode)) {
-                log_debug("Device node '%s' to clone is not a device node, ignoring.", d);
-                return -EINVAL;
-        }
+            !S_ISCHR(st.st_mode))
+                return log_debug_errno(SYNTHETIC_ERRNO(EINVAL),
+                                       "Device node '%s' to clone is not a device node, ignoring.",
+                                       d);
 
         dn = strjoina(temporary_mount, d);
 
@@ -855,10 +854,10 @@ static int follow_symlink(
         if (r > 0) /* Reached the end, nothing more to resolve */
                 return 1;
 
-        if (m->n_followed >= CHASE_SYMLINKS_MAX) /* put a boundary on things */
-                log_debug("Symlink loop on '%s'.", mount_entry_path(m));
-                return -ELOOP;
-        }
+        if (m->n_followed >= CHASE_SYMLINKS_MAX) /* put a boundary on things */
+                return log_debug_errno(SYNTHETIC_ERRNO(ELOOP),
+                                       "Symlink loop on '%s'.",
+                                       mount_entry_path(m));
 
         log_debug("Followed mount entry path symlink %s → %s.", mount_entry_path(m), target);
 
@@ -900,10 +899,9 @@ static int apply_mount(
                 }
 
                 what = mode_to_inaccessible_node(target.st_mode);
-                if (!what) {
-                        log_debug("File type not supported for inaccessible mounts. Note that symlinks are not allowed");
-                        return -ELOOP;
-                }
+                if (!what)
+                        return log_debug_errno(SYNTHETIC_ERRNO(ELOOP),
+                                               "File type not supported for inaccessible mounts. Note that symlinks are not allowed");
                 break;
         }