Use nitems(mib) instead of hardcoding mib's length
MFC after: 3 days
This commit is contained in:
parent
240ecb400f
commit
074a0dcceb
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=311713
@ -2418,7 +2418,7 @@ getifmtu(int ifindex)
|
|||||||
mib[3] = AF_INET6;
|
mib[3] = AF_INET6;
|
||||||
mib[4] = NET_RT_IFLIST;
|
mib[4] = NET_RT_IFLIST;
|
||||||
mib[5] = ifindex;
|
mib[5] = ifindex;
|
||||||
if (sysctl(mib, 6, NULL, &msize, NULL, 0) < 0) {
|
if (sysctl(mib, nitems(mib), NULL, &msize, NULL, 0) < 0) {
|
||||||
fatal("sysctl estimate NET_RT_IFLIST");
|
fatal("sysctl estimate NET_RT_IFLIST");
|
||||||
/*NOTREACHED*/
|
/*NOTREACHED*/
|
||||||
}
|
}
|
||||||
@ -2426,7 +2426,7 @@ getifmtu(int ifindex)
|
|||||||
fatal("malloc");
|
fatal("malloc");
|
||||||
/*NOTREACHED*/
|
/*NOTREACHED*/
|
||||||
}
|
}
|
||||||
if (sysctl(mib, 6, buf, &msize, NULL, 0) < 0) {
|
if (sysctl(mib, nitems(mib), buf, &msize, NULL, 0) < 0) {
|
||||||
fatal("sysctl NET_RT_IFLIST");
|
fatal("sysctl NET_RT_IFLIST");
|
||||||
/*NOTREACHED*/
|
/*NOTREACHED*/
|
||||||
}
|
}
|
||||||
@ -2598,7 +2598,7 @@ krtread(int again)
|
|||||||
free(buf);
|
free(buf);
|
||||||
buf = NULL;
|
buf = NULL;
|
||||||
}
|
}
|
||||||
if (sysctl(mib, 6, NULL, &msize, NULL, 0) < 0) {
|
if (sysctl(mib, nitems(mib), NULL, &msize, NULL, 0) < 0) {
|
||||||
errmsg = "sysctl estimate";
|
errmsg = "sysctl estimate";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -2606,7 +2606,7 @@ krtread(int again)
|
|||||||
errmsg = "malloc";
|
errmsg = "malloc";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (sysctl(mib, 6, buf, &msize, NULL, 0) < 0) {
|
if (sysctl(mib, nitems(mib), buf, &msize, NULL, 0) < 0) {
|
||||||
errmsg = "sysctl NET_RT_DUMP";
|
errmsg = "sysctl NET_RT_DUMP";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user