summaryrefslogtreecommitdiff
path: root/src/gpt-auto-generator/gpt-auto-generator.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpt-auto-generator/gpt-auto-generator.c')
-rw-r--r--src/gpt-auto-generator/gpt-auto-generator.c66
1 files changed, 22 insertions, 44 deletions
diff --git a/src/gpt-auto-generator/gpt-auto-generator.c b/src/gpt-auto-generator/gpt-auto-generator.c
index 5a78087a1f..32e9b78a1d 100644
--- a/src/gpt-auto-generator/gpt-auto-generator.c
+++ b/src/gpt-auto-generator/gpt-auto-generator.c
@@ -68,10 +68,8 @@ static int add_swap(const char *path) {
return log_oom();
f = fopen(unit, "wxe");
- if (!f) {
- log_error_errno(errno, "Failed to create unit file %s: %m", unit);
- return -errno;
- }
+ if (!f)
+ return log_error_errno(errno, "Failed to create unit file %s: %m", unit);
fprintf(f,
"# Automatically generated by systemd-gpt-auto-generator\n\n"
@@ -83,20 +81,16 @@ static int add_swap(const char *path) {
path);
fflush(f);
- if (ferror(f)) {
- log_error_errno(errno, "Failed to write unit file %s: %m", unit);
- return -errno;
- }
+ if (ferror(f))
+ return log_error_errno(errno, "Failed to write unit file %s: %m", unit);
lnk = strjoin(arg_dest, "/" SPECIAL_SWAP_TARGET ".wants/", name, NULL);
if (!lnk)
return log_oom();
mkdir_parents_label(lnk, 0755);
- if (symlink(unit, lnk) < 0) {
- log_error_errno(errno, "Failed to create symlink %s: %m", lnk);
- return -errno;
- }
+ if (symlink(unit, lnk) < 0)
+ return log_error_errno(errno, "Failed to create symlink %s: %m", lnk);
return 0;
}
@@ -128,10 +122,8 @@ static int add_cryptsetup(const char *id, const char *what, bool rw, char **devi
return log_oom();
f = fopen(p, "wxe");
- if (!f) {
- log_error_errno(errno, "Failed to create unit file %s: %m", p);
- return -errno;
- }
+ if (!f)
+ return log_error_errno(errno, "Failed to create unit file %s: %m", p);
fprintf(f,
"# Automatically generated by systemd-gpt-auto-generator\n\n"
@@ -155,10 +147,8 @@ static int add_cryptsetup(const char *id, const char *what, bool rw, char **devi
id);
fflush(f);
- if (ferror(f)) {
- log_error_errno(errno, "Failed to write file %s: %m", p);
- return -errno;
- }
+ if (ferror(f))
+ return log_error_errno(errno, "Failed to write file %s: %m", p);
from = strappenda("../", n);
@@ -167,10 +157,8 @@ static int add_cryptsetup(const char *id, const char *what, bool rw, char **devi
return log_oom();
mkdir_parents_label(to, 0755);
- if (symlink(from, to) < 0) {
- log_error_errno(errno, "Failed to create symlink %s: %m", to);
- return -errno;
- }
+ if (symlink(from, to) < 0)
+ return log_error_errno(errno, "Failed to create symlink %s: %m", to);
free(to);
to = strjoin(arg_dest, "/cryptsetup.target.requires/", n, NULL);
@@ -178,10 +166,8 @@ static int add_cryptsetup(const char *id, const char *what, bool rw, char **devi
return log_oom();
mkdir_parents_label(to, 0755);
- if (symlink(from, to) < 0) {
- log_error_errno(errno, "Failed to create symlink %s: %m", to);
- return -errno;
- }
+ if (symlink(from, to) < 0)
+ return log_error_errno(errno, "Failed to create symlink %s: %m", to);
free(to);
to = strjoin(arg_dest, "/dev-mapper-", e, ".device.requires/", n, NULL);
@@ -189,10 +175,8 @@ static int add_cryptsetup(const char *id, const char *what, bool rw, char **devi
return log_oom();
mkdir_parents_label(to, 0755);
- if (symlink(from, to) < 0) {
- log_error_errno(errno, "Failed to create symlink %s: %m", to);
- return -errno;
- }
+ if (symlink(from, to) < 0)
+ return log_error_errno(errno, "Failed to create symlink %s: %m", to);
free(p);
p = strjoin(arg_dest, "/dev-mapper-", e, ".device.d/50-job-timeout-sec-0.conf", NULL);
@@ -254,10 +238,8 @@ static int add_mount(
return log_oom();
f = fopen(p, "wxe");
- if (!f) {
- log_error_errno(errno, "Failed to create unit file %s: %m", unit);
- return -errno;
- }
+ if (!f)
+ return log_error_errno(errno, "Failed to create unit file %s: %m", unit);
fprintf(f,
"# Automatically generated by systemd-gpt-auto-generator\n\n"
@@ -286,10 +268,8 @@ static int add_mount(
fprintf(f, "Options=%s\n", rw ? "rw" : "ro");
fflush(f);
- if (ferror(f)) {
- log_error_errno(errno, "Failed to write unit file %s: %m", p);
- return -errno;
- }
+ if (ferror(f))
+ return log_error_errno(errno, "Failed to write unit file %s: %m", p);
if (post) {
lnk = strjoin(arg_dest, "/", post, ".requires/", unit, NULL);
@@ -297,10 +277,8 @@ static int add_mount(
return log_oom();
mkdir_parents_label(lnk, 0755);
- if (symlink(p, lnk) < 0) {
- log_error_errno(errno, "Failed to create symlink %s: %m", lnk);
- return -errno;
- }
+ if (symlink(p, lnk) < 0)
+ return log_error_errno(errno, "Failed to create symlink %s: %m", lnk);
}
return 0;