From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753895AbbGAM05 (ORCPT ); Wed, 1 Jul 2015 08:26:57 -0400 Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]:36137 "EHLO mail2-relais-roc.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750935AbbGAM0v (ORCPT ); Wed, 1 Jul 2015 08:26:51 -0400 X-IronPort-AV: E=Sophos;i="5.15,385,1432591200"; d="scan'208";a="168326221" Date: Wed, 1 Jul 2015 14:26:44 +0200 (CEST) From: Julia Lawall X-X-Sender: jll@hadrien To: Dan Carpenter cc: Clemens Ladisch , Joe Perches , LKML , Andrew Morton Subject: Re: RFC: kernel coding style: prefer array to &array[0] ? In-Reply-To: <20150701121524.GA30834@mwanda> Message-ID: References: <1435685746.12101.18.camel@perches.com> <5593D4F5.1090106@ladisch.de> <20150701121524.GA30834@mwanda> User-Agent: Alpine 2.10 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 1 Jul 2015, Dan Carpenter wrote: > On Wed, Jul 01, 2015 at 01:54:29PM +0200, Clemens Ladisch wrote: > > Joe Perches wrote: > > > It seems most in-kernel uses are 'array' rather than '&array[0]' > > > > > > Most of the time, using array is simpler to read than &array[0]. > > > > > > Exceptions exists when addresses for consecutive members are > > > used like func(&array[0], &array[1]); > > > > I use '&array[0]' when I want to get a pointer to a single object that > > happens to be the first one in an array. > > Yeah. Of course, you're right. Otherwise it ends up confusing static > checkers if you want the first element or the whole array. > > > > > > Should this preference be put into checkpatch and/or CodingStyle? > > > > How about the following low-hanging fruit? > > > > foo(..., &array[0], ARRAY_SIZE(array), ...) > > Yes, to this also. I doubt checkpatch.pl will find a meaningful number > of these but doing that is annoying thing. Atcually, I find 236 of them, in 48 files. julia