From owner-svn-src-head@freebsd.org Tue Mar 15 00:16:43 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 7E99CAD13C9; Tue, 15 Mar 2016 00:16:43 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-wm0-x22e.google.com (mail-wm0-x22e.google.com [IPv6:2a00:1450:400c:c09::22e]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 15898158D; Tue, 15 Mar 2016 00:16:43 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: by mail-wm0-x22e.google.com with SMTP id l68so130452274wml.0; Mon, 14 Mar 2016 17:16:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=3t8RqYgTUn0P3+QQstPBhCy7SNcLdbYB+dYHG1fS+44=; b=p6jNti/IXq5LelpoitY+gjZa4OvtkdmOTCUhyoL+5apFHiE9l53NqaCrZoVdoLLcpr I/l2kHhlrpe2FL9ojqGfTnWwd/xzEWUjjumSPH2J0x7i4khMytR2fpqaJmspSoZIaRZw EHx1o7AVAiDTg9F/Rxp1Lt/mhW0QhkYOtfgqMSsamPVsYxT4HxPVYWcsKoxdyOE9oIuV S4EEzS4vdVCLxhTV4NSDsk3fdbPfnTyNENCgH0WqbgcnpetEJkph/XBgVbUEVIk0pgsM Wd6DRIqlcpSG/6IscT4j5lkh8e8XrHKycX2KhbMR2yPMTScPz43iMc5khL9rYdrkX/v1 V0RA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=3t8RqYgTUn0P3+QQstPBhCy7SNcLdbYB+dYHG1fS+44=; b=QpnO8WkTpRmrBzFqkb5yk9Z8h31mcSt7ZXKZ1e6z5ajDu45Ph8SypJwnAAvgLXkOgF +rCT3naI8yowbb1TiYOOLA4WbKcmzO0mDd8Qiet613ifdjs7SGjylsI9Yj064qv3k5Ph uB5zQrvIsorFLtJ08QDd0cblAVxO3nUiwXwvFl3eJK6nmZ6OSpJPja/Di//gj4bN5mkf BNNWGr5GycwZ5fCGvuGpmvj3+KPFGfkObVRP9HsbfBsweMQgj1LCnh+tCR+JU9q1UbaR LXXjXLVoAKN0hjqbd4jE4xJaJ4/MsT7C+LmZyD5lcyEQpS/veGSR8+TvLHNzHOFLBA2r yG8g== X-Gm-Message-State: AD7BkJLymdFAWr0c7Vyn1dtP4bpc/1TmBosGHV0GkF9ewuYnsthFpxEwp2kap8Ak5Tfj5w== X-Received: by 10.28.141.10 with SMTP id p10mr19943383wmd.83.1458001001637; Mon, 14 Mar 2016 17:16:41 -0700 (PDT) Received: from dft-labs.eu (n1x0n-1-pt.tunnel.tserv5.lon1.ipv6.he.net. [2001:470:1f08:1f7::2]) by smtp.gmail.com with ESMTPSA id cb2sm24545815wjc.16.2016.03.14.17.16.40 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Mon, 14 Mar 2016 17:16:40 -0700 (PDT) Date: Tue, 15 Mar 2016 01:16:38 +0100 From: Mateusz Guzik To: Gleb Smirnoff Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r296880 - in head: share/man/man9 sys/kern sys/sys Message-ID: <20160315001638.GA29505@dft-labs.eu> References: <201603150005.u2F050ps086390@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <201603150005.u2F050ps086390@repo.freebsd.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.21 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: Tue, 15 Mar 2016 00:16:43 -0000 On Tue, Mar 15, 2016 at 12:05:00AM +0000, Gleb Smirnoff wrote: > +int > +sysctl_handle_counter_u64_array(SYSCTL_HANDLER_ARGS) > +{ > + uint64_t *out; > + int error; > + > + out = malloc(arg2 * sizeof(uint64_t), M_TEMP, M_WAITOK); > + for (int i = 0; i < arg2; i++) > + out[i] = counter_u64_fetch(((counter_u64_t *)arg1)[i]); > + > + error = SYSCTL_OUT(req, out, arg2 * sizeof(uint64_t)); > + > + if (error || !req->newptr) > + return (error); > + > + /* > + * Any write attempt to a counter zeroes it. > + */ > + for (int i = 0; i < arg2; i++) > + counter_u64_zero(((counter_u64_t *)arg1)[i]); > + > + return (0); > +} > This never frees tha allocated buffer. It would be better to just put stuff to userspace in a loop and avoid allocations entirely. but does not look like there are no friendly macros for that. -- Mateusz Guzik