EDAC/{sb,i7core}_edac: Do not use a plain integer for a NULL pointer
authorAbhinav Singh <singhabhinav9051571833@gmail.com>
Tue, 28 Nov 2023 14:17:03 +0000 (19:47 +0530)
committerBorislav Petkov (AMD) <bp@alien8.de>
Tue, 28 Nov 2023 14:43:43 +0000 (15:43 +0100)
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
drivers/edac/i7core_edac.c
drivers/edac/sb_edac.c

index 23d25724bae4c68def916da70075d5326e5927d0..91e0a88ef90471f9ea49a9937343b0ee39b8d35b 100644 (file)
@@ -376,7 +376,7 @@ static const struct pci_id_table pci_dev_table[] = {
        PCI_ID_TABLE_ENTRY(pci_dev_descr_i7core_nehalem),
        PCI_ID_TABLE_ENTRY(pci_dev_descr_lynnfield),
        PCI_ID_TABLE_ENTRY(pci_dev_descr_i7core_westmere),
-       {0,}                    /* 0 terminated list. */
+       { NULL, }
 };
 
 /*
@@ -385,7 +385,7 @@ static const struct pci_id_table pci_dev_table[] = {
 static const struct pci_device_id i7core_pci_tbl[] = {
        {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_X58_HUB_MGMT)},
        {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_LYNNFIELD_QPI_LINK0)},
-       {0,}                    /* 0 terminated list. */
+       { 0, }
 };
 
 /****************************************************************************
index 0c779a0326b628fc9b07d63fe0991ce5ca8bddcf..26cca5a9322da142cccef16ddeecb9d897c438bc 100644 (file)
@@ -439,7 +439,7 @@ static const struct pci_id_descr pci_dev_descr_sbridge[] = {
 
 static const struct pci_id_table pci_dev_descr_sbridge_table[] = {
        PCI_ID_TABLE_ENTRY(pci_dev_descr_sbridge, ARRAY_SIZE(pci_dev_descr_sbridge), 1, SANDY_BRIDGE),
-       {0,}                    /* 0 terminated list. */
+       { NULL, }
 };
 
 /* This changes depending if 1HA or 2HA:
@@ -505,7 +505,7 @@ static const struct pci_id_descr pci_dev_descr_ibridge[] = {
 
 static const struct pci_id_table pci_dev_descr_ibridge_table[] = {
        PCI_ID_TABLE_ENTRY(pci_dev_descr_ibridge, 12, 2, IVY_BRIDGE),
-       {0,}                    /* 0 terminated list. */
+       { NULL, }
 };
 
 /* Haswell support */
@@ -576,7 +576,7 @@ static const struct pci_id_descr pci_dev_descr_haswell[] = {
 
 static const struct pci_id_table pci_dev_descr_haswell_table[] = {
        PCI_ID_TABLE_ENTRY(pci_dev_descr_haswell, 13, 2, HASWELL),
-       {0,}                    /* 0 terminated list. */
+       { NULL, }
 };
 
 /* Knight's Landing Support */
@@ -620,7 +620,7 @@ static const struct pci_id_descr pci_dev_descr_knl[] = {
 
 static const struct pci_id_table pci_dev_descr_knl_table[] = {
        PCI_ID_TABLE_ENTRY(pci_dev_descr_knl, ARRAY_SIZE(pci_dev_descr_knl), 1, KNIGHTS_LANDING),
-       {0,}
+       { NULL, }
 };
 
 /*
@@ -686,7 +686,7 @@ static const struct pci_id_descr pci_dev_descr_broadwell[] = {
 
 static const struct pci_id_table pci_dev_descr_broadwell_table[] = {
        PCI_ID_TABLE_ENTRY(pci_dev_descr_broadwell, 10, 2, BROADWELL),
-       {0,}                    /* 0 terminated list. */
+       { NULL, }
 };