]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/shared/generator.c
coccinelle: make use of SYNTHETIC_ERRNO
[thirdparty/systemd.git] / src / shared / generator.c
index 2b0a4ecdc8d4d924c01803b29ecb64fc2628c427..e4a15f8b115c1c9f536d211960515744d50e508e 100644 (file)
@@ -1,22 +1,4 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
-/***
-  This file is part of systemd.
-
-  Copyright 2014 Lennart Poettering
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
 
 #include <errno.h>
 #include <stdio_ext.h>
@@ -328,10 +310,10 @@ int generator_hook_up_mkswap(
                 return log_oom();
 
         /* Nothing to work on. */
-        if (!is_device_path(node)) {
-                log_error("Cannot format something that is not a device node: %s", node);
-                return -EINVAL;
-        }
+        if (!is_device_path(node))
+                return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+                                       "Cannot format something that is not a device node: %s",
+                                       node);
 
         r = unit_name_from_path_instance("systemd-mkswap", node, ".service", &unit);
         if (r < 0)
@@ -398,15 +380,15 @@ int generator_hook_up_mkfs(
                 return log_oom();
 
         /* Nothing to work on. */
-        if (!is_device_path(node)) {
-                log_error("Cannot format something that is not a device node: %s", node);
-                return -EINVAL;
-        }
+        if (!is_device_path(node))
+                return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+                                       "Cannot format something that is not a device node: %s",
+                                       node);
 
-        if (!type || streq(type, "auto")) {
-                log_error("Cannot format partition %s, filesystem type is not specified", node);
-                return -EINVAL;
-        }
+        if (!type || streq(type, "auto"))
+                return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+                                       "Cannot format partition %s, filesystem type is not specified",
+                                       node);
 
         r = unit_name_from_path_instance("systemd-mkfs", node, ".service", &unit);
         if (r < 0)
@@ -516,3 +498,8 @@ int generator_hook_up_growfs(
 
         return generator_add_symlink(dir, where_unit, "wants", unit);
 }
+
+void log_setup_generator(void) {
+        log_set_prohibit_ipc(true);
+        log_setup_service();
+}