tree-wide: use TAKE_PTR() and TAKE_FD() macros

This commit is contained in:
Yu Watanabe
2018-04-05 14:26:26 +09:00
parent 3d282fff06
commit 1cc6c93a95
136 changed files with 383 additions and 736 deletions
+2 -2
View File
@@ -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;
}
+1 -2
View File
@@ -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;
}
+1 -2
View File
@@ -2448,8 +2448,7 @@ int cg_kernel_controllers(Set **ret) {
return r;
}
*ret = controllers;
controllers = NULL;
*ret = TAKE_PTR(controllers);
return 0;
}
+2 -4
View File
@@ -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;
}
+1 -2
View File
@@ -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;
+3 -6
View File
@@ -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;
}
+1 -2
View File
@@ -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;
}
+1 -2
View File
@@ -196,8 +196,7 @@ int get_locales(char ***ret) {
strv_sort(l);
*ret = l;
l = NULL;
*ret = TAKE_PTR(l);
return 0;
}
+2 -2
View File
@@ -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;
}
+1 -2
View File
@@ -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;
}
+1 -2
View File
@@ -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;
}