aboutsummaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-01-08 09:07:50 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2010-01-08 09:07:50 +0100
commit9037787eaee5efb58fd46f326397193b16b161dd (patch)
treedfd0e7d93faf711ca7dcf8c7fe0abfb21082e3d3 /networking
parentef3817c6dcbf9270d36b48a0547e507221abce74 (diff)
downloadbusybox-9037787eaee5efb58fd46f326397193b16b161dd.tar.gz
*: fix places where we were still using malloc/realloc
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking')
-rw-r--r--networking/libiproute/ipaddress.c42
1 files changed, 22 insertions, 20 deletions
diff --git a/networking/libiproute/ipaddress.c b/networking/libiproute/ipaddress.c
index c450c6a9f..03f5073fb 100644
--- a/networking/libiproute/ipaddress.c
+++ b/networking/libiproute/ipaddress.c
@@ -97,9 +97,8 @@ static void print_queuelen(char *name)
static NOINLINE int print_linkinfo(const struct nlmsghdr *n)
{
struct ifinfomsg *ifi = NLMSG_DATA(n);
- struct rtattr * tb[IFLA_MAX+1];
+ struct rtattr *tb[IFLA_MAX+1];
int len = n->nlmsg_len;
- unsigned m_flag = 0;
if (n->nlmsg_type != RTM_NEWLINK && n->nlmsg_type != RTM_DELLINK)
return 0;
@@ -130,22 +129,27 @@ static NOINLINE int print_linkinfo(const struct nlmsghdr *n)
printf("Deleted ");
printf("%d: %s", ifi->ifi_index,
- tb[IFLA_IFNAME] ? (char*)RTA_DATA(tb[IFLA_IFNAME]) : "<nil>");
-
- if (tb[IFLA_LINK]) {
- SPRINT_BUF(b1);
- int iflink = *(int*)RTA_DATA(tb[IFLA_LINK]);
- if (iflink == 0)
- printf("@NONE: ");
- else {
- printf("@%s: ", ll_idx_n2a(iflink, b1));
- m_flag = ll_index_to_flags(iflink);
- m_flag = !(m_flag & IFF_UP);
+ /*tb[IFLA_IFNAME] ? (char*)RTA_DATA(tb[IFLA_IFNAME]) : "<nil>" - we checked tb[IFLA_IFNAME] above*/
+ (char*)RTA_DATA(tb[IFLA_IFNAME])
+ );
+
+ {
+ unsigned m_flag = 0;
+ if (tb[IFLA_LINK]) {
+ SPRINT_BUF(b1);
+ int iflink = *(int*)RTA_DATA(tb[IFLA_LINK]);
+ if (iflink == 0)
+ printf("@NONE: ");
+ else {
+ printf("@%s: ", ll_idx_n2a(iflink, b1));
+ m_flag = ll_index_to_flags(iflink);
+ m_flag = !(m_flag & IFF_UP);
+ }
+ } else {
+ printf(": ");
}
- } else {
- printf(": ");
+ print_link_flags(ifi->ifi_flags, m_flag);
}
- print_link_flags(ifi->ifi_flags, m_flag);
if (tb[IFLA_MTU])
printf("mtu %u ", *(int*)RTA_DATA(tb[IFLA_MTU]));
@@ -382,12 +386,10 @@ static int FAST_FUNC store_nlmsg(const struct sockaddr_nl *who, struct nlmsghdr
struct nlmsg_list *h;
struct nlmsg_list **lp;
- h = malloc(n->nlmsg_len+sizeof(void*));
- if (h == NULL)
- return -1;
+ h = xzalloc(n->nlmsg_len + sizeof(void*));
memcpy(&h->h, n, n->nlmsg_len);
- h->next = NULL;
+ /*h->next = NULL; - xzalloc did it */
for (lp = linfo; *lp; lp = &(*lp)->next)
continue;