lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e4a2c1206cc8009f0e0881e2b9ec2e828c5d9e7c.camel@perches.com>
Date:   Sun, 19 Apr 2020 04:44:58 -0700
From:   Joe Perches <joe@...ches.com>
To:     Tang Bin <tangbin@...s.chinamobile.com>, davem@...emloft.net,
        herbert@...dor.apana.org.au
Cc:     linux-crypto@...r.kernel.org, linux-kernel@...r.kernel.org,
        Shengju Zhang <zhangshengju@...s.chinamobile.com>
Subject: Re: [PATCH] crypto: Delete redundant variable definition

On Sun, 2020-04-19 at 15:12 +0800, Tang Bin wrote:
> The variable "i" is redundant to be assigned a value
> of zero,because it's assigned in the for loop, so remove
> redundant one here.
> 
> Signed-off-by: Shengju Zhang <zhangshengju@...s.chinamobile.com>
> Signed-off-by: Tang Bin <tangbin@...s.chinamobile.com>
> 
> ---
>  drivers/crypto/bcm/cipher.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/crypto/bcm/cipher.c b/drivers/crypto/bcm/cipher.c
> index c8b940854..5db23c18c 100644
> --- a/drivers/crypto/bcm/cipher.c
> +++ b/drivers/crypto/bcm/cipher.c
> @@ -4724,7 +4724,6 @@ static int spu_dt_read(struct platform_device *pdev)
>  	spu->spu_type = matched_spu_type->type;
>  	spu->spu_subtype = matched_spu_type->subtype;
>  
> -	i = 0;
>  	for (i = 0; (i < MAX_SPUS) && ((spu_ctrl_regs =
>  		platform_get_resource(pdev, IORESOURCE_MEM, i)) != NULL); i++) {

Maybe the for loop could be simplified too by
moving the assignment inside the loop.

Also, the %pe extension could be used.

Perhaps:
---
 drivers/crypto/bcm/cipher.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/crypto/bcm/cipher.c b/drivers/crypto/bcm/cipher.c
index c8b940..7d6afa4 100644
--- a/drivers/crypto/bcm/cipher.c
+++ b/drivers/crypto/bcm/cipher.c
@@ -4707,7 +4707,6 @@ static int spu_dt_read(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
 	struct spu_hw *spu = &iproc_priv.spu;
-	struct resource *spu_ctrl_regs;
 	const struct spu_type_subtype *matched_spu_type;
 	struct device_node *dn = pdev->dev.of_node;
 	int err, i;
@@ -4724,19 +4723,23 @@ static int spu_dt_read(struct platform_device *pdev)
 	spu->spu_type = matched_spu_type->type;
 	spu->spu_subtype = matched_spu_type->subtype;
 
-	i = 0;
-	for (i = 0; (i < MAX_SPUS) && ((spu_ctrl_regs =
-		platform_get_resource(pdev, IORESOURCE_MEM, i)) != NULL); i++) {
+	for (i = 0; i < MAX_SPUS; i++) {
+		struct resource *spu_ctrl_regs;
+
+		spu_ctrl_regs = platform_get_resource(pdev, IORESOURCE_MEM, i);
+		if (!spu_ctrl_regs)
+			break;
 
 		spu->reg_vbase[i] = devm_ioremap_resource(dev, spu_ctrl_regs);
 		if (IS_ERR(spu->reg_vbase[i])) {
 			err = PTR_ERR(spu->reg_vbase[i]);
-			dev_err(&pdev->dev, "Failed to map registers: %d\n",
-				err);
+			dev_err(&pdev->dev, "Failed to map registers: %pe\n",
+				spu->reg_vbase[i]);
 			spu->reg_vbase[i] = NULL;
 			return err;
 		}
 	}
+
 	spu->num_spu = i;
 	dev_dbg(dev, "Device has %d SPUs", spu->num_spu);
 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