sd-netlink: allocate read buffer when necessary

This commit is contained in:
Yu Watanabe
2022-11-26 11:28:27 +09:00
parent 61d95dc02c
commit fb298ef104
2 changed files with 0 additions and 5 deletions
@@ -255,7 +255,6 @@ int socket_read_message(sd_netlink *nl) {
int r;
assert(nl);
assert(nl->rbuffer);
/* read nothing, just get the pending message size */
r = socket_recv_message(nl->fd, NULL, 0, NULL, true);
-4
View File
@@ -61,10 +61,6 @@ static int netlink_new(sd_netlink **ret) {
.serial = (uint32_t) (now(CLOCK_MONOTONIC) % UINT32_MAX) + 1,
};
/* We guarantee that the read buffer has at least space for a message header */
if (!greedy_realloc((void**) &nl->rbuffer, sizeof(struct nlmsghdr), sizeof(uint8_t)))
return -ENOMEM;
*ret = TAKE_PTR(nl);
return 0;
}