From patchwork Tue Jul 7 02:40:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 11647379 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 B363460D for ; Tue, 7 Jul 2020 02:56:42 +0000 (UTC) Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9B88420708 for ; Tue, 7 Jul 2020 02:56:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9B88420708 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-nvdimm-bounces@lists.01.org Received: from ml01.vlan13.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 8B27C1108DEAC; Mon, 6 Jul 2020 19:56:42 -0700 (PDT) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=134.134.136.100; helo=mga07.intel.com; envelope-from=dan.j.williams@intel.com; receiver= Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 2F3111108DEA9 for ; Mon, 6 Jul 2020 19:56:40 -0700 (PDT) IronPort-SDR: NgAiLeRABPfnqpD8NKlLE4TrSpHZJtUTUO4+qss8kPgxwbX+riT2JMtvJrrs885d0g/Dm00r98 wEgVD+7Ayv7g== X-IronPort-AV: E=McAfee;i="6000,8403,9674"; a="212503340" X-IronPort-AV: E=Sophos;i="5.75,321,1589266800"; d="scan'208";a="212503340" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2020 19:56:39 -0700 IronPort-SDR: nbRpX/zozROd5lWxQx8jfzIXH+gXrxFwmj0/Aqh6JowhhjHATn2cQ0OmbW2hADWp8cdniuxoGj 0hvypY6yn4Tw== X-IronPort-AV: E=Sophos;i="5.75,321,1589266800"; d="scan'208";a="482903844" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2020 19:56:39 -0700 Subject: [ndctl PATCH 01/16] ndctl/build: Fix zero-length array warnings From: Dan Williams To: linux-nvdimm@lists.01.org Cc: vishal.l.verma@intel.com Date: Mon, 06 Jul 2020 19:40:23 -0700 Message-ID: <159408962360.2386154.5219921025264845019.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <159408961822.2386154.888266173771881937.stgit@dwillia2-desk3.amr.corp.intel.com> References: <159408961822.2386154.888266173771881937.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-3-g996c MIME-Version: 1.0 Message-ID-Hash: 6P5J62UUVAHCKXTVEC4VQMRTEVRPZ37A X-Message-ID-Hash: 6P5J62UUVAHCKXTVEC4VQMRTEVRPZ37A X-MailFrom: dan.j.williams@intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.1.1 Precedence: list List-Id: "Linux-nvdimm developer list." Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: GCC10 emits warnings like: msft.c: In function ‘msft_cmd_smart_get_media_temperature’: msft.c:146:28: warning: array subscript 0 is outside the bounds of an interior zero-length array ‘struct ndn_msft_smart_data[0]’ [-Wzero-length-bounds] hpe1.c: In function ‘hpe1_cmd_smart_get_flags’: hpe1.c:111:33: warning: array subscript 0 is outside the bounds of an interior zero-length array ‘struct ndn_hpe1_smart_data[0]’ [-Wzero-length-bounds] ars.c: In function ‘ndctl_cmd_ars_get_record_addr’: ars.c:274:38: warning: array subscript ‘() + 4294967295’ is outside the bounds of an interior zero-length array ‘struct nd_ars_record[0]’ [-Wzero-length-bounds] In the case of the 'msft' and 'hpe1' implementation the zero-length array is not needed because they are declared with a union of a buffer of the same size as a single element. Fix those cases by just declaring a single element array. The ARS case is different, it's complaining about an internal zero-length member. Switch to the recommended [1] flexible-array syntax for that case. [1]: https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html Signed-off-by: Dan Williams --- ndctl/lib/hpe1.h | 4 ++-- ndctl/lib/msft.h | 2 +- ndctl/ndctl.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ndctl/lib/hpe1.h b/ndctl/lib/hpe1.h index b050831ec2c4..1afa54f127a6 100644 --- a/ndctl/lib/hpe1.h +++ b/ndctl/lib/hpe1.h @@ -111,7 +111,7 @@ struct ndn_hpe1_smart { __u32 status; union { __u8 buf[124]; - struct ndn_hpe1_smart_data data[0]; + struct ndn_hpe1_smart_data data[1]; }; } __attribute__((packed)); @@ -136,7 +136,7 @@ struct ndn_hpe1_smart_threshold { __u32 status; union { __u8 buf[32]; - struct ndn_hpe1_smart_threshold_data data[0]; + struct ndn_hpe1_smart_threshold_data data[1]; }; } __attribute__((packed)); diff --git a/ndctl/lib/msft.h b/ndctl/lib/msft.h index 0a1c7c6a0907..c45981edd8d7 100644 --- a/ndctl/lib/msft.h +++ b/ndctl/lib/msft.h @@ -46,7 +46,7 @@ struct ndn_msft_smart { __u32 status; union { __u8 buf[9]; - struct ndn_msft_smart_data data[0]; + struct ndn_msft_smart_data data[1]; }; } __attribute__((packed)); diff --git a/ndctl/ndctl.h b/ndctl/ndctl.h index 008f81cdeb9f..e3605b3d64b4 100644 --- a/ndctl/ndctl.h +++ b/ndctl/ndctl.h @@ -91,7 +91,7 @@ struct nd_cmd_ars_status { __u32 reserved; __u64 err_address; __u64 length; - } __attribute__((packed)) records[0]; + } __attribute__((packed)) records[]; } __attribute__((packed)); struct nd_cmd_clear_error {