diff options
author | Thomas Haller <thaller@redhat.com> | 2018-01-16 05:45:23 (GMT) |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2018-01-16 05:45:23 (GMT) |
commit | 38baa675cf738df26eac4423a15950d1d0950ca7 (patch) | |
tree | 23408ddf38f7c2ce2ddba69e9e3f89d92ef3a0e8 /lib | |
parent | 165611034621b0eda1a4747ea382600fed436437 (diff) | |
download | libnl-38baa675cf738df26eac4423a15950d1d0950ca7.zip libnl-38baa675cf738df26eac4423a15950d1d0950ca7.tar.gz libnl-38baa675cf738df26eac4423a15950d1d0950ca7.tar.bz2 |
all: declare all variables at the beginning of scope (-Wdeclaration-after-statement)
Avoid gcc warning:
error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
Diffstat (limited to 'lib')
-rw-r--r-- | lib/netfilter/exp.c | 3 | ||||
-rw-r--r-- | lib/route/qdisc/netem.c | 24 |
2 files changed, 17 insertions, 10 deletions
diff --git a/lib/netfilter/exp.c b/lib/netfilter/exp.c index 24ec55f..8adf902 100644 --- a/lib/netfilter/exp.c +++ b/lib/netfilter/exp.c @@ -352,10 +352,11 @@ static int nfnl_exp_build_tuple(struct nl_msg *msg, const struct nfnl_exp *exp, struct nlattr *tuple, *ip, *proto; struct nl_addr *addr; int family; + int type; family = nfnl_exp_get_family(exp); - int type = exp_get_tuple_attr(cta); + type = exp_get_tuple_attr(cta); if (cta == CTA_EXPECT_NAT) tuple = nla_nest_start(msg, CTA_EXPECT_NAT_TUPLE); diff --git a/lib/route/qdisc/netem.c b/lib/route/qdisc/netem.c index c4ba2a1..d3b900a 100644 --- a/lib/route/qdisc/netem.c +++ b/lib/route/qdisc/netem.c @@ -215,6 +215,10 @@ static int netem_msg_fill_raw(struct rtnl_tc *tc, void *data, unsigned char set_correlation = 0, set_reorder = 0; unsigned char set_corrupt = 0, set_dist = 0; + struct nlattr* head; + struct nlattr* tail; + int old_len; + if (!netem) BUG(); @@ -319,13 +323,13 @@ static int netem_msg_fill_raw(struct rtnl_tc *tc, void *data, * remainder of the message. That's just the way that sch_netem expects it. * Maybe there's a more succinct way to do this at a higher level. */ - struct nlattr* head = (struct nlattr *)(NLMSG_DATA(msg->nm_nlh) + - NLMSG_LENGTH(sizeof(struct tcmsg)) - NLMSG_ALIGNTO); + head = (struct nlattr *)(NLMSG_DATA(msg->nm_nlh) + + NLMSG_LENGTH(sizeof(struct tcmsg)) - NLMSG_ALIGNTO); - struct nlattr* tail = (struct nlattr *)(((void *) (msg->nm_nlh)) + - NLMSG_ALIGN(msg->nm_nlh->nlmsg_len)); + tail = (struct nlattr *)(((void *) (msg->nm_nlh)) + + NLMSG_ALIGN(msg->nm_nlh->nlmsg_len)); - int old_len = head->nla_len; + old_len = head->nla_len; head->nla_len = (void *)tail - (void *)head; msg->nm_nlh->nlmsg_len += (head->nla_len - old_len); @@ -875,9 +879,6 @@ int rtnl_netem_get_delay_distribution(struct rtnl_qdisc *qdisc, int16_t **dist_p int rtnl_netem_set_delay_distribution(struct rtnl_qdisc *qdisc, const char *dist_type) { struct rtnl_netem *netem; - if (!(netem = rtnl_tc_data(TC_CAST(qdisc)))) - BUG(); - FILE *f; int n = 0; size_t i; @@ -885,6 +886,7 @@ int rtnl_netem_set_delay_distribution(struct rtnl_qdisc *qdisc, const char *dist char *line; char name[NAME_MAX]; char dist_suffix[] = ".dist"; + char *test_suffix; /* Check several locations for the dist file */ char *test_path[] = { @@ -895,8 +897,12 @@ int rtnl_netem_set_delay_distribution(struct rtnl_qdisc *qdisc, const char *dist "/usr/local/lib/tc/", }; + if (!(netem = rtnl_tc_data(TC_CAST(qdisc)))) + BUG(); + /* If the given filename already ends in .dist, don't append it later */ - char *test_suffix = strstr(dist_type, dist_suffix); + test_suffix = strstr(dist_type, dist_suffix); + if (test_suffix != NULL && strlen(test_suffix) == 5) strcpy(dist_suffix, ""); |