summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authoreadler <eadler@FreeBSD.org>2012-12-05 13:56:56 +0000
committereadler <eadler@FreeBSD.org>2012-12-05 13:56:56 +0000
commit3b3a43cfae6d7fe5f9b4c46a6dc2e8e7e92008a6 (patch)
tree0adcc9fa26442f9ebbc27e53c7b4d8c426322695 /usr.sbin
parentdff4ef46f61862176e03fb0fd103ce56079ed597 (diff)
downloadFreeBSD-src-3b3a43cfae6d7fe5f9b4c46a6dc2e8e7e92008a6.zip
FreeBSD-src-3b3a43cfae6d7fe5f9b4c46a6dc2e8e7e92008a6.tar.gz
Simplify string duplication: use strdup instead of malloc + strcpy
Submitted by: db Approved by: cperciva MFC after: 2 weeks
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/pw/grupd.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/usr.sbin/pw/grupd.c b/usr.sbin/pw/grupd.c
index e9f6b5e..3f78e95 100644
--- a/usr.sbin/pw/grupd.c
+++ b/usr.sbin/pw/grupd.c
@@ -50,12 +50,11 @@ setgrdir(const char * dir)
{
if (dir == NULL)
return -1;
- else {
- char * d = malloc(strlen(dir)+1);
- if (d == NULL)
- return -1;
- grpath = strcpy(d, dir);
- }
+ else
+ grpath = strdup(dir);
+ if (grpath == NULL)
+ return -1;
+
return 0;
}
OpenPOWER on IntegriCloud