All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Williams <dan.j.williams@intel.com>
To: linux-nvdimm@lists.01.org
Cc: vishal.l.verma@intel.com
Subject: [ndctl PATCH 01/16] ndctl/build: Fix zero-length array warnings
Date: Mon, 06 Jul 2020 19:40:23 -0700	[thread overview]
Message-ID: <159408962360.2386154.5219921025264845019.stgit@dwillia2-desk3.amr.corp.intel.com> (raw)
In-Reply-To: <159408961822.2386154.888266173771881937.stgit@dwillia2-desk3.amr.corp.intel.com>

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 ‘(<unknown>) + 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 <dan.j.williams@intel.com>
---
 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 {
_______________________________________________
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-leave@lists.01.org

  reply	other threads:[~2020-07-07  2:56 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-07  2:40 [ndctl PATCH 00/16] Firmware Activation and Test Updates Dan Williams
2020-07-07  2:40 ` Dan Williams [this message]
2020-07-07  2:40 ` [ndctl PATCH 02/16] ndctl/dimm: Fix chatty status messages Dan Williams
2020-07-07  2:40 ` [ndctl PATCH 03/16] ndctl/list: Indicate firmware update capability Dan Williams
2020-07-07  2:40 ` [ndctl PATCH 04/16] ndctl/dimm: Detect firmware-update vs ARS conflict Dan Williams
2020-07-07  2:40 ` [ndctl PATCH 05/16] ndctl/dimm: Improve firmware-update failure message Dan Williams
2020-07-07  2:40 ` [ndctl PATCH 06/16] ndctl/dimm: Prepare to emit dimm json object after firmware update Dan Williams
2020-07-07  2:40 ` [ndctl PATCH 07/16] ndctl/dimm: Emit dimm firmware details after update Dan Williams
2020-07-07  2:41 ` [ndctl PATCH 08/16] ndctl/list: Add firmware activation enumeration Dan Williams
2020-07-07  2:41 ` [ndctl PATCH 09/16] ndctl/dimm: Auto-arm firmware activation Dan Williams
2020-07-07  2:41 ` [ndctl PATCH 10/16] ndctl/bus: Add 'activate-firmware' command Dan Williams
2020-07-07  2:41 ` [ndctl PATCH 11/16] ndctl/docs: Update copyright date Dan Williams
2020-07-07  2:41 ` [ndctl PATCH 12/16] ndctl/test: Test firmware-activation interface Dan Williams
2020-07-07  2:41 ` [ndctl PATCH 13/16] test: Validate strict iomem protections of pmem Dan Williams
2020-07-07  2:41 ` [ndctl PATCH 14/16] ndctl: Refactor nfit.h to acpi.h Dan Williams
2020-07-07  2:41 ` [ndctl PATCH 15/16] daxctl: Add 'split-acpi' command to generate custom ACPI tables Dan Williams
2020-07-07  2:41 ` [ndctl PATCH 16/16] test/ndctl: mremap pmd confusion Dan Williams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=159408962360.2386154.5219921025264845019.stgit@dwillia2-desk3.amr.corp.intel.com \
    --to=dan.j.williams@intel.com \
    --cc=linux-nvdimm@lists.01.org \
    --cc=vishal.l.verma@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.