From e9e9365b562ef5084bf21fb01e928c52c7078c93 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Sun, 27 Mar 2016 10:47:46 -0700 Subject: [PATCH] scrub out whitespace issues Run script that removes trailing whitespace everywhere. --- bridge/fdb.c | 2 +- bridge/monitor.c | 1 - genl/ctrl.c | 2 +- include/libnetlink.h | 32 +++++++++++++++----------------- lib/coverity_model.c | 2 -- lib/dnet_ntop.c | 2 -- lib/inet_proto.c | 2 -- lib/ipx_ntop.c | 2 -- lib/libgenl.c | 1 - lib/libnetlink.c | 2 +- lib/utils.c | 6 +++--- netem/maketable.c | 4 ++-- netem/normal.c | 2 +- netem/pareto.c | 4 ++-- netem/paretonormal.c | 2 +- tc/m_action.c | 6 +++--- tc/tc_core.c | 2 +- 17 files changed, 31 insertions(+), 43 deletions(-) diff --git a/bridge/fdb.c b/bridge/fdb.c index e8c314a3..df55e86d 100644 --- a/bridge/fdb.c +++ b/bridge/fdb.c @@ -298,7 +298,7 @@ static int fdb_modify(int cmd, int flags, int argc, char **argv) req.ndm.ndm_flags |= NTF_MASTER; } else if (matches(*argv, "router") == 0) { req.ndm.ndm_flags |= NTF_ROUTER; - } else if (matches(*argv, "local") == 0 || + } else if (matches(*argv, "local") == 0 || matches(*argv, "permanent") == 0) { req.ndm.ndm_state |= NUD_PERMANENT; } else if (matches(*argv, "temp") == 0 || diff --git a/bridge/monitor.c b/bridge/monitor.c index 62690810..d294269e 100644 --- a/bridge/monitor.c +++ b/bridge/monitor.c @@ -142,4 +142,3 @@ int do_monitor(int argc, char **argv) return 0; } - diff --git a/genl/ctrl.c b/genl/ctrl.c index b7a8878c..ffa34af5 100644 --- a/genl/ctrl.c +++ b/genl/ctrl.c @@ -132,7 +132,7 @@ static void print_ctrl_cmd_flags(FILE *fp, __u32 fl) fprintf(fp, "\n"); } - + static int print_ctrl_cmds(FILE *fp, struct rtattr *arg, __u32 ctrl_ver) { struct rtattr *tb[CTRL_ATTR_OP_MAX + 1]; diff --git a/include/libnetlink.h b/include/libnetlink.h index 431189e2..491263f7 100644 --- a/include/libnetlink.h +++ b/include/libnetlink.h @@ -11,8 +11,7 @@ #include #include -struct rtnl_handle -{ +struct rtnl_handle { int fd; struct sockaddr_nl local; struct sockaddr_nl peer; @@ -26,10 +25,10 @@ struct rtnl_handle extern int rcvbuf; -int rtnl_open(struct rtnl_handle *rth, unsigned subscriptions) +int rtnl_open(struct rtnl_handle *rth, unsigned int subscriptions) __attribute__((warn_unused_result)); -int rtnl_open_byproto(struct rtnl_handle *rth, unsigned subscriptions, +int rtnl_open_byproto(struct rtnl_handle *rth, unsigned int subscriptions, int protocol) __attribute__((warn_unused_result)); @@ -56,8 +55,7 @@ typedef int (*rtnl_listen_filter_t)(const struct sockaddr_nl *, struct rtnl_ctrl_data *, struct nlmsghdr *n, void *); -struct rtnl_dump_filter_arg -{ +struct rtnl_dump_filter_arg { rtnl_filter_t filter; void *arg1; __u16 nc_flags; @@ -140,6 +138,7 @@ static inline __u32 rta_getattr_u32(const struct rtattr *rta) static inline __u64 rta_getattr_u64(const struct rtattr *rta) { __u64 tmp; + memcpy(&tmp, RTA_DATA(rta), sizeof(__u64)); return tmp; } @@ -159,42 +158,42 @@ int rtnl_from_file(FILE *, rtnl_listen_filter_t handler, #ifndef IFA_RTA #define IFA_RTA(r) \ - ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifaddrmsg)))) + ((struct rtattr *)(((char *)(r)) + NLMSG_ALIGN(sizeof(struct ifaddrmsg)))) #endif #ifndef IFA_PAYLOAD -#define IFA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifaddrmsg)) +#define IFA_PAYLOAD(n) NLMSG_PAYLOAD(n, sizeof(struct ifaddrmsg)) #endif #ifndef IFLA_RTA #define IFLA_RTA(r) \ - ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifinfomsg)))) + ((struct rtattr *)(((char *)(r)) + NLMSG_ALIGN(sizeof(struct ifinfomsg)))) #endif #ifndef IFLA_PAYLOAD -#define IFLA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifinfomsg)) +#define IFLA_PAYLOAD(n) NLMSG_PAYLOAD(n, sizeof(struct ifinfomsg)) #endif #ifndef NDA_RTA #define NDA_RTA(r) \ - ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ndmsg)))) + ((struct rtattr *)(((char *)(r)) + NLMSG_ALIGN(sizeof(struct ndmsg)))) #endif #ifndef NDA_PAYLOAD -#define NDA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ndmsg)) +#define NDA_PAYLOAD(n) NLMSG_PAYLOAD(n, sizeof(struct ndmsg)) #endif #ifndef NDTA_RTA #define NDTA_RTA(r) \ - ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ndtmsg)))) + ((struct rtattr *)(((char *)(r)) + NLMSG_ALIGN(sizeof(struct ndtmsg)))) #endif #ifndef NDTA_PAYLOAD -#define NDTA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ndtmsg)) +#define NDTA_PAYLOAD(n) NLMSG_PAYLOAD(n, sizeof(struct ndtmsg)) #endif #ifndef NETNS_RTA #define NETNS_RTA(r) \ - ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct rtgenmsg)))) + ((struct rtattr *)(((char *)(r)) + NLMSG_ALIGN(sizeof(struct rtgenmsg)))) #endif #ifndef NETNS_PAYLOAD -#define NETNS_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct rtgenmsg)) +#define NETNS_PAYLOAD(n) NLMSG_PAYLOAD(n, sizeof(struct rtgenmsg)) #endif /* User defined nlmsg_type which is used mostly for logging netlink @@ -202,4 +201,3 @@ int rtnl_from_file(FILE *, rtnl_listen_filter_t handler, #define NLMSG_TSTAMP 15 #endif /* __LIBNETLINK_H__ */ - diff --git a/lib/coverity_model.c b/lib/coverity_model.c index c8963020..1321fe82 100644 --- a/lib/coverity_model.c +++ b/lib/coverity_model.c @@ -15,5 +15,3 @@ * Coverity Scan doesn't pick up modifications automatically. The model file * must be uploaded by an admin. */ - - diff --git a/lib/dnet_ntop.c b/lib/dnet_ntop.c index 507a7eb8..112dc0d9 100644 --- a/lib/dnet_ntop.c +++ b/lib/dnet_ntop.c @@ -98,5 +98,3 @@ const char *dnet_ntop(int af, const void *addr, char *str, size_t len) return NULL; } - - diff --git a/lib/inet_proto.c b/lib/inet_proto.c index 57a83511..ceda082b 100644 --- a/lib/inet_proto.c +++ b/lib/inet_proto.c @@ -67,5 +67,3 @@ int inet_proto_a2n(const char *buf) } return -1; } - - diff --git a/lib/ipx_ntop.c b/lib/ipx_ntop.c index 1e46bc21..5f646b3e 100644 --- a/lib/ipx_ntop.c +++ b/lib/ipx_ntop.c @@ -68,5 +68,3 @@ const char *ipx_ntop(int af, const void *addr, char *str, size_t len) return NULL; } - - diff --git a/lib/libgenl.c b/lib/libgenl.c index acb14783..a1a37a44 100644 --- a/lib/libgenl.c +++ b/lib/libgenl.c @@ -60,4 +60,3 @@ int genl_resolve_family(struct rtnl_handle *grth, const char *family) return genl_parse_getfamily(&req.n); } - diff --git a/lib/libnetlink.c b/lib/libnetlink.c index 245c4ca2..a90e52ca 100644 --- a/lib/libnetlink.c +++ b/lib/libnetlink.c @@ -158,7 +158,7 @@ int rtnl_send_check(struct rtnl_handle *rth, const void *buf, int len) struct nlmsgerr *err = (struct nlmsgerr*)NLMSG_DATA(h); if (h->nlmsg_len < NLMSG_LENGTH(sizeof(struct nlmsgerr))) fprintf(stderr, "ERROR truncated\n"); - else + else errno = -err->error; return -1; } diff --git a/lib/utils.c b/lib/utils.c index bd584273..b93b1dc8 100644 --- a/lib/utils.c +++ b/lib/utils.c @@ -95,7 +95,7 @@ static int get_netmask(unsigned *val, const char *arg, int base) /* try coverting dotted quad to CIDR */ if (!get_addr_1(&addr, arg, AF_INET) && addr.family == AF_INET) { int b = mask2bits(addr.data[0]); - + if (b >= 0) { *val = b; return 0; @@ -191,7 +191,7 @@ int get_time_rtt(unsigned *val, const char *arg, int *raw) *val = t; if (*val < t) *val += 1; - + return 0; } @@ -363,7 +363,7 @@ static int get_addr_ipv4(__u8 *ap, const char *cp) for (i = 0; i < 4; i++) { unsigned long n; char *endp; - + n = strtoul(cp, &endp, 0); if (n > 255) return -1; /* bogus network value */ diff --git a/netem/maketable.c b/netem/maketable.c index a5452b61..dc505328 100644 --- a/netem/maketable.c +++ b/netem/maketable.c @@ -210,7 +210,7 @@ main(int argc, char **argv) } } else { fp = stdin; - } + } x = readdoubles(fp, &limit); if (limit <= 0) { fprintf(stderr, "Nothing much read!\n"); @@ -221,7 +221,7 @@ main(int argc, char **argv) fprintf(stderr, "%d values, mu %10.4f, sigma %10.4f, rho %10.4f\n", limit, mu, sigma, rho); #endif - + table = makedist(x, limit, mu, sigma); free((void *) x); cumulativedist(table, DISTTABLESIZE, &total); diff --git a/netem/normal.c b/netem/normal.c index dbdebb1d..90963f4e 100644 --- a/netem/normal.c +++ b/netem/normal.c @@ -33,7 +33,7 @@ main(int argc, char **argv) table[i] = x; } - + printf("# This is the distribution table for the normal distribution.\n"); for (i = n = 0; i < TABLESIZE; i += 4) { int value = (int) rint(table[i]*TABLEFACTOR); diff --git a/netem/pareto.c b/netem/pareto.c index 8aa647b6..51d9437d 100644 --- a/netem/pareto.c +++ b/netem/pareto.c @@ -36,6 +36,6 @@ main(int argc, char **argv) n = 0; } } - + return 0; -} +} diff --git a/netem/paretonormal.c b/netem/paretonormal.c index ed75f288..83ec87d4 100644 --- a/netem/paretonormal.c +++ b/netem/paretonormal.c @@ -44,7 +44,7 @@ paretovalue(int i) if (dvalue > 32767) dvalue = 32767; return (int)rint(dvalue); -} +} int main(int argc, char **argv) diff --git a/tc/m_action.c b/tc/m_action.c index 5c47c825..c416d98a 100644 --- a/tc/m_action.c +++ b/tc/m_action.c @@ -141,9 +141,9 @@ static int new_cmd(char **argv) { if ((matches(*argv, "change") == 0) || - (matches(*argv, "replace") == 0) || - (matches(*argv, "delete") == 0) || - (matches(*argv, "get") == 0) || + (matches(*argv, "replace") == 0) || + (matches(*argv, "delete") == 0) || + (matches(*argv, "get") == 0) || (matches(*argv, "add") == 0)) return 1; diff --git a/tc/tc_core.c b/tc/tc_core.c index 194028ae..7bbe0d73 100644 --- a/tc/tc_core.c +++ b/tc/tc_core.c @@ -145,7 +145,7 @@ int tc_calc_rtable(struct tc_ratespec *r, __u32 *rtab, rtab[i] = tc_calc_xmittime(bps, sz); } - r->cell_align = -1; + r->cell_align = -1; r->cell_log = cell_log; r->linklayer = (linklayer & TC_LINKLAYER_MASK); return cell_log;