From patchwork Thu Apr 30 21:30:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 11521679 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6BD0E913 for ; Thu, 30 Apr 2020 21:34:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5C92C20873 for ; Thu, 30 Apr 2020 21:34:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728095AbgD3VeI (ORCPT ); Thu, 30 Apr 2020 17:34:08 -0400 Received: from mout.kundenserver.de ([212.227.126.134]:54945 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726881AbgD3VeI (ORCPT ); Thu, 30 Apr 2020 17:34:08 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.129]) with ESMTPA (Nemesis) id 1MBlgy-1jKPRO2P7c-00CAl1; Thu, 30 Apr 2020 23:33:46 +0200 From: Arnd Bergmann To: linux-kernel@vger.kernel.org, "James E.J. Bottomley" , "Martin K. Petersen" , James Bottomley Cc: Arnd Bergmann , James Bottomley , John Garry , Hannes Reinecke , linux-scsi@vger.kernel.org Subject: [PATCH 13/15] scsi: sas: avoid gcc-10 zero-length-bounds warning Date: Thu, 30 Apr 2020 23:30:55 +0200 Message-Id: <20200430213101.135134-14-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 X-Provags-ID: V03:K1:Tij/Kp5SwKUhjG30C/bCLnQ40qQlaQDnfS4eB2TiFRLUOoReIgO Uve4poc8gqTByejdFMSMTbXXN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LsZjSTHg= Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Two files access the zero-length resp_data[] array, which now causes a compiler warning: drivers/scsi/aic94xx/aic94xx_tmf.c: In function 'asd_get_tmf_resp_tasklet': drivers/scsi/aic94xx/aic94xx_tmf.c:291:22: warning: array subscript 3 is outside the bounds of an interior zero-length array 'u8[0]' {aka 'unsigned char[0]'} [-Wzero-length-bounds] 291 | res = ru->resp_data[3]; | ~~~~~~~~~~~~~^~~ In file included from include/scsi/libsas.h:15, from drivers/scsi/aic94xx/aic94xx.h:16, from drivers/scsi/aic94xx/aic94xx_tmf.c:11: include/scsi/sas.h:557:9: note: while referencing 'resp_data' 557 | u8 resp_data[0]; | ^~~~~~~~~ drivers/scsi/libsas/sas_task.c: In function 'sas_ssp_task_response': drivers/scsi/libsas/sas_task.c:21:30: warning: array subscript 3 is outside the bounds of an interior zero-length array 'u8[0]' {aka 'unsigned char[0]'} [-Wzero-length-bounds] 21 | tstat->stat = iu->resp_data[3]; | ~~~~~~~~~~~~~^~~ In file included from include/scsi/scsi_transport_sas.h:8, from drivers/scsi/libsas/sas_internal.h:14, from drivers/scsi/libsas/sas_task.c:3: include/scsi/sas.h:557:9: note: while referencing 'resp_data' 557 | u8 resp_data[0]; | ^~~~~~~~~ This should really be a flexible-array member, but the structure already has such a member, swapping it out with sense_data[] would cause many more warnings elsewhere. As a workaround, add a temporary pointer that can be accessed without a warning. Fixes: 2908d778ab3e ("[SCSI] aic94xx: new driver") Fixes: 366ca51f30de ("[SCSI] libsas: abstract STP task status into a function") Signed-off-by: Arnd Bergmann Reviewed-by: John Garry --- drivers/scsi/aic94xx/aic94xx_tmf.c | 4 +++- drivers/scsi/libsas/sas_task.c | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/aic94xx/aic94xx_tmf.c b/drivers/scsi/aic94xx/aic94xx_tmf.c index f814026f26fa..a3139f9766c8 100644 --- a/drivers/scsi/aic94xx/aic94xx_tmf.c +++ b/drivers/scsi/aic94xx/aic94xx_tmf.c @@ -269,6 +269,7 @@ static int asd_get_tmf_resp_tasklet(struct asd_ascb *ascb, struct ssp_frame_hdr *fh; struct ssp_response_iu *ru; int res = TMF_RESP_FUNC_FAILED; + u8 *resp; ASD_DPRINTK("tmf resp tasklet\n"); @@ -287,8 +288,9 @@ static int asd_get_tmf_resp_tasklet(struct asd_ascb *ascb, fh = edb->vaddr + 16; ru = edb->vaddr + 16 + sizeof(*fh); res = ru->status; + resp = ru->resp_data; if (ru->datapres == 1) /* Response data present */ - res = ru->resp_data[3]; + res = resp[3]; #if 0 ascb->tag = fh->tag; #endif diff --git a/drivers/scsi/libsas/sas_task.c b/drivers/scsi/libsas/sas_task.c index e2d42593ce52..4cd2f9611c4a 100644 --- a/drivers/scsi/libsas/sas_task.c +++ b/drivers/scsi/libsas/sas_task.c @@ -12,13 +12,14 @@ void sas_ssp_task_response(struct device *dev, struct sas_task *task, struct ssp_response_iu *iu) { struct task_status_struct *tstat = &task->task_status; + u8 *resp = iu->resp_data; tstat->resp = SAS_TASK_COMPLETE; if (iu->datapres == 0) tstat->stat = iu->status; else if (iu->datapres == 1) - tstat->stat = iu->resp_data[3]; + tstat->stat = resp[3]; else if (iu->datapres == 2) { tstat->stat = SAM_STAT_CHECK_CONDITION; tstat->buf_valid_size = From patchwork Thu Apr 30 21:30:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 11521677 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 78B5D913 for ; Thu, 30 Apr 2020 21:34:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6A712208C3 for ; Thu, 30 Apr 2020 21:34:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728107AbgD3VeK (ORCPT ); Thu, 30 Apr 2020 17:34:10 -0400 Received: from mout.kundenserver.de ([212.227.126.134]:58935 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727124AbgD3VeI (ORCPT ); Thu, 30 Apr 2020 17:34:08 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.129]) with ESMTPA (Nemesis) id 1MekrN-1iw23r0YOj-00apFq; Thu, 30 Apr 2020 23:33:54 +0200 From: Arnd Bergmann To: linux-kernel@vger.kernel.org, Intel SCU Linux support , Artur Paszkiewicz , "James E.J. Bottomley" , "Martin K. Petersen" Cc: Arnd Bergmann , linux-scsi@vger.kernel.org Subject: [PATCH 14/15] isci: avoid gcc-10 zero-length-bounds warning Date: Thu, 30 Apr 2020 23:30:56 +0200 Message-Id: <20200430213101.135134-15-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 X-Provags-ID: V03:K1:7STMyUCnzNFORsOTFhBk+QO1wMd0aCQREYl9i/6g5djgitDUpZ6 d1Cx+C01pHvqZt+aQoS8ab5L853K/yBtfnhyeugGSlvh7HKQ0PL0VPWymc4AUUryftBYEso OUGbikus/NGt12kseU7xwabsGAmxqrTKLyaGQy3cjPJ43HXWsVNNnuwv8J52mfRiGUTqkiy p2VouWvfbNWfatj6Qx9KA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:bSMgVGjYJbk=:e3OoHoNyVrETSsb4hMOhs/ AS0ivt9Xcb53jajnQRqZgv28gM4KSUsPE4/o60hKXktudnmPzwv7RW8Kj4AuCquc4xriwDklb xKB4Dxt0vhsg9WTFIyTiatKW/x6/E+2Nk8pLmNKGMItbeiWHT43Hwq6qvUgQzpoxRSAtI8K+c AbFuuj3Oam60e+HhGtj5h/CXSHXFlomhGukqvM1te61faABhg4P98Ria19e5qoPauXLU31Ir7 uyL1FS3S/Pki/1dKyCc7sM6Ze1PWMD8JL99fDJsTBP/GpBfhDzFTAdNrCaOkVW4p63C2XUS1b csL4aTU4V1v07Popcn2+JRSVN/QvEmL1z9z+73jfAP3H4oshS/HrD1Ttx26cgkbqiV823bAPX ZhkZbjdTbcPzcEB/fsZEHN5B27L5aSM9MkkOVUbub1Ihc+pylki8sChmoY4/67R7FSVVwByPd J8Nz/BCBgevzfXFncJ4UPzc9CbgwT3Cbu8rokQWb9XVFywpOkgnas+iJg2fL949baMrHLRuV8 xV3WIiGzMWBZQFDW8Ac3Ix3EbrfgS1K01zPWZNZFeF+3kf+l8QQ9HsgqFXQbOQ6mx+3uwTYYx /ol12IcZtrb7B6wpmHD1NPPwpwrDydQTJ8Dn+CHU4DYt3/OjzXb/4/KvoKwHe3/tLjE7iM6pt hrd1WgsjuRO9ZM5+aPlpnjsWOH/mx90oUd8XFgynTRngF97dbGjgqqiobJW+pvbZIV5+ZTjc4 PM8Qk89cI6yabSO1NdqEAs9oCr5xwcoXbbP27xCCOsgQ1TG8rKyt8vvnm4wbtXZwD607vZvx2 zUHvdw7DVW21QES1ntvMt/CqXvDLFzW6Q3TYBwZKF6Xm0K41d4= Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org gcc-10 warns about accesses to zero-length arrays: drivers/scsi/isci/task.h:125:31: error: array subscript 0 is outside the bounds of an interior zero-length array 'u8[0]' {aka 'unsigned char[0]'} [-Werror=zero-length-bounds] 125 | tmf->resp.resp_iu.resp_data[0], | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ include/linux/dynamic_debug.h:143:2: note: in expansion of macro '__dynamic_func_call' 143 | __dynamic_func_call(__UNIQUE_ID(ddebug), fmt, func, ##__VA_ARGS__) | ^~~~~~~~~~~~~~~~~~~ include/linux/dynamic_debug.h:157:2: note: in expansion of macro '_dynamic_func_call' 157 | _dynamic_func_call(fmt,__dynamic_dev_dbg, \ | ^~~~~~~~~~~~~~~~~~ include/linux/dev_printk.h:115:2: note: in expansion of macro 'dynamic_dev_dbg' 115 | dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__) | ^~~~~~~~~~~~~~~ drivers/scsi/isci/task.h:111:3: note: in expansion of macro 'dev_dbg' 111 | dev_dbg(&ihost->pdev->dev, | ^~~~~~~ In file included from include/scsi/libsas.h:15, from drivers/scsi/isci/task.c:59: include/scsi/sas.h:326:9: note: while referencing 'resp_data' 326 | u8 resp_data[0]; | ^~~~~~~~~ This instance is not a bug, so just work around the warning by adding a temporary pointer. Signed-off-by: Arnd Bergmann --- drivers/scsi/isci/task.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/isci/task.h b/drivers/scsi/isci/task.h index 8f4531f22ac2..2d556d7b5292 100644 --- a/drivers/scsi/isci/task.h +++ b/drivers/scsi/isci/task.h @@ -98,6 +98,8 @@ struct isci_tmf { static inline void isci_print_tmf(struct isci_host *ihost, struct isci_tmf *tmf) { + u8 *resp = tmf->resp.resp_iu.resp_data; + if (SAS_PROTOCOL_SATA == tmf->proto) dev_dbg(&ihost->pdev->dev, "%s: status = %x\n" @@ -122,10 +124,7 @@ static inline void isci_print_tmf(struct isci_host *ihost, struct isci_tmf *tmf) tmf->resp.resp_iu.datapres, tmf->resp.resp_iu.status, be32_to_cpu(tmf->resp.resp_iu.response_data_len), - tmf->resp.resp_iu.resp_data[0], - tmf->resp.resp_iu.resp_data[1], - tmf->resp.resp_iu.resp_data[2], - tmf->resp.resp_iu.resp_data[3]); + resp[0], resp[1], resp[2], resp[3]); }