]> git.baikalelectronics.ru Git - kernel.git/commitdiff
scsi: libfc: Replace one-element arrays with flexible-array members
authorGustavo A. R. Silva <gustavoars@kernel.org>
Mon, 14 Feb 2022 22:39:03 +0000 (16:39 -0600)
committerMartin K. Petersen <martin.petersen@oracle.com>
Mon, 28 Feb 2022 02:17:37 +0000 (21:17 -0500)
Use flexible-array members in struct fc_fdmi_attr_entry and fs_fdmi_attrs
instead of one-element arrays, and refactor the code accordingly.

Also, this helps with the ongoing efforts to globally enable -Warray-bounds
and get us closer to being able to tighten the FORTIFY_SOURCE routines on
memcpy().

https://github.com/KSPP/linux/issues/79
https://github.com/ClangBuiltLinux/linux/issues/1590

Link: https://lore.kernel.org/r/20220214223903.GA859464@embeddedor
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/libfc/fc_encode.h
include/scsi/fc/fc_ms.h

index 74ae7fd15d8db764556c9bdb1ca71401f62eca66..7dcac3b6baa7eef0c1a4dddd7937feaa0a76831b 100644 (file)
@@ -246,7 +246,7 @@ static inline int fc_ct_ms_fill(struct fc_lport *lport,
                                   &entry->type);
                put_unaligned_be16(len, &entry->len);
                put_unaligned_be64(lport->wwnn,
-                                  (__be64 *)&entry->value[0]);
+                                  (__be64 *)&entry->value);
 
                /* Manufacturer */
                entry = (struct fc_fdmi_attr_entry *)((char *)entry->value +
index 00191695233a56bc7ad87c0186f853dc8ba096a4..56a5d2b5a6245f1bc552cfc84de28c5adc5e3b8d 100644 (file)
@@ -158,7 +158,7 @@ struct fc_fdmi_port_name {
 struct fc_fdmi_attr_entry {
        __be16          type;
        __be16          len;
-       __u8            value[1];
+       __u8            value[];
 } __attribute__((__packed__));
 
 /*
@@ -166,7 +166,7 @@ struct fc_fdmi_attr_entry {
  */
 struct fs_fdmi_attrs {
        __be32                          numattrs;
-       struct fc_fdmi_attr_entry       attr[1];
+       struct fc_fdmi_attr_entry       attr[];
 } __attribute__((__packed__));
 
 /*