Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F103152804
D40535.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D40535.diff
View Options
diff --git a/sbin/ifconfig/ifconfig.h b/sbin/ifconfig/ifconfig.h
--- a/sbin/ifconfig/ifconfig.h
+++ b/sbin/ifconfig/ifconfig.h
@@ -251,7 +251,6 @@
void opt_register(struct option *);
extern ifconfig_handle_t *lifh;
-extern struct ifreq ifr;
extern int allmedia;
extern int exit_code;
extern char *f_inet, *f_inet6, *f_ether, *f_addr;
diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c
--- a/sbin/ifconfig/ifconfig.c
+++ b/sbin/ifconfig/ifconfig.c
@@ -85,14 +85,6 @@
ifconfig_handle_t *lifh;
-/*
- * Since "struct ifreq" is composed of various union members, callers
- * should pay special attention to interpret the value.
- * (.e.g. little/big endian difference in the structure.)
- */
-struct ifreq ifr;
-
-//char name[IFNAMSIZ];
#ifdef WITHOUT_NETLINK
static char *descr = NULL;
static size_t descrlen = 64;
diff --git a/sbin/ifconfig/ifmedia.c b/sbin/ifconfig/ifmedia.c
--- a/sbin/ifconfig/ifmedia.c
+++ b/sbin/ifconfig/ifmedia.c
@@ -179,10 +179,11 @@
{
struct ifmediareq *ifmr = (struct ifmediareq *)arg;
static bool did_it = false;
+ struct ifreq ifr = {};
if (!did_it) {
ifr.ifr_media = ifmr->ifm_current;
- if (ioctl_ctx(ctx, SIOCSIFMEDIA, (caddr_t)&ifr) < 0)
+ if (ioctl_ctx_ifr(ctx, SIOCSIFMEDIA, &ifr) < 0)
err(1, "SIOCSIFMEDIA (media)");
free(ifmr);
did_it = true;
@@ -208,11 +209,9 @@
*/
subtype = get_media_subtype(ifmr->ifm_ulist[0], val);
- strlcpy(ifr.ifr_name, ctx->ifname, sizeof(ifr.ifr_name));
- ifr.ifr_media = (ifmr->ifm_current & IFM_IMASK) |
+ ifmr->ifm_current = (ifmr->ifm_current & IFM_IMASK) |
IFM_TYPE(ifmr->ifm_ulist[0]) | subtype;
- ifmr->ifm_current = ifr.ifr_media;
callback_register(setifmediacallback, (void *)ifmr);
}
@@ -240,18 +239,15 @@
options = get_media_options(ifmr->ifm_ulist[0], val);
- strlcpy(ifr.ifr_name, ctx->ifname, sizeof(ifr.ifr_name));
- ifr.ifr_media = ifmr->ifm_current;
if (clear)
- ifr.ifr_media &= ~options;
+ ifmr->ifm_current &= ~options;
else {
if (options & IFM_HDX) {
- ifr.ifr_media &= ~IFM_FDX;
+ ifmr->ifm_current &= ~IFM_FDX;
options &= ~IFM_HDX;
}
- ifr.ifr_media |= options;
+ ifmr->ifm_current |= options;
}
- ifmr->ifm_current = ifr.ifr_media;
callback_register(setifmediacallback, (void *)ifmr);
}
@@ -267,10 +263,8 @@
if (inst < 0 || inst > (int)IFM_INST_MAX)
errx(1, "invalid media instance: %s", val);
- strlcpy(ifr.ifr_name, ctx->ifname, sizeof(ifr.ifr_name));
- ifr.ifr_media = (ifmr->ifm_current & ~IFM_IMASK) | inst << IFM_ISHIFT;
+ ifmr->ifm_current = (ifmr->ifm_current & ~IFM_IMASK) | inst << IFM_ISHIFT;
- ifmr->ifm_current = ifr.ifr_media;
callback_register(setifmediacallback, (void *)ifmr);
}
@@ -284,10 +278,8 @@
mode = get_media_mode(ifmr->ifm_ulist[0], val);
- strlcpy(ifr.ifr_name, ctx->ifname, sizeof(ifr.ifr_name));
- ifr.ifr_media = (ifmr->ifm_current & ~IFM_MMASK) | mode;
+ ifmr->ifm_current = (ifmr->ifm_current & ~IFM_MMASK) | mode;
- ifmr->ifm_current = ifr.ifr_media;
callback_register(setifmediacallback, (void *)ifmr);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 22, 4:16 PM (5 h, 35 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14774198
Default Alt Text
D40535.diff (2 KB)
Attached To
Mode
D40535: ifconfig: remove global 'ifr' usage from ifmedia.c & remove 'ifr'.
Attached
Detach File
Event Timeline
Log In to Comment