Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp5676703ybe; Tue, 10 Sep 2019 07:17:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqwgeHiaIWJssQthTBCHFl1331KlqHSswdfugv9dvzgXhWthY4Fp1rUmsJaDqoNBrFtkmQ/H X-Received: by 2002:a17:906:1385:: with SMTP id f5mr25471165ejc.145.1568125076561; Tue, 10 Sep 2019 07:17:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568125076; cv=none; d=google.com; s=arc-20160816; b=UWlCD40Wfb/mbb5uwwAOpYEbKSNZz0QORR9cMhXAv0PMMVQ9/teJvAONUAwe5vgR7Y /dMs0midiWeiV4snEtaZhy58HzrPjs6B2st4EetpLN66IhGX/KY3VObojBLnTs9yCFFT xUdwo+YBSruv/TLAGQqd/GH7qeLthvcYPmyf+mpipG2OixzlIyVqL/h6r0xd13bvVfY6 9T1bNhjoqgv9FwfUZayfYp8b3jq3RLw5nj0FSwz9oJH5HdecKoTTJijpqVeyZ7wovu5t GRoqOMa+p1qBOfOhKrUwfraHI66+HlUz1axvYTZ9PqoAFDyQD3Y9xXhgcNbF3CN+629x nT0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=G7hoXMY82GaAtkIfBClh+DQeKOTBWT7BqkL++A5yUgg=; b=cm5MAKPUnVdzdVIunbtDXAfAFQLLFdeZGVAzW3CebEP7RP5cKlsYZOtcSFIOvPaQQn wjYCS0gnBESFXvxr7zZz5vZkJz44+lPzuGp+1ejLZ9aWpJIOHmIjWMf7rz7+JFKxJ/IU vpTeE7bFdE1O9JJvV9AHkbKOM+MSQvL4ds6bMQDmIHMR+1ixpBASC0dWkGx/NAtsXKyp akUJk6y4FxZxp7BqOklivw/shF48MaCiy9YP5JvYaqTdHu1UhN5/0Ck8xpd1TUgMp9DZ CNrDNlkmE39OdlMNPf1hPKlkiAk71Zo4wJjBi6/GKsElcmN09ERGqewiFcwArpoqnMNi sI0A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f43si12084730edf.422.2019.09.10.07.17.32; Tue, 10 Sep 2019 07:17:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732666AbfIJNgL convert rfc822-to-8bit (ORCPT + 99 others); Tue, 10 Sep 2019 09:36:11 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:54870 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732546AbfIJNgK (ORCPT ); Tue, 10 Sep 2019 09:36:10 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 31875E1C68541BC25C73; Tue, 10 Sep 2019 21:36:05 +0800 (CST) Received: from localhost (10.202.226.61) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.439.0; Tue, 10 Sep 2019 21:36:02 +0800 Date: Tue, 10 Sep 2019 14:35:50 +0100 From: Jonathan Cameron To: Krzysztof Wilczynski CC: Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , , Subject: Re: [PATCH] iio: light: bh1750: Move static keyword to the front of declaration Message-ID: <20190910143550.00000e64@huawei.com> In-Reply-To: <20190908135208.GA29162@rocinante> References: <20190902113132.26658-1-kw@linux.com> <20190908114944.18bb78e3@archlinux> <20190908135208.GA29162@rocinante> Organization: Huawei X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; i686-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8BIT X-Originating-IP: [10.202.226.61] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 8 Sep 2019 15:52:09 +0200 Krzysztof Wilczynski wrote: > Hello Jonathan, > > Thank you for feedback. > > [...] > > > drivers/iio/light/bh1750.c:64:1: warning: > > > ‘static’ is not at beginning of declaration [-Wold-style-declaration] > [...] > > This one has me confused. The warning seems to be false as static > > is at the beginning of the declaration.... > > > > Sure we "could" combine the declaration with the definition as you have > > done here, but that has nothing much to do with the warning. > [...] > > I only moved the "static const" at the front, I haven't changed the > code as it's already has been a declaration and definition. There is > no semicolon there and the original author put a newline to separate > things which makes it look as if these were separate. > > Simple example based on the existing code: > > https://godbolt.org/z/hV4HP7 > > I hope this helps to illustrate the change in the patch. I apologise > if my approach was incorrect. > > As part of the patch I removed the newline in an aim to make it less > confusing to anyone who will read the code in the future. Especially, > since it makes it a bit awkward to read and when using things like > grep. > > Krzysztof I get what you are trying to do, the issue is the code is currently: struct bh1750_chip_info { u16 mtreg_min; u16 mtreg_max; u16 mtreg_default; int mtreg_to_usec; int mtreg_to_scale; /* * For BH1710/BH1721 all possible integration time values won't fit * into one page so displaying is limited to every second one. * Note, that user can still write proper values which were not * listed. */ int inc; u16 int_time_low_mask; u16 int_time_high_mask; } static const bh1750_chip_info_tbl[] = { [BH1710] = { 140, 1022, 300, 400, 250000000, 2, 0x001F, 0x03E0 }, [BH1721] = { 140, 1020, 300, 400, 250000000, 2, 0x0010, 0x03E0 }, [BH1750] = { 31, 254, 69, 1740, 57500000, 1, 0x001F, 0x00E0 }, }; That test is supposed to catch the second block being const static bh1750_chip_info_tbl[] = { ... Which it isn't. So the issue here was never that the static keyword wasn't at the front of the declaration but that we could save a tiny bit code by using the pattern static const struct bh1750_chip_info { ... } bh1750_chip_info_tbl[] { [...] = ... }; We can do that of course, but that's nothing to do with moving the static keyword to the front of the declaration which is what the patch claims to be doing. Jonathan