From nobody Fri Jun 16 07:19:44 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Qj9XK4Xn9z4fZ5w; Fri, 16 Jun 2023 07:19:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Qj9XK0gkPz47fg; Fri, 16 Jun 2023 07:19:45 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1686899985; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=C5dGkOkmDEw/WQ2ySSo3TI+Wp7HQhowv/ifchSB2h+s=; b=rIpBeP7kfZtgC+Bq3E1rUQA1PrFwn2L6gLM3gWfcqzAE5c0TFtXtOX8sGrk7iM0GUr2qJ4 NtV/rdCF5gjV4qVTkdar9ukVM/mltOwYZjwMNAVDScSRj5JrRCsr47HGoyovccFVK5GA73 2lYGICcUb5wRNqGxWLkC5B6msrCDQgEXs8QtJhNAaDMgRFvS/WBWHpbbikRmF9T6Hvq7zl NOSRAN1Ufox6tt0cYaF4TEYTh4808O4SmfyPGhOs4W0qXOfnF/1KpA47KlBkYt12SnIpiV 4QsJxHRBofyXEeQUlVKa60Y1zG4Gjrok7U67HQ4Sox/4AJX2WVaHn0gxeuwl8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1686899985; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=C5dGkOkmDEw/WQ2ySSo3TI+Wp7HQhowv/ifchSB2h+s=; b=wr97j/Ce1PbHTgZED1SFxq/wwlwVG5nvFGzljQ7/PgtiFYK5DXDTr+JcgZvMGT82D5/Drt a3Dxq/krLi03A7oONFaUNWQQ+jjDa7D+VLtIRHVbkoH3ym9t0q3qffP9ukuMvqcYxqeCWf HE4EwRDhCrKGhiT26MHdAKCm0H2tvp/AARqRTtF3OEl1fkwfjKTrrzSXw9iTWojoKJKEW+ ZvA+DalKkbLsOeqvUwGjz3IKaWtwMflzwtT1Kv6PMxPVRxTpZc5gStw5Ek1vaekfvT9Qz3 449EEXPZau7EY39m61bFGV7pLXsrSQispA+sTXN8isy1s1Nwuf0Sdc7fBJvJ1w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1686899985; a=rsa-sha256; cv=none; b=gwLAbYuKqugfNDHOGLv1yCGVC/iecdZEYUF+JKXbLTwQxKWLRuPsaon5oO371QMJ2N7MJV prKATql8nGeAzyhBA7pIQm8NV2HgA8LJkiCRihMPlpPD5FQ26L++GDBp5Ri2L9Bpb3DyI6 Gd7gCs90PuYbUeIey4tuGpcrhnjUNQN+pDkC1Jd+ItY0ad9ASClHcvRZMXdUhyx0Kqwvau TAL+wX8PHowK/QOr79VOG9A56IM9bkLOJTH9fAkiNzc6yRdZuYEBrWrB91qN3Uen+N6ar7 Ws3A9/wDo5XRtMTlDdMKNNPAt0b26qd6WDzqkqefgQSBfnp2l4rIql+UnAC/vA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Qj9XJ65H8zK1p; Fri, 16 Jun 2023 07:19:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 35G7JiQV034725; Fri, 16 Jun 2023 07:19:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 35G7JiOE034724; Fri, 16 Jun 2023 07:19:44 GMT (envelope-from git) Date: Fri, 16 Jun 2023 07:19:44 GMT Message-Id: <202306160719.35G7JiOE034724@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Alexander V. Chernikov" Subject: git: f414f37e3861 - main - ifconfig: remove global 'ifr' usage from ifmedia.c & remove 'ifr'. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: melifaro X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f414f37e38614daabc1d10e37efec9ef7fa620f3 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=f414f37e38614daabc1d10e37efec9ef7fa620f3 commit f414f37e38614daabc1d10e37efec9ef7fa620f3 Author: Alexander V. Chernikov AuthorDate: 2023-06-14 13:04:10 +0000 Commit: Alexander V. Chernikov CommitDate: 2023-06-16 07:19:21 +0000 ifconfig: remove global 'ifr' usage from ifmedia.c & remove 'ifr'. Reviewed by: kp Differential Revision: https://reviews.freebsd.org/D40535 MFC after: 2 weeks --- sbin/ifconfig/ifconfig.c | 8 -------- sbin/ifconfig/ifconfig.h | 1 - sbin/ifconfig/ifmedia.c | 24 ++++++++---------------- 3 files changed, 8 insertions(+), 25 deletions(-) diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index 5ac217858057..24462f76e96c 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -85,14 +85,6 @@ static const char rcsid[] = 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/ifconfig.h b/sbin/ifconfig/ifconfig.h index 334027c36d89..49f907367b7a 100644 --- a/sbin/ifconfig/ifconfig.h +++ b/sbin/ifconfig/ifconfig.h @@ -251,7 +251,6 @@ struct option { 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/ifmedia.c b/sbin/ifconfig/ifmedia.c index 122756207d1b..395789916edb 100644 --- a/sbin/ifconfig/ifmedia.c +++ b/sbin/ifconfig/ifmedia.c @@ -179,10 +179,11 @@ setifmediacallback(if_ctx *ctx, void *arg) { 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 @@ setmedia(if_ctx *ctx, const char *val, int d __unused) */ 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 @@ domediaopt(if_ctx *ctx, const char *val, bool clear) 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 @@ setmediainst(if_ctx *ctx, const char *val, int d __unused) 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 @@ setmediamode(if_ctx *ctx, const char *val, int d __unused) 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); }