From owner-svn-src-stable@freebsd.org Fri Nov 13 09:46:30 2015 Return-Path: Delivered-To: svn-src-stable@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 1570AA2D455; Fri, 13 Nov 2015 09:46:30 +0000 (UTC) (envelope-from mav@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 B7AE31D53; Fri, 13 Nov 2015 09:46:29 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id tAD9kS2e016828; Fri, 13 Nov 2015 09:46:28 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id tAD9kSR8016827; Fri, 13 Nov 2015 09:46:28 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201511130946.tAD9kSR8016827@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 13 Nov 2015 09:46:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r290762 - stable/10/cddl/contrib/opensolaris/lib/libzfs/common X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Nov 2015 09:46:30 -0000 Author: mav Date: Fri Nov 13 09:46:28 2015 New Revision: 290762 URL: https://svnweb.freebsd.org/changeset/base/290762 Log: MFC r289528: Reduce diff from upstream. Should be no functional change. Modified: stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c Directory Properties: stable/10/ (props changed) Modified: stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c ============================================================================== --- stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c Fri Nov 13 09:45:33 2015 (r290761) +++ stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c Fri Nov 13 09:46:28 2015 (r290762) @@ -3729,17 +3729,18 @@ zpool_history_unpack(char *buf, uint64_t int zpool_get_history(zpool_handle_t *zhp, nvlist_t **nvhisp) { - char *buf = NULL; - uint64_t bufsize = HIS_BUF_LEN_DEF; + char *buf; + uint64_t buflen = HIS_BUF_LEN_DEF; uint64_t off = 0; nvlist_t **records = NULL; uint_t numrecords = 0; int err, i; - if ((buf = malloc(bufsize)) == NULL) + buf = malloc(buflen); + if (buf == NULL) return (ENOMEM); do { - uint64_t bytes_read = bufsize; + uint64_t bytes_read = buflen; uint64_t leftover; if ((err = get_history(zhp, buf, &off, &bytes_read)) != 0) @@ -3753,18 +3754,16 @@ zpool_get_history(zpool_handle_t *zhp, n &leftover, &records, &numrecords)) != 0) break; off -= leftover; - - /* - * If the history block is too big, double the buffer - * size and try again. - */ if (leftover == bytes_read) { + /* + * no progress made, because buffer is not big enough + * to hold this record; resize and retry. + */ + buflen *= 2; free(buf); buf = NULL; - - bufsize <<= 1; - if ((bufsize >= HIS_BUF_LEN_MAX) || - ((buf = malloc(bufsize)) == NULL)) { + if ((buflen >= HIS_BUF_LEN_MAX) || + ((buf = malloc(buflen)) == NULL)) { err = ENOMEM; break; } @@ -3772,6 +3771,7 @@ zpool_get_history(zpool_handle_t *zhp, n /* CONSTCOND */ } while (1); + free(buf); if (!err) {