chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
cryptsetup-generator: use log_oom() everywhere
[elogind.git]
/
src
/
cryptsetup
/
cryptsetup-generator.c
diff --git
a/src/cryptsetup/cryptsetup-generator.c
b/src/cryptsetup/cryptsetup-generator.c
index 4166f365eaccef7dc451d117757b54a14a6cfc8e..ef16fbc2f521ba21652f8b20ef1201ab21ed831d 100644
(file)
--- a/
src/cryptsetup/cryptsetup-generator.c
+++ b/
src/cryptsetup/cryptsetup-generator.c
@@
-81,31
+81,27
@@
static int create_disk(
noauto = has_option(options, "noauto");
nofail = has_option(options, "nofail");
noauto = has_option(options, "noauto");
nofail = has_option(options, "nofail");
- n = unit_name_
build_escap
e("systemd-cryptsetup", name, ".service");
+ n = unit_name_
from_path_instanc
e("systemd-cryptsetup", name, ".service");
if (!n) {
if (!n) {
- r = -ENOMEM;
- log_error("Failed to allocate unit name.");
+ r = log_oom();
goto fail;
}
goto fail;
}
- p = join(arg_dest, "/", n, NULL);
+ p =
str
join(arg_dest, "/", n, NULL);
if (!p) {
if (!p) {
- r = -ENOMEM;
- log_error("Failed to allocate unit file name.");
+ r = log_oom();
goto fail;
}
u = fstab_node_to_udev_node(device);
if (!u) {
goto fail;
}
u = fstab_node_to_udev_node(device);
if (!u) {
- r = -ENOMEM;
- log_error("Failed to allocate device node.");
+ r = log_oom();
goto fail;
}
d = unit_name_from_path(u, ".device");
if (!d) {
goto fail;
}
d = unit_name_from_path(u, ".device");
if (!d) {
- r = -ENOMEM;
- log_error("Failed to allocate device name.");
+ r = log_oom();
goto fail;
}
goto fail;
}
@@
-120,10
+116,11
@@
static int create_disk(
"# Automatically generated by systemd-cryptsetup-generator\n\n"
"[Unit]\n"
"Description=Cryptography Setup for %%I\n"
"# Automatically generated by systemd-cryptsetup-generator\n\n"
"[Unit]\n"
"Description=Cryptography Setup for %%I\n"
+ "Documentation=man:systemd-cryptsetup@.service(8) man:crypttab(5)\n"
"SourcePath=/etc/crypttab\n"
"Conflicts=umount.target\n"
"DefaultDependencies=no\n"
"SourcePath=/etc/crypttab\n"
"Conflicts=umount.target\n"
"DefaultDependencies=no\n"
- "BindTo=%s dev-mapper-%%i.device\n"
+ "Bind
s
To=%s dev-mapper-%%i.device\n"
"After=systemd-readahead-collect.service systemd-readahead-replay.service %s\n"
"Before=umount.target\n",
d, d);
"After=systemd-readahead-collect.service systemd-readahead-replay.service %s\n"
"Before=umount.target\n",
d, d);
@@
-168,15
+165,15
@@
static int create_disk(
}
if (asprintf(&from, "../%s", n) < 0) {
}
if (asprintf(&from, "../%s", n) < 0) {
- r =
-ENOMEM
;
+ r =
log_oom()
;
goto fail;
}
if (!noauto) {
goto fail;
}
if (!noauto) {
- to = join(arg_dest, "/", d, ".wants/", n, NULL);
+ to =
str
join(arg_dest, "/", d, ".wants/", n, NULL);
if (!to) {
if (!to) {
- r =
-ENOMEM
;
+ r =
log_oom()
;
goto fail;
}
goto fail;
}
@@
-190,11
+187,11
@@
static int create_disk(
free(to);
if (!nofail)
free(to);
if (!nofail)
- to = join(arg_dest, "/cryptsetup.target.requires/", n, NULL);
+ to =
str
join(arg_dest, "/cryptsetup.target.requires/", n, NULL);
else
else
- to = join(arg_dest, "/cryptsetup.target.wants/", n, NULL);
+ to =
str
join(arg_dest, "/cryptsetup.target.wants/", n, NULL);
if (!to) {
if (!to) {
- r =
-ENOMEM
;
+ r =
log_oom()
;
goto fail;
}
goto fail;
}
@@
-210,9
+207,9
@@
static int create_disk(
}
e = unit_name_escape(name);
}
e = unit_name_escape(name);
- to = join(arg_dest, "/dev-mapper-", e, ".device.requires/", n, NULL);
+ to =
str
join(arg_dest, "/dev-mapper-", e, ".device.requires/", n, NULL);
if (!to) {
if (!to) {
- r =
-ENOMEM
;
+ r =
log_oom()
;
goto fail;
}
goto fail;
}
@@
-259,7
+256,7
@@
static int parse_proc_cmdline(void) {
word = strndup(w, l);
if (!word) {
word = strndup(w, l);
if (!word) {
- r =
-ENOMEM
;
+ r =
log_oom()
;
goto finish;
}
goto finish;
}
@@
-302,8
+299,7
@@
static int parse_proc_cmdline(void) {
t = strv_append(arg_proc_cmdline_disks, word + 10);
if (!t) {
t = strv_append(arg_proc_cmdline_disks, word + 10);
if (!t) {
- log_error("Out of memory");
- r = -ENOMEM;
+ r = log_oom();
goto finish;
}
strv_free(arg_proc_cmdline_disks);
goto finish;
}
strv_free(arg_proc_cmdline_disks);
@@
-316,8
+312,7
@@
static int parse_proc_cmdline(void) {
t = strv_append(arg_proc_cmdline_disks, word + 13);
if (!t) {
t = strv_append(arg_proc_cmdline_disks, word + 13);
if (!t) {
- log_error("Out of memory");
- r = -ENOMEM;
+ r = log_oom();
goto finish;
}
strv_free(arg_proc_cmdline_disks);
goto finish;
}
strv_free(arg_proc_cmdline_disks);
@@
-375,11
+370,11
@@
int main(int argc, char *argv[]) {
if (startswith(p, "luks-"))
p += 5;
if (startswith(p, "luks-"))
p += 5;
- name = strappend("luks-",
*i
);
- device = strappend("UUID=",
*i
);
+ name = strappend("luks-",
p
);
+ device = strappend("UUID=",
p
);
if (!name || !device) {
if (!name || !device) {
- log_
error("Out of memory"
);
+ log_
oom(
);
r = EXIT_FAILURE;
free(name);
free(device);
r = EXIT_FAILURE;
free(name);
free(device);