summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@gmail.com>2014-08-18 13:07:43 +0200
committerDavid Herrmann <dh.herrmann@gmail.com>2014-08-18 13:07:43 +0200
commit8a02decaf1e81bad3c06752e998734c96ab11260 (patch)
treeea24f29fbb5af1d2dc93429e99e23f8312b92767 /src
parent23972f4244f7609658c2a17f85508d50e4739990 (diff)
memfd: use _cleanup_ if applicable
We now have a sd_memfd_freep helper, use it if applicable.
Diffstat (limited to 'src')
-rw-r--r--src/shared/memfd.c11
1 files 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;
}