From 8a02decaf1e81bad3c06752e998734c96ab11260 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Mon, 18 Aug 2014 13:07:43 +0200 Subject: memfd: use _cleanup_ if applicable We now have a sd_memfd_freep helper, use it if applicable. --- src/shared/memfd.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/shared/memfd.c b/src/shared/memfd.c index d94c6268dd..e246f915ca 100644 --- a/src/shared/memfd.c +++ b/src/shared/memfd.c @@ -241,7 +241,7 @@ int sd_memfd_set_size(sd_memfd *m, uint64_t sz) { } int sd_memfd_new_and_map(sd_memfd **m, const char *name, size_t sz, void **p) { - sd_memfd *n; + _cleanup_(sd_memfd_freep) sd_memfd *n = NULL; int r; r = sd_memfd_new(&n, name); @@ -249,18 +249,15 @@ int sd_memfd_new_and_map(sd_memfd **m, const char *name, size_t sz, void **p) { return r; r = sd_memfd_set_size(n, sz); - if (r < 0) { - sd_memfd_free(n); + if (r < 0) return r; - } r = sd_memfd_map(n, 0, sz, p); - if (r < 0) { - sd_memfd_free(n); + if (r < 0) return r; - } *m = n; + n = NULL; return 0; } -- cgit v1.2.3-54-g00ecf