From owner-svn-src-head@freebsd.org Mon Sep 19 18:42:59 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 615BFBE1B0C; Mon, 19 Sep 2016 18:42:59 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 31E8618C4; Mon, 19 Sep 2016 18:42:59 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u8JIgwLQ094039; Mon, 19 Sep 2016 18:42:58 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u8JIgwEf094038; Mon, 19 Sep 2016 18:42:58 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201609191842.u8JIgwEf094038@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Mon, 19 Sep 2016 18:42:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r305993 - head/sbin/mount X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Sep 2016 18:42:59 -0000 Author: pfg Date: Mon Sep 19 18:42:58 2016 New Revision: 305993 URL: https://svnweb.freebsd.org/changeset/base/305993 Log: 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) Modified: head/sbin/mount/mount.c Modified: head/sbin/mount/mount.c ============================================================================== --- head/sbin/mount/mount.c Mon Sep 19 18:40:54 2016 (r305992) +++ head/sbin/mount/mount.c Mon Sep 19 18:42:58 2016 (r305993) @@ -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);