summaryrefslogtreecommitdiff
path: root/src/basic
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2018-04-05 14:26:26 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2018-04-05 14:26:26 +0900
commit1cc6c93a9569a9f2664d0d26cd0e50408307c430 (patch)
tree57e115a1beb9b097f731da79c3192015ff35cc94 /src/basic
parent3d282fff063c81893dc4bbd0282193d20dd5357e (diff)
downloadsystemd-1cc6c93a9569a9f2664d0d26cd0e50408307c430.tar.gz
tree-wide: use TAKE_PTR() and TAKE_FD() macros
Diffstat (limited to 'src/basic')
-rw-r--r--src/basic/bpf-program.c4
-rw-r--r--src/basic/btrfs-util.c3
-rw-r--r--src/basic/cgroup-util.c3
-rw-r--r--src/basic/cpu-set-util.c6
-rw-r--r--src/basic/fileio.c3
-rw-r--r--src/basic/hexdecoct.c9
-rw-r--r--src/basic/khash.c3
-rw-r--r--src/basic/locale-util.c3
-rw-r--r--src/basic/set.c4
-rw-r--r--src/basic/socket-util.c3
-rw-r--r--src/basic/time-util.c3
11 files changed, 16 insertions, 28 deletions
diff --git a/src/basic/bpf-program.c b/src/basic/bpf-program.c
index a244742f91..2cff567dc9 100644
--- a/src/basic/bpf-program.c
+++ b/src/basic/bpf-program.c
@@ -42,8 +42,8 @@ int bpf_program_new(uint32_t prog_type, BPFProgram **ret) {
p->prog_type = prog_type;
p->kernel_fd = -1;
- *ret = p;
- p = NULL;
+ *ret = TAKE_PTR(p);
+
return 0;
}
diff --git a/src/basic/btrfs-util.c b/src/basic/btrfs-util.c
index 3d30497f74..8b7d51f85a 100644
--- a/src/basic/btrfs-util.c
+++ b/src/basic/btrfs-util.c
@@ -1841,8 +1841,7 @@ int btrfs_qgroup_find_parents(int fd, uint64_t qgroupid, uint64_t **ret) {
return 0;
}
- *ret = items;
- items = NULL;
+ *ret = TAKE_PTR(items);
return (int) n_items;
}
diff --git a/src/basic/cgroup-util.c b/src/basic/cgroup-util.c
index 67e690d6f5..530ad136ba 100644
--- a/src/basic/cgroup-util.c
+++ b/src/basic/cgroup-util.c
@@ -2448,8 +2448,7 @@ int cg_kernel_controllers(Set **ret) {
return r;
}
- *ret = controllers;
- controllers = NULL;
+ *ret = TAKE_PTR(controllers);
return 0;
}
diff --git a/src/basic/cpu-set-util.c b/src/basic/cpu-set-util.c
index 9f0a61a18e..818cb38081 100644
--- a/src/basic/cpu-set-util.c
+++ b/src/basic/cpu-set-util.c
@@ -111,10 +111,8 @@ int parse_cpu_set_internal(
}
/* On success, sets *cpu_set and returns ncpus for the system. */
- if (c) {
- *cpu_set = c;
- c = NULL;
- }
+ if (c)
+ *cpu_set = TAKE_PTR(c);
return (int) ncpus;
}
diff --git a/src/basic/fileio.c b/src/basic/fileio.c
index f807842c31..d0cb033bbb 100644
--- a/src/basic/fileio.c
+++ b/src/basic/fileio.c
@@ -1606,8 +1606,7 @@ int read_line(FILE *f, size_t limit, char **ret) {
if (ret) {
buffer[n] = 0;
- *ret = buffer;
- buffer = NULL;
+ *ret = TAKE_PTR(buffer);
}
return (int) count;
diff --git a/src/basic/hexdecoct.c b/src/basic/hexdecoct.c
index 0764521b6f..7f8a74acf6 100644
--- a/src/basic/hexdecoct.c
+++ b/src/basic/hexdecoct.c
@@ -125,8 +125,7 @@ int unhexmem(const char *p, size_t l, void **mem, size_t *len) {
*z = 0;
- *mem = r;
- r = NULL;
+ *mem = TAKE_PTR(r);
*len = (l + 1) / 2;
return 0;
@@ -482,8 +481,7 @@ int unbase32hexmem(const char *p, size_t l, bool padding, void **mem, size_t *_l
*z = 0;
- *mem = r;
- r = NULL;
+ *mem = TAKE_PTR(r);
*_len = len;
return 0;
@@ -751,8 +749,7 @@ int unbase64mem(const char *p, size_t l, void **ret, size_t *ret_size) {
if (ret_size)
*ret_size = (size_t) (z - buf);
- *ret = buf;
- buf = NULL;
+ *ret = TAKE_PTR(buf);
return 0;
}
diff --git a/src/basic/khash.c b/src/basic/khash.c
index 6463faf3e1..b3e1dc4448 100644
--- a/src/basic/khash.c
+++ b/src/basic/khash.c
@@ -216,8 +216,7 @@ int khash_dup(khash *h, khash **ret) {
if (copy->fd < 0)
return -errno;
- *ret = copy;
- copy = NULL;
+ *ret = TAKE_PTR(copy);
return 0;
}
diff --git a/src/basic/locale-util.c b/src/basic/locale-util.c
index de3d7c8c89..2080be24be 100644
--- a/src/basic/locale-util.c
+++ b/src/basic/locale-util.c
@@ -196,8 +196,7 @@ int get_locales(char ***ret) {
strv_sort(l);
- *ret = l;
- l = NULL;
+ *ret = TAKE_PTR(l);
return 0;
}
diff --git a/src/basic/set.c b/src/basic/set.c
index e554e825eb..da2cc0fb4a 100644
--- a/src/basic/set.c
+++ b/src/basic/set.c
@@ -18,6 +18,7 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
+#include "alloc-util.h"
#include "set.h"
int set_make(Set **ret, const struct hash_ops *hash_ops HASHMAP_DEBUG_PARAMS, void *add, ...) {
@@ -55,8 +56,7 @@ int set_make(Set **ret, const struct hash_ops *hash_ops HASHMAP_DEBUG_PARAMS, vo
va_end(ap);
}
- *ret = s;
- s = NULL;
+ *ret = TAKE_PTR(s);
return 0;
}
diff --git a/src/basic/socket-util.c b/src/basic/socket-util.c
index fd26ae7137..1bfd125e01 100644
--- a/src/basic/socket-util.c
+++ b/src/basic/socket-util.c
@@ -1017,8 +1017,7 @@ int getpeergroups(int fd, gid_t **ret) {
if ((socklen_t) (int) n != n)
return -E2BIG;
- *ret = d;
- d = NULL;
+ *ret = TAKE_PTR(d);
return (int) n;
}
diff --git a/src/basic/time-util.c b/src/basic/time-util.c
index 4a341e208f..b99d257b77 100644
--- a/src/basic/time-util.c
+++ b/src/basic/time-util.c
@@ -1283,8 +1283,7 @@ int get_timezones(char ***ret) {
} else if (errno != ENOENT)
return -errno;
- *ret = zones;
- zones = NULL;
+ *ret = TAKE_PTR(zones);
return 0;
}