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)
This commit is contained in:
Pedro F. Giffuni 2016-09-19 18:42:58 +00:00
parent 07fa0846ca
commit 8967299b33
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=305993

View File

@ -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);