Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 9 May 2015 22:43:45 +0000 (UTC)
From:      Baptiste Daroussin <bapt@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r282699 - head/usr.sbin/pw
Message-ID:  <201505092243.t49MhjwS076201@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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    *



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