Module Name:    src
Committed By:   kre
Date:           Sat Apr 29 23:30:18 UTC 2023

Modified Files:
        src/sys/kern: vfs_subr.c
        src/sys/sys: sdt.h

Log Message:
Fix builds (hopefully) when DTRACE hooks are not included.


To generate a diff of this commit:
cvs rdiff -u -r1.498 -r1.499 src/sys/kern/vfs_subr.c
cvs rdiff -u -r1.15 -r1.16 src/sys/sys/sdt.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/vfs_subr.c
diff -u src/sys/kern/vfs_subr.c:1.498 src/sys/kern/vfs_subr.c:1.499
--- src/sys/kern/vfs_subr.c:1.498	Sat Apr 29 10:07:30 2023
+++ src/sys/kern/vfs_subr.c	Sat Apr 29 23:30:18 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_subr.c,v 1.498 2023/04/29 10:07:30 riastradh Exp $	*/
+/*	$NetBSD: vfs_subr.c,v 1.499 2023/04/29 23:30:18 kre Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 2004, 2005, 2007, 2008, 2019, 2020
@@ -69,7 +69,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.498 2023/04/29 10:07:30 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.499 2023/04/29 23:30:18 kre Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_43.h"
@@ -714,7 +714,7 @@ vn_syncer_add1(struct vnode *vp, int del
 void
 vn_syncer_add_to_worklist(struct vnode *vp, int delayx)
 {
-	vnode_impl_t *vip = VNODE_TO_VIMPL(vp);
+	SDT_VAR_DECL(vnode_impl_t *vip = VNODE_TO_VIMPL(vp));
 
 	KASSERT(mutex_owned(vp->v_interlock));
 
@@ -840,9 +840,10 @@ sched_sync(void *arg)
 	struct vnode *vp;
 	struct mount *mp;
 	time_t starttime, endtime;
-	int vdelay, oslot, nslot, delayx;
+	int vdelay, nslot, delayx;
+	SDT_VAR_DECL(int oslot);
 	bool synced;
-	int error;
+	SDT_VAR_DECL(int error);
 
 	for (;;) {
 		starttime = time_second;
@@ -861,14 +862,21 @@ sched_sync(void *arg)
 			}
 
 			vdelay = sync_delay(mp);
+#ifdef KDTRACE_HOOKS
 			oslot = mp->mnt_synclist_slot;
+#endif
 			nslot = sync_delay_slot(vdelay);
 			mp->mnt_synclist_slot = nslot;
 			SDT_PROBE4(vfs, syncer, worklist, mount__update,
 			    mp, vdelay, oslot, nslot);
 
 			SDT_PROBE1(vfs, syncer, sync, mount__start,  mp);
-			error = VFS_SYNC(mp, MNT_LAZY, curlwp->l_cred);
+#ifdef KDTRACE_HOOKS
+			error =
+#else
+			(void)
+#endif
+				VFS_SYNC(mp, MNT_LAZY, curlwp->l_cred);
 			SDT_PROBE2(vfs, syncer, sync, mount__done,
 			    mp, error);
 		}
@@ -918,7 +926,9 @@ sched_sync(void *arg)
 				 * into the future.
 				 */
 				delayx = synced ? syncdelay : lockdelay;
+#ifdef KDTRACE_HOOKS
 				oslot = vi->vi_synclist_slot;
+#endif
 				vn_syncer_add1(vp, delayx);
 				nslot = vi->vi_synclist_slot;
 				SDT_PROBE4(vfs, syncer, worklist,

Index: src/sys/sys/sdt.h
diff -u src/sys/sys/sdt.h:1.15 src/sys/sys/sdt.h:1.16
--- src/sys/sys/sdt.h:1.15	Sat Oct 29 14:00:12 2022
+++ src/sys/sys/sdt.h	Sat Apr 29 23:30:18 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdt.h,v 1.15 2022/10/29 14:00:12 riastradh Exp $	*/
+/*	$NetBSD: sdt.h,v 1.16 2023/04/29 23:30:18 kre Exp $	*/
 
 /*-
  * Copyright 2006-2008 John Birrell <j...@freebsd.org>
@@ -37,6 +37,9 @@
 
 #define	_DTRACE_VERSION	1
 
+#define SDT_PROVIDER_DEFINE(prov)
+#define SDT_PROVIDER_DECLARE(prov)
+
 #define	DTRACE_PROBE(prov, name) do {				\
 	extern void __dtrace_##prov##___##name(void);		\
 	__dtrace_##prov##___##name();				\
@@ -138,6 +141,8 @@
     arg1, xarg1, arg2, xarg2, arg3, xarg3, arg4, xarg4, arg5, xarg5, arg6,     \
     xarg6)
 
+#define	SDT_VAR_DECL(decl)					__nothing
+
 #define	DTRACE_PROBE(name)					__nothing
 #define	DTRACE_PROBE1(name, type0, arg0)			__nothing
 #define	DTRACE_PROBE2(name, type0, arg0, type1, arg1)		__nothing
@@ -334,6 +339,8 @@
 			    (uintptr_t)arg6);				       \
 	} while (0)
 
+#define	SDT_VAR_DECL(decl)	decl ;
+
 #define	DTRACE_PROBE_IMPL_START(name, arg0, arg1, arg2, arg3, arg4)	do { \
 	static SDT_PROBE_DEFINE(sdt, , , name);				     \
 	SDT_PROBE(sdt, , , name, arg0, arg1, arg2, arg3, arg4);

Reply via email to