Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp2297648ybz; Thu, 30 Apr 2020 14:37:00 -0700 (PDT) X-Google-Smtp-Source: APiQypITw0IaUPTIhf/aWEmCiKk+6xNIfWWISmuiEQZTrEtntuWbE/utpjzbjjSxMc7AE96T1HRS X-Received: by 2002:a50:f61c:: with SMTP id c28mr905542edn.365.1588282620771; Thu, 30 Apr 2020 14:37:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588282620; cv=none; d=google.com; s=arc-20160816; b=bYfx2xzJwlDx3FLMdX95obKnQi03HrJVOH72QQvwUeNe/8mbyXF/zr57Pxg72fNM9I W2G2ip8/BunYO0DQCJbBuRHWMVR608+/lrFJxalG6KnkTrwqeX/il9osWiCENQKc6C9C x3A4W9pcHJMpfDx1PZbF6h5tgFr+SNM28088qdXzb5aEdoqbYcq3bWRMaVNofUYjY87p F4R4BaZsc/EXXdRYRU+4DD5dVwRdaw5fonmy+YUdSUPc1tHxGYSSxEdjJ2K4lRjeyZar aOuwFqVT0GgByNmyxV2SVJzu9R9ijc34Yqm7mg7Ms81C15wBVwQORqVh2bAv2oDbirTB JpMg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=7o5+I914Ig95Eq3t48YH71Suc6MyEFkiQOOC0KgrVnU=; b=j18WmnqDcG7InMzKZ3bb3483GUUa0g36O2AULAmQ/J3IugiA1KGdd1k528z/pcqKNM 49wD1mmwg7s3Cn9o8gApuysADsYnrqO8oSlS4/Ml2rbp7Aeg4osUz/+0UE17+wSSXRTt FrjPhP91ggZ9qBDalb7ZAYJ0kl+2ScVv4TB9BmFjOSbpmh24Bl7bNWwIabXez0F5ScoB KSP5zg4x45WV1l5yYAdXj4Gy9K4jrHop1RGLhVanLFvyaJwQ9o3vbIE+pvvWGHXEEe4v p89OLmc2H2w/1i0F7f7IFRmPsE2IC9tC7Stm/dbMfNUuCdVcIQ5QgLVVUF/M4ixJhms4 B4GA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dk9si493832edb.403.2020.04.30.14.36.36; Thu, 30 Apr 2020 14:37:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727850AbgD3Vcm (ORCPT + 99 others); Thu, 30 Apr 2020 17:32:42 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:51025 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726336AbgD3Vcl (ORCPT ); Thu, 30 Apr 2020 17:32:41 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.129]) with ESMTPA (Nemesis) id 1MRmwM-1jaI7F1geQ-00T9PZ; Thu, 30 Apr 2020 23:32:35 +0200 From: Arnd Bergmann To: linux-kernel@vger.kernel.org, Greg Kroah-Hartman Cc: Arnd Bergmann , Alan Stern , Yoshihiro Shimoda , linux-usb@vger.kernel.org Subject: [PATCH 08/15] usb: ehci: avoid gcc-10 zero-length-bounds warning Date: Thu, 30 Apr 2020 23:30:50 +0200 Message-Id: <20200430213101.135134-9-arnd@arndb.de> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200430213101.135134-1-arnd@arndb.de> References: <20200430213101.135134-1-arnd@arndb.de> MIME-Version: 1.0 Content-Transfer-Encoding: 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Wg33jP19lMpou6wQm5Eg5T/yjaziSMHK/nPASt z60ev2uT6xJm/Vhvywu0OrPttAQ8naeLtNyPkstQNrkLFzSFq8= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Building ehci drivers with gcc-10 results in a number of warnings like when an zero-length array is accessed: drivers/usb/host/ehci-hub.c: In function 'ehci_bus_suspend': drivers/usb/host/ehci-hub.c:320:30: error: array subscript 14 is outside the bounds of an interior zero-length array 'u32[0]' {aka 'unsigned int[0]'} [-Werror=zero-length-bounds] 320 | u32 __iomem *hostpc_reg = &ehci->regs->hostpc[port]; | ^~~~~~~~~~~~~~~~~~~~~~~~~ In file included from drivers/usb/host/ehci.h:273, from drivers/usb/host/ehci-hcd.c:96: include/linux/usb/ehci_def.h:186:7: note: while referencing 'hostpc' 186 | u32 hostpc[0]; /* HOSTPC extension */ | ^~~~~~ In file included from drivers/usb/host/ehci-hcd.c:305: drivers/usb/host/ehci-hub.c: In function 'ehci_hub_control': drivers/usb/host/ehci-hub.c:892:15: error: array subscript 256 is outside the bounds of an interior zero-length array 'u32[0]' {aka 'unsigned int[0]'} [-Werror=zero-length-bounds] 892 | hostpc_reg = &ehci->regs->hostpc[temp]; | ^~~~~~~~~~~~~~~~~~~~~~~~~ In file included from drivers/usb/host/ehci.h:273, from drivers/usb/host/ehci-hcd.c:96: include/linux/usb/ehci_def.h:186:7: note: while referencing 'hostpc' 186 | u32 hostpc[0]; /* HOSTPC extension */ | ^~~~~~ All these fields are colocated with reserved fields that I guess refer to the correct field length. Change the two struct definition to use an unnamed union to define both of these fields at the same location as the corresponding reserved fields. Signed-off-by: Arnd Bergmann --- include/linux/usb/ehci_def.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/include/linux/usb/ehci_def.h b/include/linux/usb/ehci_def.h index 78e006355557..8777d8e56ef2 100644 --- a/include/linux/usb/ehci_def.h +++ b/include/linux/usb/ehci_def.h @@ -127,7 +127,8 @@ struct ehci_regs { #define FLAG_CF (1<<0) /* true: we'll support "high speed" */ /* PORTSC: offset 0x44 */ - u32 port_status[0]; /* up to N_PORTS */ + union { + u32 port_status[9]; /* up to N_PORTS */ /* EHCI 1.1 addendum */ #define PORTSC_SUSPEND_STS_ACK 0 #define PORTSC_SUSPEND_STS_NYET 1 @@ -165,7 +166,8 @@ struct ehci_regs { #define PORT_CONNECT (1<<0) /* device connected */ #define PORT_RWC_BITS (PORT_CSC | PORT_PEC | PORT_OCC) - u32 reserved3[9]; + u32 reserved3[9]; + }; /* USBMODE: offset 0x68 */ u32 usbmode; /* USB Device mode */ @@ -181,11 +183,13 @@ struct ehci_regs { * PORTSCx */ /* HOSTPC: offset 0x84 */ - u32 hostpc[0]; /* HOSTPC extension */ + union { + u32 hostpc[17]; /* HOSTPC extension */ #define HOSTPC_PHCD (1<<22) /* Phy clock disable */ #define HOSTPC_PSPD (3<<25) /* Port speed detection */ - u32 reserved5[17]; + u32 reserved5[17]; + }; /* USBMODE_EX: offset 0xc8 */ u32 usbmode_ex; /* USB Device mode extension */ -- 2.26.0