From owner-svn-src-all@freebsd.org Thu Mar 17 20:06:16 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 5A057AD466E; Thu, 17 Mar 2016 20:06:16 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from cell.glebi.us (glebi.us [96.95.210.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "cell.glebi.us", Issuer "cell.glebi.us" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 285897DF; Thu, 17 Mar 2016 20:06:15 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from cell.glebi.us (localhost [127.0.0.1]) by cell.glebi.us (8.15.2/8.15.2) with ESMTPS id u2HK6FLh085857 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 17 Mar 2016 13:06:15 -0700 (PDT) (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by cell.glebi.us (8.15.2/8.15.2/Submit) id u2HK6Fw6085856; Thu, 17 Mar 2016 13:06:15 -0700 (PDT) (envelope-from glebius@FreeBSD.org) X-Authentication-Warning: cell.glebi.us: glebius set sender to glebius@FreeBSD.org using -f Date: Thu, 17 Mar 2016 13:06:15 -0700 From: Gleb Smirnoff To: Hans Petter Selasky Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r296933 - in head: share/man/man9 sys/sys Message-ID: <20160317200615.GX1328@FreeBSD.org> References: <201603160837.u2G8bqgr087126@repo.freebsd.org> <20160316203241.GM1328@FreeBSD.org> <56EA5AE8.4050700@selasky.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <56EA5AE8.4050700@selasky.org> User-Agent: Mutt/1.5.24 (2015-08-30) 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 20:06:16 -0000 On Thu, Mar 17, 2016 at 08:21:12AM +0100, Hans Petter Selasky wrote: H> On 03/16/16 21:32, Gleb Smirnoff wrote: H> > On Wed, Mar 16, 2016 at 08:37:52AM +0000, Hans Petter Selasky wrote: H> > H> Author: hselasky H> > H> Date: Wed Mar 16 08:37:52 2016 H> > H> New Revision: 296933 H> > H> URL: https://svnweb.freebsd.org/changeset/base/296933 H> > H> H> > H> Log: H> > H> Improve the implementation and documentation of the H> > H> SYSCTL_COUNTER_U64_ARRAY() macro. H> > H> H> > H> - Add proper asserts to the SYSCTL_COUNTER_U64_ARRAY() macro that checks H> > H> the size of the first element of the array. H> > H> - Add an example to the counter(9) manual page how to use the H> > H> SYSCTL_COUNTER_U64_ARRAY() macro. H> > H> - Add some missing symbolic links for counter(9) while at it. H> > H> > ... H> > H> > H> +.Sh EXAMPLES H> > H> +The following example creates a static counter array exported to H> > H> +userspace through a sysctl: H> > H> +.Bd -literal -offset indent H> > H> +#define MY_SIZE 8 H> > H> +static counter_u64_t array[MY_SIZE]; H> > H> +SYSCTL_COUNTER_U64_ARRAY(_debug, OID_AUTO, counter_array, CTLFLAG_RW, H> > H> + &array[0], MY_SIZE, "Test counter array"); H> > H> > I always wondered what is stylistically better: array or &array[0]? I H> > usually prefer the former. H> > H> H> A question: If you pass "array" why do you need a length argument in the H> SYSCTL macro. Can't you get the length of the array like H> sizeof(array)/sizeof((array)[0]) inside the macro? IMHO, that's a good idea for the static sysctl declaration. I can't imagine a good case when size in array declaration and in the SYSCTL declaration would differ. -- Totus tuus, Glebius.