Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 29 Jul 2017 23:31:21 +0000 (UTC)
From:      Conrad Meyer <cem@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r321707 - head/sys/kern
Message-ID:  <201707292331.v6TNVLLO017763@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: cem
Date: Sat Jul 29 23:31:21 2017
New Revision: 321707
URL: https://svnweb.freebsd.org/changeset/base/321707

Log:
  kldstat: Use sizeof in place of named constants for sizing
  
  No functional change.
  
  This is handy for FreeBSD derivatives that want to modify the value of
  MAXPATHLEN, but not the kld_file_stat ABI.
  
  Submitted by:	Siddhant Agarwal <sagarwal AT isilon.com>
  Sponsored by:	Dell EMC Isilon

Modified:
  head/sys/kern/kern_linker.c

Modified: head/sys/kern/kern_linker.c
==============================================================================
--- head/sys/kern/kern_linker.c	Sat Jul 29 22:25:45 2017	(r321706)
+++ head/sys/kern/kern_linker.c	Sat Jul 29 23:31:21 2017	(r321707)
@@ -1243,8 +1243,8 @@ kern_kldstat(struct thread *td, int fileid, struct kld
 
 	/* Version 1 fields: */
 	namelen = strlen(lf->filename) + 1;
-	if (namelen > MAXPATHLEN)
-		namelen = MAXPATHLEN;
+	if (namelen > sizeof(stat->name))
+		namelen = sizeof(stat->name);
 	bcopy(lf->filename, &stat->name[0], namelen);
 	stat->refs = lf->refs;
 	stat->id = lf->id;
@@ -1252,8 +1252,8 @@ kern_kldstat(struct thread *td, int fileid, struct kld
 	stat->size = lf->size;
 	/* Version 2 fields: */
 	namelen = strlen(lf->pathname) + 1;
-	if (namelen > MAXPATHLEN)
-		namelen = MAXPATHLEN;
+	if (namelen > sizeof(stat->pathname))
+		namelen = sizeof(stat->pathname);
 	bcopy(lf->pathname, &stat->pathname[0], namelen);
 	sx_xunlock(&kld_sx);
 



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