chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
bus: always create --user bus when kdbus is active
[elogind.git]
/
src
/
nss-myhostname
/
netlink.c
diff --git
a/src/nss-myhostname/netlink.c
b/src/nss-myhostname/netlink.c
index 2329f00943106586fb6243fb049e62ee1d13110e..d61ecdfd40f5e0e2d7e5b40b8d50023a647a131b 100644
(file)
--- a/
src/nss-myhostname/netlink.c
+++ b/
src/nss-myhostname/netlink.c
@@
-31,12
+31,9
@@
#include <limits.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <limits.h>
#include <arpa/inet.h>
#include <unistd.h>
-#include <inttypes.h>
#include <stdlib.h>
#include "ifconf.h"
#include <stdlib.h>
#include "ifconf.h"
-#include "macro.h"
-#include "util.h"
#define SEQ 4711
#define SEQ 4711
@@
-172,28
+169,35
@@
int ifconf_acquire_addresses(struct address **_list, unsigned *_n_list) {
int r, on = 1;
struct address *list = NULL;
unsigned n_list = 0;
int r, on = 1;
struct address *list = NULL;
unsigned n_list = 0;
- int
_cleanup_close_
fd;
+ int fd;
fd = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE);
if (fd < 0)
return -errno;
fd = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE);
if (fd < 0)
return -errno;
- if (setsockopt(fd, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on)) < 0)
- return -errno;
+ if (setsockopt(fd, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on)) < 0) {
+ r = -errno;
+ goto finish;
+ }
- if (send(fd, &req, req.hdr.nlmsg_len, 0) < 0)
- return -errno;
+ if (send(fd, &req, req.hdr.nlmsg_len, 0) < 0) {
+ r = -errno;
+ goto finish;
+ }
while((r = read_reply(fd, &list, &n_list)) == 0)
;
while((r = read_reply(fd, &list, &n_list)) == 0)
;
+finish:
+ close(fd);
+
if (r < 0) {
free(list);
return r;
}
if (r < 0) {
free(list);
return r;
}
- assert(n_list == 0 || list);
- qsort(list, n_list, sizeof(struct address), address_compare);
+ if (n_list)
+
qsort(list, n_list, sizeof(struct address), address_compare);
*_list = list;
*_n_list = n_list;
*_list = list;
*_n_list = n_list;