From a4ae4201a45858516cfb3e63ffd12c2d12acbb70 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Thu, 22 Apr 2010 13:59:45 +0200 Subject: fix lots of compilation warnings in example files They have been spotted by -Wall -Wextra Signed-off-by: Pablo Neira Ayuso --- examples/genl-family-get.c | 3 +-- examples/rtnl-link-dump.c | 3 +-- examples/rtnl-link-dump2.c | 3 +-- examples/rtnl-link-dump3.c | 2 +- examples/rtnl-link-event.c | 3 --- examples/rtnl-link-set.c | 6 ++++-- examples/rtnl-route-dump.c | 22 +++++++++++----------- 7 files changed, 19 insertions(+), 23 deletions(-) diff --git a/examples/genl-family-get.c b/examples/genl-family-get.c index 73a7574..7594003 100644 --- a/examples/genl-family-get.c +++ b/examples/genl-family-get.c @@ -1,6 +1,7 @@ #include #include #include +#include #include #include @@ -36,7 +37,6 @@ static int parse_mc_grps_cb(const struct nlattr *attr, void *data) static void parse_genl_mc_grps(struct nlattr *nested) { struct nlattr *pos; - int len; mnl_attr_for_each_nested(pos, nested) { struct nlattr *tb[CTRL_ATTR_MCAST_GRP_MAX+1] = {}; @@ -83,7 +83,6 @@ static int parse_family_ops_cb(const struct nlattr *attr, void *data) static void parse_genl_family_ops(struct nlattr *nested) { struct nlattr *pos; - int len; mnl_attr_for_each_nested(pos, nested) { struct nlattr *tb[CTRL_ATTR_OP_MAX+1] = {}; diff --git a/examples/rtnl-link-dump.c b/examples/rtnl-link-dump.c index 2b9f472..e3cba05 100644 --- a/examples/rtnl-link-dump.c +++ b/examples/rtnl-link-dump.c @@ -1,6 +1,7 @@ #include #include #include +#include #include #include @@ -39,8 +40,6 @@ static int data_cb(const struct nlmsghdr *nlh, void *data) { struct nlattr *tb[IFLA_MAX+1] = {}; struct ifinfomsg *ifm = mnl_nlmsg_get_payload(nlh); - int len = nlh->nlmsg_len; - struct nlattr *attr; printf("index=%d type=%d flags=%d family=%d ", ifm->ifi_index, ifm->ifi_type, diff --git a/examples/rtnl-link-dump2.c b/examples/rtnl-link-dump2.c index eda5453..df61c43 100644 --- a/examples/rtnl-link-dump2.c +++ b/examples/rtnl-link-dump2.c @@ -1,6 +1,7 @@ #include #include #include +#include #include #include @@ -36,8 +37,6 @@ static int data_attr_cb(const struct nlattr *attr, void *data) static int data_cb(const struct nlmsghdr *nlh, void *data) { struct ifinfomsg *ifm = mnl_nlmsg_get_payload(nlh); - int len = nlh->nlmsg_len; - struct nlattr *attr; printf("index=%d type=%d flags=%d family=%d ", ifm->ifi_index, ifm->ifi_type, diff --git a/examples/rtnl-link-dump3.c b/examples/rtnl-link-dump3.c index fc887ff..4dc20af 100644 --- a/examples/rtnl-link-dump3.c +++ b/examples/rtnl-link-dump3.c @@ -1,6 +1,7 @@ #include #include #include +#include #include #include @@ -10,7 +11,6 @@ static int data_cb(const struct nlmsghdr *nlh, void *data) { struct ifinfomsg *ifm = mnl_nlmsg_get_payload(nlh); - int len = nlh->nlmsg_len; struct nlattr *attr; printf("index=%d type=%d flags=%d family=%d ", diff --git a/examples/rtnl-link-event.c b/examples/rtnl-link-event.c index 17f479f..bf4d845 100644 --- a/examples/rtnl-link-event.c +++ b/examples/rtnl-link-event.c @@ -39,8 +39,6 @@ static int data_cb(const struct nlmsghdr *nlh, void *data) { struct nlattr *tb[IFLA_MAX+1] = {}; struct ifinfomsg *ifm = mnl_nlmsg_get_payload(nlh); - int len = nlh->nlmsg_len; - struct nlattr *attr; printf("index=%d type=%d flags=%d family=%d ", ifm->ifi_index, ifm->ifi_type, @@ -66,7 +64,6 @@ int main() { struct mnl_socket *nl; char buf[getpagesize()]; - struct nlmsghdr *nlh = (struct nlmsghdr *) buf; int ret; nl = mnl_socket_open(NETLINK_ROUTE); diff --git a/examples/rtnl-link-set.c b/examples/rtnl-link-set.c index 9be6635..87ac167 100644 --- a/examples/rtnl-link-set.c +++ b/examples/rtnl-link-set.c @@ -1,6 +1,8 @@ #include #include #include +#include +#include #include #include @@ -21,9 +23,9 @@ int main(int argc, char *argv[]) exit(EXIT_FAILURE); } - if (strncasecmp(argv[2], "up") == 0) + if (strncasecmp(argv[2], "up", strlen("up")) == 0) oper = IF_OPER_UP; - else if (strncasecmp(argv[2], "down") == 0) + else if (strncasecmp(argv[2], "down", strlen("down")) == 0) oper = IF_OPER_DOWN; else { fprintf(stderr, "%s is not `up' nor `down'\n", argv[2]); diff --git a/examples/rtnl-route-dump.c b/examples/rtnl-route-dump.c index 4241cf8..41ab10d 100644 --- a/examples/rtnl-route-dump.c +++ b/examples/rtnl-route-dump.c @@ -1,6 +1,8 @@ #include #include #include +#include +#include #include #include @@ -9,9 +11,6 @@ static int data_attr_cb2(const struct nlattr *attr, void *data) { - const struct nlattr **tb = (const struct nlattr **)data; - int type = mnl_attr_get_type(attr); - if (mnl_attr_type_valid(attr, RTAX_MAX) < 0) { perror("mnl_attr_type_valid"); return MNL_CB_ERROR; @@ -29,10 +28,12 @@ static void attributes_show_ipv4(struct nlattr *tb[]) printf("table=%u ", mnl_attr_get_u32(tb[RTA_TABLE])); } if (tb[RTA_DST]) { - printf("dst=%s ", inet_ntoa(mnl_attr_get_u32(tb[RTA_DST]))); + struct in_addr *addr = mnl_attr_get_payload(tb[RTA_DST]); + printf("dst=%s ", inet_ntoa(*addr)); } if (tb[RTA_SRC]) { - printf("src=%s ", inet_ntoa(mnl_attr_get_u32(tb[RTA_SRC]))); + struct in_addr *addr = mnl_attr_get_payload(tb[RTA_SRC]); + printf("src=%s ", inet_ntoa(*addr)); } if (tb[RTA_OIF]) { printf("oif=%u ", mnl_attr_get_u32(tb[RTA_OIF])); @@ -41,11 +42,12 @@ static void attributes_show_ipv4(struct nlattr *tb[]) printf("flow=%u ", mnl_attr_get_u32(tb[RTA_FLOW])); } if (tb[RTA_PREFSRC]) { - printf("prefsrc=%s ", - inet_ntoa(mnl_attr_get_u32(tb[RTA_PREFSRC]))); + struct in_addr *addr = mnl_attr_get_payload(tb[RTA_PREFSRC]); + printf("prefsrc=%s ", inet_ntoa(*addr)); } if (tb[RTA_GATEWAY]) { - printf("gw=%s ", inet_ntoa(mnl_attr_get_u32(tb[RTA_GATEWAY]))); + struct in_addr *addr = mnl_attr_get_payload(tb[RTA_GATEWAY]); + printf("gw=%s ", inet_ntoa(*addr)); } if (tb[RTA_METRICS]) { int i; @@ -56,7 +58,7 @@ static void attributes_show_ipv4(struct nlattr *tb[]) for (i=0; inlmsg_len; - struct nlattr *attr; /* protocol family = AF_INET | AF_INET6 */ printf("family=%u ", rm->rtm_family); -- cgit v1.2.3