summaryrefslogtreecommitdiff
path: root/src/cryptsetup/cryptsetup.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-10-03 22:13:55 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-10-03 22:13:55 -0400
commit5862d652ba14178cff46b8a8fc6c6d8392bf32b1 (patch)
treeb5f526c49e7aa8f5115fd59faecac865bdefce22 /src/cryptsetup/cryptsetup.c
parent9a5cb1371b6d8b0a04bd08665bcf9b06cb40c64c (diff)
Introduce _cleanup_endmntent_
Diffstat (limited to 'src/cryptsetup/cryptsetup.c')
-rw-r--r--src/cryptsetup/cryptsetup.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/src/cryptsetup/cryptsetup.c b/src/cryptsetup/cryptsetup.c
index 769c3e4f31..4f2f52a28a 100644
--- a/src/cryptsetup/cryptsetup.c
+++ b/src/cryptsetup/cryptsetup.c
@@ -236,31 +236,24 @@ finish:
}
static char *disk_mount_point(const char *label) {
- char *mp = NULL;
_cleanup_free_ char *device = NULL;
- FILE *f = NULL;
+ _cleanup_endmntent_ FILE *f = NULL;
struct mntent *m;
/* Yeah, we don't support native systemd unit files here for now */
if (asprintf(&device, "/dev/mapper/%s", label) < 0)
- goto finish;
+ return NULL;
f = setmntent("/etc/fstab", "r");
if (!f)
- goto finish;
+ return NULL;
while ((m = getmntent(f)))
- if (path_equal(m->mnt_fsname, device)) {
- mp = strdup(m->mnt_dir);
- break;
- }
-
-finish:
- if (f)
- endmntent(f);
+ if (path_equal(m->mnt_fsname, device))
+ return strdup(m->mnt_dir);
- return mp;
+ return NULL;
}
static int get_password(const char *name, usec_t until, bool accept_cached, char ***passwords) {