[RESEND PATCH v7 1/2] EDAC/qcom: Remove extra error no assignment in qcom_llcc_core_setup()

Manivannan Sadhasivam posted 2 patches 2 years, 7 months ago
There is a newer version of this series
[RESEND PATCH v7 1/2] EDAC/qcom: Remove extra error no assignment in qcom_llcc_core_setup()
Posted by Manivannan Sadhasivam 2 years, 7 months ago
If the ret variable is initialized with -EINVAL, then there is no need to
assign it again in the default case of qcom_llcc_core_setup().

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
---
 drivers/edac/qcom_edac.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/edac/qcom_edac.c b/drivers/edac/qcom_edac.c
index 265e0fb39bc7..53d666ffcb1f 100644
--- a/drivers/edac/qcom_edac.c
+++ b/drivers/edac/qcom_edac.c
@@ -170,7 +170,7 @@ static int qcom_llcc_core_setup(struct regmap *llcc_bcast_regmap)
 static int
 qcom_llcc_clear_error_status(int err_type, struct llcc_drv_data *drv)
 {
-	int ret = 0;
+	int ret = -EINVAL;
 
 	switch (err_type) {
 	case LLCC_DRAM_CE:
@@ -198,7 +198,6 @@ qcom_llcc_clear_error_status(int err_type, struct llcc_drv_data *drv)
 			return ret;
 		break;
 	default:
-		ret = -EINVAL;
 		edac_printk(KERN_CRIT, EDAC_LLCC, "Unexpected error type: %d\n",
 			    err_type);
 	}
-- 
2.25.1
Re: [RESEND PATCH v7 1/2] EDAC/qcom: Remove extra error no assignment in qcom_llcc_core_setup()
Posted by Borislav Petkov 2 years, 7 months ago
On Wed, May 17, 2023 at 11:58:58AM +0530, Manivannan Sadhasivam wrote:
> If the ret variable is initialized with -EINVAL, then there is no need to
> assign it again in the default case of qcom_llcc_core_setup().
> 
> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> ---
>  drivers/edac/qcom_edac.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/edac/qcom_edac.c b/drivers/edac/qcom_edac.c
> index 265e0fb39bc7..53d666ffcb1f 100644
> --- a/drivers/edac/qcom_edac.c
> +++ b/drivers/edac/qcom_edac.c
> @@ -170,7 +170,7 @@ static int qcom_llcc_core_setup(struct regmap *llcc_bcast_regmap)
>  static int
>  qcom_llcc_clear_error_status(int err_type, struct llcc_drv_data *drv)
>  {
> -	int ret = 0;
> +	int ret = -EINVAL;

It is actually better to leave it here uninitialized...

>  
>  	switch (err_type) {
>  	case LLCC_DRAM_CE:
> @@ -198,7 +198,6 @@ qcom_llcc_clear_error_status(int err_type, struct llcc_drv_data *drv)
>  			return ret;
>  		break;
>  	default:
> -		ret = -EINVAL;

... and initialize it here to -EINVAL because then it is perfectly clear
what the default case returns. Instead of going through the whole
function.

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette