Index | Thread | Search

From:
Rafael Sadowski <rafael@sizeofvoid.org>
Subject:
Fix misleading XXX comments in vfs_lookup.c
To:
tech@openbsd.org
Date:
Mon, 9 Jun 2025 08:11:43 +0200

Download raw body.

Thread
  • Rafael Sadowski:

    Fix misleading XXX comments in vfs_lookup.c

I spent considerable time investigating these XXX markers thinking
there was a bug or performance issue, only to discover the
comments are simply inaccurate.

1. It's not the "last" component - this code runs for every component
   during path traversal. 
2. The XXX suggests there's a problem or TODO, but the code is actually
   correct and cannot be optimized further

The patch replaces them with correct descriptions of what the code
actually does.

diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c
index e437f4ea27b..a1d34a7ab5c 100644
--- a/sys/kern/vfs_lookup.c
+++ b/sys/kern/vfs_lookup.c
@@ -456,7 +456,7 @@ dirloop:
 	 */
 	cnp->cn_consume = 0;
 
-	/* XXX: Figure out the length of the last component. */
+	/* Calculate the length of the current path component */
 	cp = cnp->cn_nameptr;
 	while (*cp && (*cp != '/'))
 		cp++;
@@ -758,7 +758,7 @@ vfs_relookup(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp)
 	 */
 
 #ifdef NAMEI_DIAGNOSTIC
-	/* XXX: Figure out the length of the last component. */
+	/* Verify component length and ensure this is the last component. */
 	cp = cnp->cn_nameptr;
 	while (*cp && (*cp != '/')) {
 		cp++;