Skip to content

Commit a2f99fb

Browse files
suab321321bp3tk0v
authored andcommitted
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
1 parent 9e08ac1 commit a2f99fb

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

drivers/edac/i7core_edac.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ static const struct pci_id_table pci_dev_table[] = {
376376
PCI_ID_TABLE_ENTRY(pci_dev_descr_i7core_nehalem),
377377
PCI_ID_TABLE_ENTRY(pci_dev_descr_lynnfield),
378378
PCI_ID_TABLE_ENTRY(pci_dev_descr_i7core_westmere),
379-
{0,} /* 0 terminated list. */
379+
{ NULL, }
380380
};
381381

382382
/*
@@ -385,7 +385,7 @@ static const struct pci_id_table pci_dev_table[] = {
385385
static const struct pci_device_id i7core_pci_tbl[] = {
386386
{PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_X58_HUB_MGMT)},
387387
{PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_LYNNFIELD_QPI_LINK0)},
388-
{0,} /* 0 terminated list. */
388+
{ 0, }
389389
};
390390

391391
/****************************************************************************

drivers/edac/sb_edac.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ static const struct pci_id_descr pci_dev_descr_sbridge[] = {
439439

440440
static const struct pci_id_table pci_dev_descr_sbridge_table[] = {
441441
PCI_ID_TABLE_ENTRY(pci_dev_descr_sbridge, ARRAY_SIZE(pci_dev_descr_sbridge), 1, SANDY_BRIDGE),
442-
{0,} /* 0 terminated list. */
442+
{ NULL, }
443443
};
444444

445445
/* This changes depending if 1HA or 2HA:
@@ -505,7 +505,7 @@ static const struct pci_id_descr pci_dev_descr_ibridge[] = {
505505

506506
static const struct pci_id_table pci_dev_descr_ibridge_table[] = {
507507
PCI_ID_TABLE_ENTRY(pci_dev_descr_ibridge, 12, 2, IVY_BRIDGE),
508-
{0,} /* 0 terminated list. */
508+
{ NULL, }
509509
};
510510

511511
/* Haswell support */
@@ -576,7 +576,7 @@ static const struct pci_id_descr pci_dev_descr_haswell[] = {
576576

577577
static const struct pci_id_table pci_dev_descr_haswell_table[] = {
578578
PCI_ID_TABLE_ENTRY(pci_dev_descr_haswell, 13, 2, HASWELL),
579-
{0,} /* 0 terminated list. */
579+
{ NULL, }
580580
};
581581

582582
/* Knight's Landing Support */
@@ -620,7 +620,7 @@ static const struct pci_id_descr pci_dev_descr_knl[] = {
620620

621621
static const struct pci_id_table pci_dev_descr_knl_table[] = {
622622
PCI_ID_TABLE_ENTRY(pci_dev_descr_knl, ARRAY_SIZE(pci_dev_descr_knl), 1, KNIGHTS_LANDING),
623-
{0,}
623+
{ NULL, }
624624
};
625625

626626
/*
@@ -686,7 +686,7 @@ static const struct pci_id_descr pci_dev_descr_broadwell[] = {
686686

687687
static const struct pci_id_table pci_dev_descr_broadwell_table[] = {
688688
PCI_ID_TABLE_ENTRY(pci_dev_descr_broadwell, 10, 2, BROADWELL),
689-
{0,} /* 0 terminated list. */
689+
{ NULL, }
690690
};
691691

692692

0 commit comments

Comments
 (0)