From owner-svn-src-all@freebsd.org Mon Sep 19 18:35:23 2016 Return-Path: Delivered-To: svn-src-all@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 BE8CBBE1698; Mon, 19 Sep 2016 18:35:23 +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 8EDB0EB7; Mon, 19 Sep 2016 18:35:23 +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 u8JIZMjN090286; Mon, 19 Sep 2016 18:35:22 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u8JIZMFB090285; Mon, 19 Sep 2016 18:35:22 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201609191835.u8JIZMFB090285@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:35:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r305990 - head/usr.bin/hexdump X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Sep 2016 18:35:23 -0000 Author: pfg Date: Mon Sep 19 18:35:22 2016 New Revision: 305990 URL: https://svnweb.freebsd.org/changeset/base/305990 Log: hexdump(1): Simplify by using asprintf(3) Instead of strlen() + calloc() + snprintf, just use asprintf(). No functional change. Obtained from: OpenBSD (CVS Rev. 1.22) Modified: head/usr.bin/hexdump/parse.c Modified: head/usr.bin/hexdump/parse.c ============================================================================== --- head/usr.bin/hexdump/parse.c Mon Sep 19 17:51:56 2016 (r305989) +++ head/usr.bin/hexdump/parse.c Mon Sep 19 18:35:22 2016 (r305990) @@ -208,7 +208,6 @@ rewrite(FS *fs) unsigned char *p1, *p2, *fmtp; char savech, cs[3]; int nconv, prec; - size_t len; prec = 0; @@ -389,10 +388,8 @@ isint2: switch(fu->bcnt) { */ savech = *p2; p1[0] = '\0'; - len = strlen(fmtp) + strlen(cs) + 1; - if ((pr->fmt = calloc(1, len)) == NULL) + if (asprintf(&pr->fmt, "%s%s", fmtp, cs) == -1) err(1, NULL); - snprintf(pr->fmt, len, "%s%s", fmtp, cs); *p2 = savech; pr->cchar = pr->fmt + (p1 - fmtp); fmtp = p2;