Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 3 May 2019 21:46:26 +0000 (UTC)
From:      Kirk McKusick <mckusick@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r347064 - head/sys/ufs/ufs
Message-ID:  <201905032146.x43LkQas003448@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mckusick
Date: Fri May  3 21:46:25 2019
New Revision: 347064
URL: https://svnweb.freebsd.org/changeset/base/347064

Log:
  Simplify calculation of DIRECTSIZ. No functional change intended.
  
  Suggested by: kib
  MFC after:    1 week

Modified:
  head/sys/ufs/ufs/dir.h

Modified: head/sys/ufs/ufs/dir.h
==============================================================================
--- head/sys/ufs/ufs/dir.h	Fri May  3 21:26:44 2019	(r347063)
+++ head/sys/ufs/ufs/dir.h	Fri May  3 21:46:25 2019	(r347064)
@@ -108,13 +108,11 @@ struct	direct {
  * The DIRSIZ macro gives the minimum record length which will hold
  * the directory entry.  This requires the amount of space in struct direct
  * without the d_name field, plus enough space for the name with a terminating
- * null byte (dp->d_namlen+1), rounded up to a 4 byte boundary.
- *
- * 
+ * null byte (dp->d_namlen + 1), rounded up to a 4 byte boundary.
  */
-#define	DIRECTSIZ(namlen)						\
-	((__offsetof(struct direct, d_name) +				\
-	  ((namlen)+1)*sizeof(((struct direct *)0)->d_name[0]) + 3) & ~3)
+#define	DIR_ROUNDUP	4	/* Directory name roundup size */
+#define	DIRECTSIZ(namlen) \
+    (roundup2(__offsetof(struct direct, d_name) + (namlen) + 1, DIR_ROUNDUP))
 #if (BYTE_ORDER == LITTLE_ENDIAN)
 #define	DIRSIZ(oldfmt, dp) \
     ((oldfmt) ? DIRECTSIZ((dp)->d_type) : DIRECTSIZ((dp)->d_namlen))



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