svn commit: r282699 - head/usr.sbin/pw

Baptiste Daroussin bapt at FreeBSD.org
Sat May 9 22:43:45 UTC 2015


Author: bapt
Date: Sat May  9 22:43:44 2015
New Revision: 282699
URL: https://svnweb.freebsd.org/changeset/base/282699

Log:
  Use snprintf(3) instead of sprintf(3)
  Remove useless "else"

Modified:
  head/usr.sbin/pw/pw_user.c

Modified: head/usr.sbin/pw/pw_user.c
==============================================================================
--- head/usr.sbin/pw/pw_user.c	Sat May  9 22:08:30 2015	(r282698)
+++ head/usr.sbin/pw/pw_user.c	Sat May  9 22:43:44 2015	(r282699)
@@ -1018,17 +1018,16 @@ static char    *
 pw_homepolicy(struct userconf * cnf, struct cargs * args, char const * user)
 {
 	struct carg    *arg = getarg(args, 'd');
+	static char     home[128];
 
 	if (arg)
-		return arg->val;
-	else {
-		static char     home[128];
+		return (arg->val);
 
-		if (cnf->home == NULL || *cnf->home == '\0')
-			errx(EX_CONFIG, "no base home directory set");
-		sprintf(home, "%s/%s", cnf->home, user);
-		return home;
-	}
+	if (cnf->home == NULL || *cnf->home == '\0')
+		errx(EX_CONFIG, "no base home directory set");
+	snprintf(home, sizeof(home), "%s/%s", cnf->home, user);
+
+	return (home);
 }
 
 static char    *


More information about the svn-src-all mailing list