From 5044c33eade0ce0dc0ffb7bf26620cb17ac13c65 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sun, 17 Feb 2019 21:41:45 +0100 Subject: [PATCH] platform/netlink: use designated initializer in nlmsg_alloc_size() --- src/platform/nm-netlink.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/platform/nm-netlink.c b/src/platform/nm-netlink.c index 2d4f5ea549..eb3f1a9f82 100644 --- a/src/platform/nm-netlink.c +++ b/src/platform/nm-netlink.c @@ -259,11 +259,12 @@ nlmsg_alloc_size (size_t len) if (len < sizeof (struct nlmsghdr)) len = sizeof (struct nlmsghdr); - nm = g_slice_new0 (struct nl_msg); - - nm->nm_protocol = -1; - nm->nm_size = len; - nm->nm_nlh = g_malloc0 (len); + nm = g_slice_new (struct nl_msg); + *nm = (struct nl_msg) { + .nm_protocol = -1, + .nm_size = len, + .nm_nlh = g_malloc0 (len), + }; nm->nm_nlh->nlmsg_len = nlmsg_total_size (0); return nm; } @@ -370,7 +371,8 @@ nla_get_u64 (const struct nlattr *nla) { uint64_t tmp = 0; - if (nla && nla_len (nla) >= sizeof (tmp)) + if ( nla + && nla_len (nla) >= sizeof (tmp)) memcpy (&tmp, nla_data (nla), sizeof (tmp)); return tmp;