Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 12 Sep 2025 16:29:01 GMT
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: bcdbeaeffccb - main - ng_device.c: improve compliance with style(9)
Message-ID:  <202509121629.58CGT1Mp019457@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by imp:

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

commit bcdbeaeffccb65574ac06001888840d9a15f4edf
Author:     Quentin Thébault <quentin.thebault@defenso.fr>
AuthorDate: 2025-09-08 13:33:03 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2025-09-12 16:24:44 +0000

    ng_device.c: improve compliance with style(9)
    
    Signed-off-by: Quentin Thébault <quentin.thebault@defenso.fr>
    Reviewed by: imp, jhb
    Pull Request: https://github.com/freebsd/freebsd-src/pull/1827
---
 sys/netgraph/ng_device.c | 63 ++++++++++++++++++++++++++----------------------
 1 file changed, 34 insertions(+), 29 deletions(-)

diff --git a/sys/netgraph/ng_device.c b/sys/netgraph/ng_device.c
index eca3a916a59f..582f877ff3ed 100644
--- a/sys/netgraph/ng_device.c
+++ b/sys/netgraph/ng_device.c
@@ -32,7 +32,7 @@
  */
 
 #if 0
-#define	DBG do { printf("ng_device: %s\n", __func__ ); } while (0)
+#define	DBG do { printf("ng_device: %s\n", __func__); } while (0)
 #else
 #define	DBG do {} while (0)
 #endif
@@ -150,9 +150,11 @@ static struct cdevsw ngd_cdevsw = {
 	.d_name =	NG_DEVICE_DEVNAME,
 };
 
-/******************************************************************************
+/*
+ *****************************************************************************
  *  Netgraph methods
- ******************************************************************************/
+ *****************************************************************************
+ */
 
 /*
  * Handle loading and unloading for this node type.
@@ -202,13 +204,13 @@ ng_device_constructor(node_p node)
 
 	priv->ngddev = make_dev(&ngd_cdevsw, priv->unit, UID_ROOT,
 	    GID_WHEEL, 0600, NG_DEVICE_DEVNAME "%d", priv->unit);
-	if(priv->ngddev == NULL) {
-		printf("%s(): make_dev() failed\n",__func__);
+	if (priv->ngddev == NULL) {
+		printf("%s(): make_dev() failed\n", __func__);
 		mtx_destroy(&priv->ngd_mtx);
 		mtx_destroy(&priv->readq.ifq_mtx);
 		free_unr(ngd_unit, priv->unit);
 		free(priv, M_NETGRAPH);
-		return(EINVAL);
+		return (EINVAL);
 	}
 	/* XXX: race here? */
 	priv->ngddev->si_drv1 = priv;
@@ -218,7 +220,7 @@ ng_device_constructor(node_p node)
 		log(LOG_WARNING, "%s: can't acquire netgraph name\n",
 		    devtoname(priv->ngddev));
 
