From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756141AbbFVHjG (ORCPT ); Mon, 22 Jun 2015 03:39:06 -0400 Received: from ni.piap.pl ([195.187.100.4]:36897 "EHLO ni.piap.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753591AbbFVHjD (ORCPT ); Mon, 22 Jun 2015 03:39:03 -0400 From: khalasa@piap.pl (Krzysztof =?utf-8?Q?Ha=C5=82asa?=) To: Joe Perches Cc: Frans Klaver , Andy Whitcroft , lkml Subject: Re: Coding style details (checkpatch) References: <1434725667.2689.121.camel@perches.com> <1434953551.9808.19.camel@perches.com> <1434955662.9808.26.camel@perches.com> Date: Mon, 22 Jun 2015 09:39:00 +0200 In-Reply-To: <1434955662.9808.26.camel@perches.com> (Joe Perches's message of "Sun, 21 Jun 2015 23:47:42 -0700") Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-KLMS-Rule-ID: 1 X-KLMS-Message-Action: clean X-KLMS-AntiSpam-Lua-Profiles: 79658 [Jun 22 2015] X-KLMS-AntiSpam-Version: 5.5.6 X-KLMS-AntiSpam-Envelope-From: khalasa@piap.pl X-KLMS-AntiSpam-Rate: 0 X-KLMS-AntiSpam-Status: not_detected X-KLMS-AntiSpam-Method: none X-KLMS-AntiSpam-Moebius-Timestamps: 3611792, 3611813, 3611558 X-KLMS-AntiSpam-Info: LuaCore: 230 2015-06-18_15-19-46 a57002d05d325a1ca642728c4b1d1e7603231830, Auth:dkim=none X-KLMS-AntiSpam-Interceptor-Info: scan successful X-KLMS-AntiPhishing: Clean, 2015/06/18 15:23:24 X-KLMS-AntiVirus: Kaspersky Security 8.0 for Linux Mail Server, version 8.0.1.721, bases: 2015/06/22 03:32:00 #8275466 X-KLMS-AntiVirus-Status: Clean, skipped Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Joe Perches writes: > #define VDREG8(a0) ((const u16[]){ \ > a0 + 0x000, a0 + 0x010, a0 +0x020, a0 + 0x030, \ > a0 + 0x100, a0 + 0x110, a0 +0x120, a0 + 0x130}) > > as "const u16[]" is a $Type but "const u16[]" is not. > > Still, as written, the code seems fragile as MACRO[index] > allows index to be any value, maybe larger than the array. Right. XXX[8] is meant as an additional mental check. Not very effective, though I think certain GCCs can issue a warning for obvious out-of-bounds accesses (probably with both [] and [8]). -- Krzysztof Halasa Industrial Research Institute for Automation and Measurements PIAP Al. Jerozolimskie 202, 02-486 Warsaw, Poland -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in Please read the FAQ at http://www.tux.org/lkml/