diff mbox series

[v2] driver : edac : Fix warning using plain integer as NULL

Message ID 20231127214156.432669-1-singhabhinav9051571833@gmail.com (mailing list archive)
State New, archived
Headers show
Series [v2] driver : edac : Fix warning using plain integer as NULL | expand

Commit Message

Abhinav Singh Nov. 27, 2023, 9:41 p.m. UTC
Sparse static analysis tools generate a warning with this message
"Using plain integer as NULL pointer". In this case this warning is
being shown because we are trying to initialize  pointer to NULL using
integer value 0.

The reason for this change is that use of numeric 0 for a null pointer is 
unacceptable. See this link for the long description why:
Link: https://www.spinics.net/lists/linux-sparse/msg10066.html

Signed-off-by: Abhinav Singh <singhabhinav9051571833@gmail.com>
---
v1 -> v2: 1. Fixed the comment section descrbing the current code.
	  2. Added a reason for why this change is required.

 drivers/edac/i7core_edac.c | 4 ++--
 drivers/edac/sb_edac.c     | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

Comments

Abhinav Singh Nov. 27, 2023, 9:47 p.m. UTC | #1
On 11/28/23 03:11, Abhinav Singh wrote:
> Sparse static analysis tools generate a warning with this message
> "Using plain integer as NULL pointer". In this case this warning is
> being shown because we are trying to initialize  pointer to NULL using
> integer value 0.
> 
> The reason for this change is that use of numeric 0 for a null pointer is
> unacceptable. See this link for the long description why:
> Link: https://www.spinics.net/lists/linux-sparse/msg10066.html
> 
> Signed-off-by: Abhinav Singh <singhabhinav9051571833@gmail.com>
> ---
> v1 -> v2: 1. Fixed the comment section descrbing the current code.
> 	  2. Added a reason for why this change is required.
> 
>   drivers/edac/i7core_edac.c | 4 ++--
>   drivers/edac/sb_edac.c     | 6 +++---
>   2 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/edac/i7core_edac.c b/drivers/edac/i7core_edac.c
> index 08bf20c60111..4c76d0f180ec 100644
> --- a/drivers/edac/i7core_edac.c
> +++ b/drivers/edac/i7core_edac.c
> @@ -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),
> -	{NULL,}			/* 0 terminated list. */
> +	{NULL,}			/* NULL terminated list. */
>   };
>   
>   /*
> @@ -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,}			/* NULL terminated list. */
>   };
>   
>   /****************************************************************************
> diff --git a/drivers/edac/sb_edac.c b/drivers/edac/sb_edac.c
> index a3f50a66de33..5d9a2963dc54 100644
> --- a/drivers/edac/sb_edac.c
> +++ b/drivers/edac/sb_edac.c
> @@ -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),
> -	{NULL,}			/* 0 terminated list. */
> +	{NULL,}			/* NULL terminated list. */
>   };
>   
>   /* This changes depending if 1HA or 2HA:
> @@ -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),
> -	{NULL,}			/* 0 terminated list. */
> +	{NULL,}			/* NULL terminated list. */
>   };
>   
>   /* Knight's Landing Support */
> @@ -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),
> -	{NULL,}			/* 0 terminated list. */
> +	{NULL,}			/* NULL terminated list. */
>   };
>   
>   
Thank You, for explaining me what needs to be done. Yeah without a 
proper reason a change is never really clear which can be confusing to 
anyone looking. I will make sure I add a reason in every patch from now on.

Thank You,
Abhinav Singh
Qiuxu Zhuo Nov. 28, 2023, 7:47 a.m. UTC | #2
> From: Abhinav Singh <singhabhinav9051571833@gmail.com>
> ...
> diff --git a/drivers/edac/i7core_edac.c b/drivers/edac/i7core_edac.c index
> 08bf20c60111..4c76d0f180ec 100644
> --- a/drivers/edac/i7core_edac.c
> +++ b/drivers/edac/i7core_edac.c
> @@ -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),
> -	{NULL,}			/* 0 terminated list. */
> +	{NULL,}			/* NULL terminated list. */
>  };
> 
>  /*
> @@ -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,}			/* NULL terminated list. */
>  };

The updated comment (NULL pointer) mismatches the code (zero value).
diff mbox series

Patch

diff --git a/drivers/edac/i7core_edac.c b/drivers/edac/i7core_edac.c
index 08bf20c60111..4c76d0f180ec 100644
--- a/drivers/edac/i7core_edac.c
+++ b/drivers/edac/i7core_edac.c
@@ -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),
-	{NULL,}			/* 0 terminated list. */
+	{NULL,}			/* NULL terminated list. */
 };
 
 /*
@@ -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,}			/* NULL terminated list. */
 };
 
 /****************************************************************************
diff --git a/drivers/edac/sb_edac.c b/drivers/edac/sb_edac.c
index a3f50a66de33..5d9a2963dc54 100644
--- a/drivers/edac/sb_edac.c
+++ b/drivers/edac/sb_edac.c
@@ -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),
-	{NULL,}			/* 0 terminated list. */
+	{NULL,}			/* NULL terminated list. */
 };
 
 /* This changes depending if 1HA or 2HA:
@@ -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),
-	{NULL,}			/* 0 terminated list. */
+	{NULL,}			/* NULL terminated list. */
 };
 
 /* Knight's Landing Support */
@@ -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),
-	{NULL,}			/* 0 terminated list. */
+	{NULL,}			/* NULL terminated list. */
 };