Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

EDAC/{sb,i7core}_edac: Do not use a plain integer for a NULL pointer

Sparse warns about the use of the integer constant 0 as a NULL pointer
with the -Wnon-pointer-null switch.

Even though the C standard requires that 0 == NULL and type conversion
rules turn an integer constant 0 into a NULL pointer when cast to a void
* type, Linus notes that this is a very poor situation from a type
safety angle and a pointer should be initialized with a pointer type
- not an integer constant.

See https://www.spinics.net/lists/linux-sparse/msg10066.html for more
info.

[ bp: Rewrite commit message, drop useless comments in the code. ]

Signed-off-by: Abhinav Singh <singhabhinav9051571833@gmail.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/r/20231128141703.614605-1-singhabhinav9051571833@gmail.com

authored by

Abhinav Singh and committed by
Borislav Petkov (AMD)
a2f99fba 9e08ac1b

+7 -7
+2 -2
drivers/edac/i7core_edac.c
··· 376 376 PCI_ID_TABLE_ENTRY(pci_dev_descr_i7core_nehalem), 377 377 PCI_ID_TABLE_ENTRY(pci_dev_descr_lynnfield), 378 378 PCI_ID_TABLE_ENTRY(pci_dev_descr_i7core_westmere), 379 - {0,} /* 0 terminated list. */ 379 + { NULL, } 380 380 }; 381 381 382 382 /* ··· 385 385 static const struct pci_device_id i7core_pci_tbl[] = { 386 386 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_X58_HUB_MGMT)}, 387 387 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_LYNNFIELD_QPI_LINK0)}, 388 - {0,} /* 0 terminated list. */ 388 + { 0, } 389 389 }; 390 390 391 391 /****************************************************************************
+5 -5
drivers/edac/sb_edac.c
··· 439 439 440 440 static const struct pci_id_table pci_dev_descr_sbridge_table[] = { 441 441 PCI_ID_TABLE_ENTRY(pci_dev_descr_sbridge, ARRAY_SIZE(pci_dev_descr_sbridge), 1, SANDY_BRIDGE), 442 - {0,} /* 0 terminated list. */ 442 + { NULL, } 443 443 }; 444 444 445 445 /* This changes depending if 1HA or 2HA: ··· 505 505 506 506 static const struct pci_id_table pci_dev_descr_ibridge_table[] = { 507 507 PCI_ID_TABLE_ENTRY(pci_dev_descr_ibridge, 12, 2, IVY_BRIDGE), 508 - {0,} /* 0 terminated list. */ 508 + { NULL, } 509 509 }; 510 510 511 511 /* Haswell support */ ··· 576 576 577 577 static const struct pci_id_table pci_dev_descr_haswell_table[] = { 578 578 PCI_ID_TABLE_ENTRY(pci_dev_descr_haswell, 13, 2, HASWELL), 579 - {0,} /* 0 terminated list. */ 579 + { NULL, } 580 580 }; 581 581 582 582 /* Knight's Landing Support */ ··· 620 620 621 621 static const struct pci_id_table pci_dev_descr_knl_table[] = { 622 622 PCI_ID_TABLE_ENTRY(pci_dev_descr_knl, ARRAY_SIZE(pci_dev_descr_knl), 1, KNIGHTS_LANDING), 623 - {0,} 623 + { NULL, } 624 624 }; 625 625 626 626 /* ··· 686 686 687 687 static const struct pci_id_table pci_dev_descr_broadwell_table[] = { 688 688 PCI_ID_TABLE_ENTRY(pci_dev_descr_broadwell, 10, 2, BROADWELL), 689 - {0,} /* 0 terminated list. */ 689 + { NULL, } 690 690 }; 691 691 692 692