platform/trivial: coding style fixes/whitespace

This commit is contained in:
Thomas Haller 2019-02-17 11:12:02 +01:00
parent 6f8208c0d4
commit 6c24846929
3 changed files with 63 additions and 61 deletions

View file

@ -1099,7 +1099,7 @@ _linktype_get_type (NMPlatform *platform,
******************************************************************/
#define NLMSG_TAIL(nmsg) \
((struct rtattr *) (((char *) (nmsg)) + NLMSG_ALIGN((nmsg)->nlmsg_len)))
((struct rtattr *) (((char *) (nmsg)) + NLMSG_ALIGN ((nmsg)->nlmsg_len)))
/* copied from iproute2's addattr_l(). */
static gboolean
@ -1159,7 +1159,7 @@ _parse_af_inet6 (NMPlatform *platform,
[IFLA_INET6_CONF] = { .minlen = 4 },
[IFLA_INET6_STATS] = { .minlen = 8 },
[IFLA_INET6_ICMP6STATS] = { .minlen = 8 },
[IFLA_INET6_TOKEN] = { .minlen = sizeof(struct in6_addr) },
[IFLA_INET6_TOKEN] = { .minlen = sizeof (struct in6_addr) },
[IFLA_INET6_ADDR_GEN_MODE] = { .type = NLA_U8 },
};
struct nlattr *tb[G_N_ELEMENTS (policy)];
@ -1171,11 +1171,11 @@ _parse_af_inet6 (NMPlatform *platform,
if (nla_parse_nested_arr (tb, attr, policy) < 0)
return FALSE;
if (tb[IFLA_INET6_CONF] && nla_len(tb[IFLA_INET6_CONF]) % 4)
if (tb[IFLA_INET6_CONF] && nla_len (tb[IFLA_INET6_CONF]) % 4)
return FALSE;
if (tb[IFLA_INET6_STATS] && nla_len(tb[IFLA_INET6_STATS]) % 8)
if (tb[IFLA_INET6_STATS] && nla_len (tb[IFLA_INET6_STATS]) % 8)
return FALSE;
if (tb[IFLA_INET6_ICMP6STATS] && nla_len(tb[IFLA_INET6_ICMP6STATS]) % 8)
if (tb[IFLA_INET6_ICMP6STATS] && nla_len (tb[IFLA_INET6_ICMP6STATS]) % 8)
return FALSE;
if (_check_addr_or_return_val (tb, IFLA_INET6_TOKEN, sizeof (struct in6_addr), FALSE)) {
@ -1694,7 +1694,7 @@ _vlan_qos_mapping_from_nla (struct nlattr *nlattr,
array = g_ptr_array_new ();
nla_for_each_nested (nla, nlattr, remaining) {
if (nla_len (nla) < sizeof(NMVlanQosMapping))
if (nla_len (nla) < sizeof (NMVlanQosMapping))
return FALSE;
g_ptr_array_add (array, nla_data (nla));
}
@ -1762,7 +1762,7 @@ _parse_lnk_vlan (const char *kind, struct nlattr *info_data)
if (tb[IFLA_VLAN_FLAGS]) {
struct ifla_vlan_flags flags;
nla_memcpy (&flags, tb[IFLA_VLAN_FLAGS], sizeof(flags));
nla_memcpy (&flags, tb[IFLA_VLAN_FLAGS], sizeof (flags));
obj->lnk_vlan.flags = flags.flags;
}
@ -2697,7 +2697,7 @@ _new_from_nl_link (NMPlatform *platform, const NMPCache *cache, struct nlmsghdr
if (!tb[IFLA_IFNAME])
return NULL;
nla_strlcpy(obj->link.name, tb[IFLA_IFNAME], IFNAMSIZ);
nla_strlcpy (obj->link.name, tb[IFLA_IFNAME], IFNAMSIZ);
if (!obj->link.name[0])
return NULL;
@ -2998,7 +2998,7 @@ _new_from_nl_addr (struct nlmsghdr *nlh, gboolean id_only)
is_v4 = ifa->ifa_family == AF_INET;
if (nlmsg_parse_arr (nlh, sizeof(*ifa), tb, policy) < 0)
if (nlmsg_parse_arr (nlh, sizeof (*ifa), tb, policy) < 0)
return NULL;
addr_len = is_v4
@ -3067,7 +3067,7 @@ _new_from_nl_addr (struct nlmsghdr *nlh, gboolean id_only)
timestamp = 0;
/* IPv6 only */
if (tb[IFA_CACHEINFO]) {
const struct ifa_cacheinfo *ca = nla_data(tb[IFA_CACHEINFO]);
const struct ifa_cacheinfo *ca = nla_data (tb[IFA_CACHEINFO]);
lifetime = ca->ifa_valid;
preferred = ca->ifa_prefered;
@ -3155,9 +3155,10 @@ _new_from_nl_route (struct nlmsghdr *nlh, gboolean id_only)
if (tb[RTA_MULTIPATH]) {
struct rtnexthop *rtnh = nla_data (tb[RTA_MULTIPATH]);
size_t tlen = nla_len(tb[RTA_MULTIPATH]);
size_t tlen = nla_len (tb[RTA_MULTIPATH]);
while (tlen >= sizeof(*rtnh) && tlen >= rtnh->rtnh_len) {
while ( tlen >= sizeof (*rtnh)
&& tlen >= rtnh->rtnh_len) {
if (nh.is_present) {
/* we don't support multipath routes. */
@ -3167,7 +3168,7 @@ _new_from_nl_route (struct nlmsghdr *nlh, gboolean id_only)
nh.ifindex = rtnh->rtnh_ifindex;
if (rtnh->rtnh_len > sizeof(*rtnh)) {
if (rtnh->rtnh_len > sizeof (*rtnh)) {
struct nlattr *ntb[G_N_ELEMENTS (policy)];
if (nla_parse_arr (ntb,
@ -3180,8 +3181,8 @@ _new_from_nl_route (struct nlmsghdr *nlh, gboolean id_only)
memcpy (&nh.gateway, nla_data (ntb[RTA_GATEWAY]), addr_len);
}
tlen -= RTNH_ALIGN(rtnh->rtnh_len);
rtnh = RTNH_NEXT(rtnh);
tlen -= RTNH_ALIGN (rtnh->rtnh_len);
rtnh = RTNH_NEXT (rtnh);
}
}
@ -3262,7 +3263,7 @@ _new_from_nl_route (struct nlmsghdr *nlh, gboolean id_only)
obj->ip_route.plen = rtm->rtm_dst_len;
if (tb[RTA_PRIORITY])
obj->ip_route.metric = nla_get_u32(tb[RTA_PRIORITY]);
obj->ip_route.metric = nla_get_u32 (tb[RTA_PRIORITY]);
if (is_v4)
obj->ip4_route.gateway = nh.gateway.addr4;
@ -3599,7 +3600,7 @@ _nl_msg_new_link_set_linkinfo_vlan (struct nl_msg *msg,
for (i = 0; i < egress_qos_len; i++) {
if (VLAN_XGRESS_PRIO_VALID (egress_qos[i].to)) {
if (!qos) {
if (!(qos = nla_nest_start(msg, IFLA_VLAN_EGRESS_QOS)))
if (!(qos = nla_nest_start (msg, IFLA_VLAN_EGRESS_QOS)))
goto nla_put_failure;
}
NLA_PUT (msg, i, sizeof (egress_qos[i]), &egress_qos[i]);
@ -3607,7 +3608,7 @@ _nl_msg_new_link_set_linkinfo_vlan (struct nl_msg *msg,
}
if (qos)
nla_nest_end(msg, qos);
nla_nest_end (msg, qos);
}
nla_nest_end (msg, data);
@ -3722,7 +3723,7 @@ _nl_msg_new_address (int nlmsg_type,
.ifa_prefered = preferred,
};
NLA_PUT (msg, IFA_CACHEINFO, sizeof(ca), &ca);
NLA_PUT (msg, IFA_CACHEINFO, sizeof (ca), &ca);
}
if (flags & ~((guint32) 0xFF)) {
@ -3848,7 +3849,7 @@ _nl_msg_new_route (int nlmsg_type,
if (lock)
NLA_PUT_U32 (msg, RTAX_LOCK, lock);
nla_nest_end(msg, metrics);
nla_nest_end (msg, metrics);
}
/* We currently don't have need for multi-hop routes... */
@ -5063,7 +5064,7 @@ _nl_send_nlmsghdr (NMPlatform *platform,
};
struct msghdr msg = {
.msg_name = &nladdr,
.msg_namelen = sizeof(nladdr),
.msg_namelen = sizeof (nladdr),
.msg_iov = &iov,
.msg_iovlen = 1,
};

View file

@ -106,7 +106,7 @@ struct nla_policy {
/*****************************************************************************/
static inline int
nla_attr_size(int payload)
nla_attr_size (int payload)
{
nm_assert (payload >= 0);
@ -122,7 +122,7 @@ nla_total_size (int payload)
static inline int
nla_padlen (int payload)
{
return nla_total_size(payload) - nla_attr_size(payload);
return nla_total_size (payload) - nla_attr_size (payload);
}
struct nlattr *nla_reserve (struct nl_msg *msg, int attrtype, int attrlen);
@ -174,13 +174,13 @@ nla_get_u16 (const struct nlattr *nla)
}
static inline uint32_t
nla_get_u32(const struct nlattr *nla)
nla_get_u32 (const struct nlattr *nla)
{
return *(const uint32_t *) nla_data (nla);
}
static inline int32_t
nla_get_s32(const struct nlattr *nla)
nla_get_s32 (const struct nlattr *nla)
{
return *(const int32_t *) nla_data (nla);
}
@ -202,7 +202,7 @@ int nla_put (struct nl_msg *msg, int attrtype, int datalen, const void *data);
static inline int
nla_put_string (struct nl_msg *msg, int attrtype, const char *str)
{
return nla_put(msg, attrtype, strlen(str) + 1, str);
return nla_put (msg, attrtype, strlen (str) + 1, str);
}
static inline int
@ -225,54 +225,54 @@ nla_put_uint32 (struct nl_msg *msg, int attrtype, uint32_t val)
#define NLA_PUT(msg, attrtype, attrlen, data) \
G_STMT_START { \
if (nla_put(msg, attrtype, attrlen, data) < 0) \
if (nla_put (msg, attrtype, attrlen, data) < 0) \
goto nla_put_failure; \
} G_STMT_END
#define NLA_PUT_TYPE(msg, type, attrtype, value) \
G_STMT_START { \
type __nla_tmp = value; \
NLA_PUT(msg, attrtype, sizeof(type), &__nla_tmp); \
NLA_PUT (msg, attrtype, sizeof (type), &__nla_tmp); \
} G_STMT_END
#define NLA_PUT_U8(msg, attrtype, value) \
NLA_PUT_TYPE(msg, uint8_t, attrtype, value)
NLA_PUT_TYPE (msg, uint8_t, attrtype, value)
#define NLA_PUT_S8(msg, attrtype, value) \
NLA_PUT_TYPE(msg, int8_t, attrtype, value)
NLA_PUT_TYPE (msg, int8_t, attrtype, value)
#define NLA_PUT_U16(msg, attrtype, value) \
NLA_PUT_TYPE(msg, uint16_t, attrtype, value)
NLA_PUT_TYPE (msg, uint16_t, attrtype, value)
#define NLA_PUT_U32(msg, attrtype, value) \
NLA_PUT_TYPE(msg, uint32_t, attrtype, value)
NLA_PUT_TYPE (msg, uint32_t, attrtype, value)
#define NLA_PUT_S32(msg, attrtype, value) \
NLA_PUT_TYPE(msg, int32_t, attrtype, value)
NLA_PUT_TYPE (msg, int32_t, attrtype, value)
#define NLA_PUT_U64(msg, attrtype, value) \
NLA_PUT_TYPE(msg, uint64_t, attrtype, value)
NLA_PUT_TYPE (msg, uint64_t, attrtype, value)
#define NLA_PUT_STRING(msg, attrtype, value) \
NLA_PUT(msg, attrtype, (int) strlen(value) + 1, value)
NLA_PUT (msg, attrtype, (int) strlen (value) + 1, value)
#define NLA_PUT_FLAG(msg, attrtype) \
NLA_PUT(msg, attrtype, 0, NULL)
NLA_PUT (msg, attrtype, 0, NULL)
struct nlattr *nla_find (const struct nlattr *head, int len, int attrtype);
static inline int
nla_ok (const struct nlattr *nla, int remaining)
{
return remaining >= (int) sizeof(*nla) &&
nla->nla_len >= sizeof(*nla) &&
return remaining >= (int) sizeof (*nla) &&
nla->nla_len >= sizeof (*nla) &&
nla->nla_len <= remaining;
}
static inline struct nlattr *
nla_next(const struct nlattr *nla, int *remaining)
nla_next (const struct nlattr *nla, int *remaining)
{
int totlen = NLA_ALIGN(nla->nla_len);
int totlen = NLA_ALIGN (nla->nla_len);
*remaining -= totlen;
return (struct nlattr *) ((char *) nla + totlen);
@ -280,13 +280,13 @@ nla_next(const struct nlattr *nla, int *remaining)
#define nla_for_each_attr(pos, head, len, rem) \
for (pos = head, rem = len; \
nla_ok(pos, rem); \
pos = nla_next(pos, &(rem)))
nla_ok (pos, rem); \
pos = nla_next (pos, &(rem)))
#define nla_for_each_nested(pos, nla, rem) \
for (pos = (struct nlattr *) nla_data(nla), rem = nla_len(nla); \
nla_ok(pos, rem); \
pos = nla_next(pos, &(rem)))
for (pos = (struct nlattr *) nla_data (nla), rem = nla_len (nla); \
nla_ok (pos, rem); \
pos = nla_next (pos, &(rem)))
void nla_nest_cancel (struct nl_msg *msg, const struct nlattr *attr);
struct nlattr *nla_nest_start (struct nl_msg *msg, int attrtype);
@ -311,7 +311,7 @@ nla_parse_nested (struct nlattr *tb[],
struct nlattr *nla,
const struct nla_policy *policy)
{
return nla_parse (tb, maxtype, nla_data(nla), nla_len(nla), policy);
return nla_parse (tb, maxtype, nla_data (nla), nla_len (nla), policy);
}
#define nla_parse_nested_arr(tb, nla, policy) \
@ -353,15 +353,15 @@ nlmsg_total_size (int payload)
static inline int
nlmsg_ok (const struct nlmsghdr *nlh, int remaining)
{
return (remaining >= (int)sizeof(struct nlmsghdr) &&
nlh->nlmsg_len >= sizeof(struct nlmsghdr) &&
return (remaining >= (int) sizeof (struct nlmsghdr) &&
nlh->nlmsg_len >= sizeof (struct nlmsghdr) &&
nlh->nlmsg_len <= remaining);
}
static inline struct nlmsghdr *
nlmsg_next (struct nlmsghdr *nlh, int *remaining)
{
int totlen = NLMSG_ALIGN(nlh->nlmsg_len);
int totlen = NLMSG_ALIGN (nlh->nlmsg_len);
*remaining -= totlen;
@ -381,7 +381,7 @@ _nm_auto_nl_msg_cleanup (struct nl_msg **ptr)
{
nlmsg_free (*ptr);
}
#define nm_auto_nlmsg nm_auto(_nm_auto_nl_msg_cleanup)
#define nm_auto_nlmsg nm_auto (_nm_auto_nl_msg_cleanup)
static inline void *
nlmsg_data (const struct nlmsghdr *nlh)
@ -392,13 +392,13 @@ nlmsg_data (const struct nlmsghdr *nlh)
static inline void *
nlmsg_tail (const struct nlmsghdr *nlh)
{
return (unsigned char *) nlh + NLMSG_ALIGN(nlh->nlmsg_len);
return (unsigned char *) nlh + NLMSG_ALIGN (nlh->nlmsg_len);
}
struct nlmsghdr *nlmsg_hdr (struct nl_msg *n);
static inline int
nlmsg_valid_hdr(const struct nlmsghdr *nlh, int hdrlen)
nlmsg_valid_hdr (const struct nlmsghdr *nlh, int hdrlen)
{
if (nlh->nlmsg_len < nlmsg_size (hdrlen))
return 0;
@ -421,8 +421,8 @@ nlmsg_attrlen (const struct nlmsghdr *nlh, int hdrlen)
static inline struct nlattr *
nlmsg_attrdata (const struct nlmsghdr *nlh, int hdrlen)
{
unsigned char *data = nlmsg_data(nlh);
return (struct nlattr *) (data + NLMSG_ALIGN(hdrlen));
unsigned char *data = nlmsg_data (nlh);
return (struct nlattr *) (data + NLMSG_ALIGN (hdrlen));
}
static inline struct nlattr *

View file

@ -464,21 +464,22 @@ nl80211_bss_dump_handler (struct nl_msg *msg, void *arg)
info->freq = nla_get_u32 (bss[NL80211_BSS_FREQUENCY]);
if (bss[NL80211_BSS_SIGNAL_UNSPEC])
info->beacon_signal =
nla_get_u8 (bss[NL80211_BSS_SIGNAL_UNSPEC]);
info->beacon_signal = nla_get_u8 (bss[NL80211_BSS_SIGNAL_UNSPEC]);
if (bss[NL80211_BSS_SIGNAL_MBM])
info->beacon_signal =
nl80211_xbm_to_percent (nla_get_u32 (bss[NL80211_BSS_SIGNAL_MBM]), 100);
info->beacon_signal = nl80211_xbm_to_percent (nla_get_u32 (bss[NL80211_BSS_SIGNAL_MBM]), 100);
if (bss[NL80211_BSS_INFORMATION_ELEMENTS]) {
guint8 *ssid;
guint32 ssid_len;
find_ssid (nla_data (bss[NL80211_BSS_INFORMATION_ELEMENTS]),
nla_len (bss[NL80211_BSS_INFORMATION_ELEMENTS]),
&ssid, &ssid_len);
if (ssid && ssid_len && ssid_len <= sizeof (info->ssid)) {
nla_len (bss[NL80211_BSS_INFORMATION_ELEMENTS]),
&ssid,
&ssid_len);
if ( ssid
&& ssid_len
&& ssid_len <= sizeof (info->ssid)) {
memcpy (info->ssid, ssid, ssid_len);
info->ssid_len = ssid_len;
}