git: 130383f2f10c - main - linux(4): Make linux_ifflags return a value

From: Dmitry Chagin <dchagin_at_FreeBSD.org>
Date: Sat, 04 Mar 2023 09:12:42 UTC
The branch main has been updated by dchagin:

URL: https://cgit.FreeBSD.org/src/commit/?id=130383f2f10c110de3379a302766fa098290d5ac

commit 130383f2f10c110de3379a302766fa098290d5ac
Author:     Dmitry Chagin <dchagin@FreeBSD.org>
AuthorDate: 2023-03-04 09:11:38 +0000
Commit:     Dmitry Chagin <dchagin@FreeBSD.org>
CommitDate: 2023-03-04 09:11:38 +0000

    linux(4): Make linux_ifflags return a value
    
    To simplify the use of the function in the printf-like statements.
    
    Differential Revision:  https://reviews.freebsd.org/D38830
---
 sys/compat/linsysfs/linsysfs.c  |  4 +---
 sys/compat/linux/linux.c        | 29 +++++++++++++++--------------
 sys/compat/linux/linux_common.h |  2 +-
 sys/compat/linux/linux_ioctl.c  |  4 ++--
 4 files changed, 19 insertions(+), 20 deletions(-)

diff --git a/sys/compat/linsysfs/linsysfs.c b/sys/compat/linsysfs/linsysfs.c
index f916858a17a7..0c0744a054a0 100644
--- a/sys/compat/linsysfs/linsysfs.c
+++ b/sys/compat/linsysfs/linsysfs.c
@@ -98,13 +98,11 @@ static int
 linsysfs_ifnet_flags(PFS_FILL_ARGS)
 {
 	struct ifnet *ifp;
-	unsigned short flags;
 
 	ifp = ifname_linux_to_bsd(td, pn->pn_parent->pn_name, NULL);
 	if (ifp == NULL)
 		return (ENOENT);
-	linux_ifflags(ifp, &flags);
-	sbuf_printf(sb, "0x%x\n", flags);
+	sbuf_printf(sb, "0x%x\n", linux_ifflags(ifp));
 	return (0);
 }
 
diff --git a/sys/compat/linux/linux.c b/sys/compat/linux/linux.c
index a7844f4bbbcf..135bc10e2dc1 100644
--- a/sys/compat/linux/linux.c
+++ b/sys/compat/linux/linux.c
@@ -416,33 +416,34 @@ ifname_linux_to_bsd(struct thread *td, const char *lxname, char *bsdname)
 	return (arg.ifp);
 }
 
-void
-linux_ifflags(struct ifnet *ifp, short *flags)
+unsigned short
+linux_ifflags(struct ifnet *ifp)
 {
-	unsigned short fl;
+	unsigned short fl, flags;
 
 	fl = (if_getflags(ifp) | if_getdrvflags(ifp)) & 0xffff;
-	*flags = 0;
+	flags = 0;
 	if (fl & IFF_UP)
-		*flags |= LINUX_IFF_UP;
+		flags |= LINUX_IFF_UP;
 	if (fl & IFF_BROADCAST)
-		*flags |= LINUX_IFF_BROADCAST;
+		flags |= LINUX_IFF_BROADCAST;
 	if (fl & IFF_DEBUG)
-		*flags |= LINUX_IFF_DEBUG;
+		flags |= LINUX_IFF_DEBUG;
 	if (fl & IFF_LOOPBACK)
-		*flags |= LINUX_IFF_LOOPBACK;
+		flags |= LINUX_IFF_LOOPBACK;
 	if (fl & IFF_POINTOPOINT)
-		*flags |= LINUX_IFF_POINTOPOINT;
+		flags |= LINUX_IFF_POINTOPOINT;
 	if (fl & IFF_DRV_RUNNING)
-		*flags |= LINUX_IFF_RUNNING;
+		flags |= LINUX_IFF_RUNNING;
 	if (fl & IFF_NOARP)
-		*flags |= LINUX_IFF_NOARP;
+		flags |= LINUX_IFF_NOARP;
 	if (fl & IFF_PROMISC)
-		*flags |= LINUX_IFF_PROMISC;
+		flags |= LINUX_IFF_PROMISC;
 	if (fl & IFF_ALLMULTI)
-		*flags |= LINUX_IFF_ALLMULTI;
+		flags |= LINUX_IFF_ALLMULTI;
 	if (fl & IFF_MULTICAST)
-		*flags |= LINUX_IFF_MULTICAST;
+		flags |= LINUX_IFF_MULTICAST;
+	return (flags);
 }
 
 static u_int
diff --git a/sys/compat/linux/linux_common.h b/sys/compat/linux/linux_common.h
index 9ebaff26b9ff..c25c4abf18ae 100644
--- a/sys/compat/linux/linux_common.h
+++ b/sys/compat/linux/linux_common.h
@@ -36,7 +36,7 @@ int	ifname_bsd_to_linux_name(const char *, char *, size_t);
 
 struct ifnet	*ifname_linux_to_bsd(struct thread *td,
 		    const char *lxname, char *bsdname);
-void		linux_ifflags(struct ifnet *ifp, short *flags);
+unsigned short	linux_ifflags(struct ifnet *);
 int		linux_ifhwaddr(struct ifnet *ifp, struct l_sockaddr *lsa);
 
 int		linux_to_bsd_domain(int domain);
diff --git a/sys/compat/linux/linux_ioctl.c b/sys/compat/linux/linux_ioctl.c
index 8900102bbbc7..8551ba180aa4 100644
--- a/sys/compat/linux/linux_ioctl.c
+++ b/sys/compat/linux/linux_ioctl.c
@@ -2237,9 +2237,9 @@ again:
 static int
 linux_gifflags(struct thread *td, struct ifnet *ifp, struct l_ifreq *ifr)
 {
-	l_short flags;
+	unsigned short flags;
 
-	linux_ifflags(ifp, &flags);
+	flags = linux_ifflags(ifp);
 
 	return (copyout(&flags, &ifr->ifr_flags, sizeof(flags)));
 }