summaryrefslogtreecommitdiffstats
path: root/pw
diff options
context:
space:
mode:
authorBaptiste Daroussin <bapt@FreeBSD.org>2015-05-09 22:43:44 +0000
committerBaptiste Daroussin <bapt@FreeBSD.org>2015-05-09 22:43:44 +0000
commit12334184dee67245367ba6ff6b4914392538bc4d (patch)
tree68c8b7122e3d879fea5d28d6f95c706533150dbe /pw
parent2f3cb3756d908fc83cd3e754db1d6652a4cb0615 (diff)
downloadpw-darwin-12334184dee67245367ba6ff6b4914392538bc4d.tar.gz
pw-darwin-12334184dee67245367ba6ff6b4914392538bc4d.zip
Use snprintf(3) instead of sprintf(3)
Remove useless "else"
Diffstat (limited to 'pw')
-rw-r--r--pw/pw_user.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/pw/pw_user.c b/pw/pw_user.c
index bdb3cd6..d7aed71 100644
--- a/pw/pw_user.c
+++ b/pw/pw_user.c
@@ -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 *