aboutsummaryrefslogtreecommitdiff
path: root/sbin/mount
diff options
context:
space:
mode:
authorPedro F. Giffuni <pfg@FreeBSD.org>2016-09-19 18:42:58 +0000
committerPedro F. Giffuni <pfg@FreeBSD.org>2016-09-19 18:42:58 +0000
commit8967299b33c1fae4a3ab14396db323bb7b7fcc50 (patch)
tree343b120fb68630e06a145f3d6dba9ca79d7e272e /sbin/mount
parent07fa0846caac7196e070c3f438b19ec90f31083c (diff)
downloadsrc-8967299b33c1fae4a3ab14396db323bb7b7fcc50.tar.gz
src-8967299b33c1fae4a3ab14396db323bb7b7fcc50.zip
mount(1): Simplify by using asprintf(3)
Instead of strlen() + malloc() + snprintf, just use asprintf(). No functional change. Obtained from: OpenBSD (CVS Rev. 1.67)
Notes
Notes: svn path=/head/; revision=305993
Diffstat (limited to 'sbin/mount')
-rw-r--r--sbin/mount/mount.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/sbin/mount/mount.c b/sbin/mount/mount.c
index debe3547a8ff..b33d9a3f71ef 100644
--- a/sbin/mount/mount.c
+++ b/sbin/mount/mount.c
@@ -705,17 +705,14 @@ getmntpt(const char *name)
char *
catopt(char *s0, const char *s1)
{
- size_t i;
char *cp;
if (s1 == NULL || *s1 == '\0')
return (s0);
if (s0 && *s0) {
- i = strlen(s0) + strlen(s1) + 1 + 1;
- if ((cp = malloc(i)) == NULL)
- errx(1, "malloc failed");
- (void)snprintf(cp, i, "%s,%s", s0, s1);
+ if (asprintf(&cp, "%s,%s", s0, s1) == -1)
+ errx(1, "asprintf failed");
} else
cp = strdup(s1);