From owner-svn-src-all@freebsd.org Thu Mar 17 07:18:27 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 B4E61AD3264; Thu, 17 Mar 2016 07:18:27 +0000 (UTC) (envelope-from hps@selasky.org) Received: from mail.turbocat.net (heidi.turbocat.net [88.198.202.214]) (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 7EE641D6; Thu, 17 Mar 2016 07:18:26 +0000 (UTC) (envelope-from hps@selasky.org) Received: from laptop015.home.selasky.org (unknown [62.141.129.119]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.turbocat.net (Postfix) with ESMTPSA id 28C081FE024; Thu, 17 Mar 2016 08:18:25 +0100 (CET) Subject: Re: svn commit: r296933 - in head: share/man/man9 sys/sys To: Gleb Smirnoff References: <201603160837.u2G8bqgr087126@repo.freebsd.org> <20160316203241.GM1328@FreeBSD.org> Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org From: Hans Petter Selasky Message-ID: <56EA5AE8.4050700@selasky.org> Date: Thu, 17 Mar 2016 08:21:12 +0100 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 MIME-Version: 1.0 In-Reply-To: <20160316203241.GM1328@FreeBSD.org> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.21 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: Thu, 17 Mar 2016 07:18:27 -0000 On 03/16/16 21:32, Gleb Smirnoff wrote: > On Wed, Mar 16, 2016 at 08:37:52AM +0000, Hans Petter Selasky wrote: > H> Author: hselasky > H> Date: Wed Mar 16 08:37:52 2016 > H> New Revision: 296933 > H> URL: https://svnweb.freebsd.org/changeset/base/296933 > H> > H> Log: > H> Improve the implementation and documentation of the > H> SYSCTL_COUNTER_U64_ARRAY() macro. > H> > H> - Add proper asserts to the SYSCTL_COUNTER_U64_ARRAY() macro that checks > H> the size of the first element of the array. > H> - Add an example to the counter(9) manual page how to use the > H> SYSCTL_COUNTER_U64_ARRAY() macro. > H> - Add some missing symbolic links for counter(9) while at it. > > ... > > H> +.Sh EXAMPLES > H> +The following example creates a static counter array exported to > H> +userspace through a sysctl: > H> +.Bd -literal -offset indent > H> +#define MY_SIZE 8 > H> +static counter_u64_t array[MY_SIZE]; > H> +SYSCTL_COUNTER_U64_ARRAY(_debug, OID_AUTO, counter_array, CTLFLAG_RW, > H> + &array[0], MY_SIZE, "Test counter array"); > > I always wondered what is stylistically better: array or &array[0]? I > usually prefer the former. > A question: If you pass "array" why do you need a length argument in the SYSCTL macro. Can't you get the length of the array like sizeof(array)/sizeof((array)[0]) inside the macro? --HPS