-	return(0);
+	return (0);
 }
 
 /*
@@ -286,7 +288,7 @@ ng_device_newhook(node_p node, hook_p hook, const char *name)
 
 	priv->hook = hook;
 
-	return(0);
+	return (0);
 }
 
 /*
@@ -319,7 +321,7 @@ ng_device_rcvdata(hook_p hook, item_p item)
 	}
 	mtx_unlock(&priv->ngd_mtx);
 
-	return(0);
+	return (0);
 }
 
 /*
@@ -344,7 +346,7 @@ ng_device_disconnect(hook_p hook)
 
 	ng_rmnode_self(NG_HOOK_NODE(hook));
 
-	return(0);
+	return (0);
 }
 
 /*
@@ -357,9 +359,11 @@ ng_device_shutdown(node_p node)
 	return (0);
 }
 
-/******************************************************************************
+/*
+ *****************************************************************************
  *  Device methods
- ******************************************************************************/
+ *****************************************************************************
+ */
 
 /*
  * the device is opened
@@ -367,7 +371,7 @@ ng_device_shutdown(node_p node)
 static int
 ngdopen(struct cdev *dev, int flag, int mode, struct thread *td)
 {
-	priv_p	priv = (priv_p )dev->si_drv1;
+	priv_p	priv = (priv_p)dev->si_drv1;
 
 	DBG;
 
@@ -375,7 +379,7 @@ ngdopen(struct cdev *dev, int flag, int mode, struct thread *td)
 	priv->flags |= NGDF_OPEN;
 	mtx_unlock(&priv->ngd_mtx);
 
-	return(0);
+	return (0);
 }
 
 /*
@@ -384,14 +388,14 @@ ngdopen(struct cdev *dev, int flag, int mode, struct thread *td)
 static int
 ngdclose(struct cdev *dev, int flag, int mode, struct thread *td)
 {
-	priv_p	priv = (priv_p )dev->si_drv1;
+	priv_p	priv = (priv_p)dev->si_drv1;
 
 	DBG;
 	mtx_lock(&priv->ngd_mtx);
 	priv->flags &= ~NGDF_OPEN;
 	mtx_unlock(&priv->ngd_mtx);
 
-	return(0);
+	return (0);
 }
 
 /*
@@ -435,21 +439,22 @@ ngdioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag,
  *
  */
 static int
-ngdioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *td)
+ngdioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
+    struct thread *td)
 {
 	struct ngd_softc *sc = &ngd_softc;
-	struct ngd_connection * connection = NULL;
-	struct ngd_connection * tmp;
+	struct ngd_connection *connection = NULL;
+	struct ngd_connection *tmp;
 	int error = 0;
 	struct ng_mesg *msg;
-	struct ngd_param_s * datap;
+	struct ngd_param_s *datap;
 
 	DBG;
 
 	NG_MKMESSAGE(msg, NGM_DEVICE_COOKIE, cmd, sizeof(struct ngd_param_s),
 			M_NOWAIT);
 	if (msg == NULL) {
-		printf("%s(): msg == NULL\n",__func__);
+		printf("%s(): msg == NULL\n", __func__);
 		goto nomsg;
 	}
 
@@ -458,12 +463,12 @@ ngdioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *td
 	datap->p = addr;
 
 	NG_SEND_MSG_HOOK(error, sc->node, msg, connection->active_hook, 0);
-	if(error)
-		printf("%s(): NG_SEND_MSG_HOOK error: %d\n",__func__,error);
+	if (error)
+		printf("%s(): NG_SEND_MSG_HOOK error: %d\n", __func__, error);
 
 nomsg:
 
-	return(0);
+	return (0);
 }
 #endif /* if 0 */
 
@@ -474,7 +479,7 @@ nomsg:
 static int
 ngdread(struct cdev *dev, struct uio *uio, int flag)
 {
-	priv_p	priv = (priv_p )dev->si_drv1;
+	priv_p	priv = (priv_p)dev->si_drv1;
 	struct mbuf *m;
 	int len, error = 0;
 
@@ -510,14 +515,14 @@ ngdread(struct cdev *dev, struct uio *uio, int flag)
 
 /*
  * This function is called when our device is written to.
- * We read the data from userland into mbuf chain and pass it to the remote hook.
- *
+ * We read the data from userland into mbuf chain and pass it to the remote
+ * hook.
  */
 static int
 ngdwrite(struct cdev *dev, struct uio *uio, int flag)
 {
 	struct epoch_tracker et;
-	priv_p	priv = (priv_p )dev->si_drv1;
+	priv_p	priv = (priv_p)dev->si_drv1;
 	struct mbuf *m;
 	int error = 0;
 
@@ -547,7 +552,7 @@ ngdwrite(struct cdev *dev, struct uio *uio, int flag)
 static int
 ngdpoll(struct cdev *dev, int events, struct thread *td)
 {
-	priv_p	priv = (priv_p )dev->si_drv1;
+	priv_p	priv = (priv_p)dev->si_drv1;
 	int revents = 0;
 
 	if (events & (POLLIN | POLLRDNORM) &&



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