Skip to contentSkip to conversation

serial: 8250_pci: fix -Winitializer-overrides for Brainboxes UC-260/271/701/756 entries

PATCH In review Rosen Penev 2 participants 3 messages May 28 – Jul 7 TTY layer and serial drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 serial: 8250_pci: fix -Winitializer-overrides for Brainboxes UC-260/271/701/756 entries

PCI_VDEVICE() expands to set .class=0 and .class_mask=0, but the Brainboxes
UC-260/271/701/756 entries immediately override those fields. This causes a build error with clang -Werror,-Winitializer-overrides.

Fix by expanding PCI_VDEVICE() manually, omitting the trailing
.class/.class_mask zeroes so each field is set exactly once.

Found with W=1

Assisted-by Opencode:Big-pickle
---
 drivers/tty/serial/8250/8250_pci.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/tty/serial/8250/8250_pci.c +4 -2
index 3e5bc9e8d269..0513f4b3c093 100644
@@ -5394,12 +5394,14 @@ static const struct pci_device_id serial_pci_tbl[] = {
 	 * Brainboxes UC-260/271/701/756
 	 */
 	{
-		PCI_VDEVICE(INTASHIELD, 0x0D21),
+		.vendor = PCI_VENDOR_ID_INTASHIELD, .device = 0x0D21,
+		.subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID,
 		.class = PCI_CLASS_COMMUNICATION_MULTISERIAL << 8,
 		.class_mask = 0xffff00,
 		.driver_data = pbn_b2_4_115200,
 	}, {
-		PCI_VDEVICE(INTASHIELD, 0x0E34),
+		.vendor = PCI_VENDOR_ID_INTASHIELD, .device = 0x0E34,
+		.subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID,
 		.class = PCI_CLASS_COMMUNICATION_MULTISERIAL << 8,
 		.class_mask = 0xffff00,
 		.driver_data = pbn_b2_4_115200,
Signature · 1 line
2.54.0
#1 lore raw
Quoted 39 lines · Rosen Penev

PCI_VDEVICE() expands to set .class=0 and .class_mask=0, but the Brainboxes
UC-260/271/701/756 entries immediately override those fields. This causes a build error with clang -Werror,-Winitializer-overrides.

Fix by expanding PCI_VDEVICE() manually, omitting the trailing
.class/.class_mask zeroes so each field is set exactly once.

Found with W=1

Assisted-by Opencode:Big-pickle
---
 drivers/tty/serial/8250/8250_pci.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/tty/serial/8250/8250_pci.c +4 -2
index 3e5bc9e8d269..0513f4b3c093 100644
@@ -5394,12 +5394,14 @@ static const struct pci_device_id serial_pci_tbl[] = {
 	 * Brainboxes UC-260/271/701/756
 	 */
 	{
-		PCI_VDEVICE(INTASHIELD, 0x0D21),
+		.vendor = PCI_VENDOR_ID_INTASHIELD, .device = 0x0D21,
+		.subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID,
 		.class = PCI_CLASS_COMMUNICATION_MULTISERIAL << 8,
 		.class_mask = 0xffff00,
 		.driver_data = pbn_b2_4_115200,
 	}, {
-		PCI_VDEVICE(INTASHIELD, 0x0E34),
+		.vendor = PCI_VENDOR_ID_INTASHIELD, .device = 0x0E34,
+		.subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID,
 		.class = PCI_CLASS_COMMUNICATION_MULTISERIAL << 8,
 		.class_mask = 0xffff00,
 		.driver_data = pbn_b2_4_115200,
Signature · 1 line
2.54.0

Does not apply to the current tree :(

#2 lore raw
Quoted 35 lines · Greg Kroah-Hartman
Quoted 33 lines · Rosen Penev

PCI_VDEVICE() expands to set .class=0 and .class_mask=0, but the Brainboxes
UC-260/271/701/756 entries immediately override those fields. This causes a build error with clang -Werror,-Winitializer-overrides.

Fix by expanding PCI_VDEVICE() manually, omitting the trailing
.class/.class_mask zeroes so each field is set exactly once.

Found with W=1

Assisted-by Opencode:Big-pickle
---
 drivers/tty/serial/8250/8250_pci.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/tty/serial/8250/8250_pci.c +4 -2
index 3e5bc9e8d269..0513f4b3c093 100644
@@ -5394,12 +5394,14 @@ static const struct pci_device_id serial_pci_tbl[] = {
       * Brainboxes UC-260/271/701/756
       */
      {
-             PCI_VDEVICE(INTASHIELD, 0x0D21),
+             .vendor = PCI_VENDOR_ID_INTASHIELD, .device = 0x0D21,
+             .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID,
              .class = PCI_CLASS_COMMUNICATION_MULTISERIAL << 8,
              .class_mask = 0xffff00,
              .driver_data = pbn_b2_4_115200,
      }, {
-             PCI_VDEVICE(INTASHIELD, 0x0E34),
+             .vendor = PCI_VENDOR_ID_INTASHIELD, .device = 0x0E34,
+             .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID,
Quoted 8 lines
Quoted 6 lines
drivers/tty/serial/8250/8250_pci.c +0 -1
              .class = PCI_CLASS_COMMUNICATION_MULTISERIAL << 8,
              .class_mask = 0xffff00,
              .driver_data = pbn_b2_4_115200,
--

2.54.0

Does not apply to the current tree :(

This appears to have been fixed in 426e83cab1f5d53069ac7030cb03e2d7c6367ef1