diff options
author | Lennart Poettering <lennart@poettering.net> | 2014-07-17 01:39:46 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2014-07-17 01:42:26 +0200 |
commit | a2ba62c719224a4b47751623ca5e8b0333f49721 (patch) | |
tree | 9d8d2332a7c63ab55089e83c6fd82ca85bd73efc /src/libsystemd-network/network-internal.c | |
parent | b45d9e86e41c453e0b57f2f8316bef06dee42e5a (diff) |
sd-network: remove redundant array size parameter from functions that return arrays
As long as the number of array entries is relatively small it's nicer to
simply return the number of entries directly, instead of using a size_t*
return parameter for it.
Diffstat (limited to 'src/libsystemd-network/network-internal.c')
-rw-r--r-- | src/libsystemd-network/network-internal.c | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/libsystemd-network/network-internal.c b/src/libsystemd-network/network-internal.c index 7a7a4eac9d..e209b0f56e 100644 --- a/src/libsystemd-network/network-internal.c +++ b/src/libsystemd-network/network-internal.c @@ -339,7 +339,7 @@ int net_parse_inaddr(const char *address, unsigned char *family, void *dst) { return 0; } -void serialize_in_addrs(FILE *f, const char *key, struct in_addr *addresses, size_t size) { +void serialize_in_addrs(FILE *f, const char *key, const struct in_addr *addresses, size_t size) { unsigned i; assert(f); @@ -356,14 +356,13 @@ void serialize_in_addrs(FILE *f, const char *key, struct in_addr *addresses, siz fputs("\n", f); } -int deserialize_in_addrs(struct in_addr **ret, size_t *ret_size, const char *string) { +int deserialize_in_addrs(struct in_addr **ret, const char *string) { _cleanup_free_ struct in_addr *addresses = NULL; - size_t size = 0; + int size = 0; char *word, *state; size_t len; assert(ret); - assert(ret_size); assert(string); FOREACH_WORD(word, len, string, state) { @@ -388,21 +387,19 @@ int deserialize_in_addrs(struct in_addr **ret, size_t *ret_size, const char *str size ++; } - *ret_size = size; *ret = addresses; addresses = NULL; - return 0; + return size; } -int deserialize_in6_addrs(struct in6_addr **ret, size_t *ret_size, const char *string) { +int deserialize_in6_addrs(struct in6_addr **ret, const char *string) { _cleanup_free_ struct in6_addr *addresses = NULL; - size_t size = 0; + int size = 0; char *word, *state; size_t len; assert(ret); - assert(ret_size); assert(string); FOREACH_WORD(word, len, string, state) { @@ -427,11 +424,10 @@ int deserialize_in6_addrs(struct in6_addr **ret, size_t *ret_size, const char *s size++; } - *ret_size = size; *ret = addresses; addresses = NULL; - return 0; + return size; } void serialize_dhcp_routes(FILE *f, const char *key, struct sd_dhcp_route *routes, size_t size) { |