Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 16 Apr 2021 02:43:02 GMT
From:      Ryan Moeller <freqlabs@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 1310ff46bf39 - stable/13 - ifconfig: Reuse media state in ifmedia_getstate
Message-ID:  <202104160243.13G2h2DG029098@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by freqlabs:

URL: https://cgit.FreeBSD.org/src/commit/?id=1310ff46bf39ee27873eba67fb4aeaf2917bab3d

commit 1310ff46bf39ee27873eba67fb4aeaf2917bab3d
Author:     Ryan Moeller <freqlabs@FreeBSD.org>
AuthorDate: 2021-04-16 02:32:25 +0000
Commit:     Ryan Moeller <freqlabs@FreeBSD.org>
CommitDate: 2021-04-16 02:42:45 +0000

    ifconfig: Reuse media state in ifmedia_getstate
    
    This restores behavior lost in code cleanup, fixing a regression after
    2803fa471e77dc8f227fe00bbf075de7feb10022 where changing media options
    only applies some of the changes, not all.
    
    Reported by:    np
    Reviewed by:    donner
    Differential Revision:  https://reviews.freebsd.org/D29741
    
    (cherry picked from commit 407fb44c920a580a30dfe7d1add796a7b35a5ac7)
---
 sbin/ifconfig/ifmedia.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/sbin/ifconfig/ifmedia.c b/sbin/ifconfig/ifmedia.c
index 66eb40254889..aacf34a13248 100644
--- a/sbin/ifconfig/ifmedia.c
+++ b/sbin/ifconfig/ifmedia.c
@@ -159,7 +159,10 @@ free:
 struct ifmediareq *
 ifmedia_getstate(void)
 {
-	static struct ifmediareq *ifmr;
+	static struct ifmediareq *ifmr = NULL;
+
+	if (ifmr != NULL)
+		return (ifmr);
 
 	if (ifconfig_media_get_mediareq(lifh, name, &ifmr) == -1)
 		errc(1, ifconfig_err_errno(lifh),



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202104160243.13G2h2DG029098>