2017-04-19 09:08:21

by SF Markus Elfring

[permalink] [raw]
Subject: [PATCH 0/2] n2rng: Fine-tuning for n2rng_probe()

From: Markus Elfring <[email protected]>
Date: Wed, 19 Apr 2017 11:00:11 +0200

Two update suggestions were taken into account
from static source code analysis.

Markus Elfring (2):
Use devm_kcalloc()
Combine substrings for two messages

drivers/char/hw_random/n2-drv.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)

--
2.12.2


2017-04-19 09:10:28

by SF Markus Elfring

[permalink] [raw]
Subject: [PATCH 1/2] n2rng: Use devm_kcalloc() in n2rng_probe()

From: Markus Elfring <[email protected]>
Date: Wed, 19 Apr 2017 10:30:47 +0200

* A multiplication for the size determination of a memory allocation
indicated that an array data structure should be processed.
Thus use the corresponding function "devm_kcalloc".

* Replace the specification of a data structure by a pointer dereference
to make the corresponding size determination a bit safer according to
the Linux coding style convention.

Signed-off-by: Markus Elfring <[email protected]>
---
drivers/char/hw_random/n2-drv.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/char/hw_random/n2-drv.c b/drivers/char/hw_random/n2-drv.c
index 31cbdbbaebfc..92dd4e925315 100644
--- a/drivers/char/hw_random/n2-drv.c
+++ b/drivers/char/hw_random/n2-drv.c
@@ -748,9 +748,7 @@ static int n2rng_probe(struct platform_device *op)

dev_info(&op->dev, "Registered RNG HVAPI major %lu minor %lu\n",
np->hvapi_major, np->hvapi_minor);
-
- np->units = devm_kzalloc(&op->dev,
- sizeof(struct n2rng_unit) * np->num_units,
+ np->units = devm_kcalloc(&op->dev, np->num_units, sizeof(*np->units),
GFP_KERNEL);
err = -ENOMEM;
if (!np->units)
--
2.12.2

2017-04-19 09:11:35

by SF Markus Elfring

[permalink] [raw]
Subject: [PATCH 2/2] n2rng: Combine substrings for two messages in n2rng_probe()

From: Markus Elfring <[email protected]>
Date: Wed, 19 Apr 2017 10:50:04 +0200

The script "checkpatch.pl" pointed information out like the following.

WARNING: quoted string split across lines

Thus fix the affected source code places.

Signed-off-by: Markus Elfring <[email protected]>
---
drivers/char/hw_random/n2-drv.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/char/hw_random/n2-drv.c b/drivers/char/hw_random/n2-drv.c
index 92dd4e925315..f3e67c768101 100644
--- a/drivers/char/hw_random/n2-drv.c
+++ b/drivers/char/hw_random/n2-drv.c
@@ -723,16 +723,16 @@ static int n2rng_probe(struct platform_device *op)
if (sun4v_hvapi_register(HV_GRP_RNG,
np->hvapi_major,
&np->hvapi_minor)) {
- dev_err(&op->dev, "Cannot register suitable "
- "HVAPI version.\n");
+ dev_err(&op->dev,
+ "Cannot register suitable HVAPI version.\n");
goto out;
}
}

if (np->flags & N2RNG_FLAG_MULTI) {
if (np->hvapi_major < 2) {
- dev_err(&op->dev, "multi-unit-capable RNG requires "
- "HVAPI major version 2 or later, got %lu\n",
+ dev_err(&op->dev,
+ "multi-unit-capable RNG requires HVAPI major version 2 or later, got %lu\n",
np->hvapi_major);
goto out_hvapi_unregister;
}
--
2.12.2


2017-04-19 15:24:36

by Shannon Nelson

[permalink] [raw]
Subject: Re: [PATCH 1/2] n2rng: Use devm_kcalloc() in n2rng_probe()

On 4/19/2017 2:10 AM, SF Markus Elfring wrote:
> From: Markus Elfring <[email protected]>
> Date: Wed, 19 Apr 2017 10:30:47 +0200
>
> * A multiplication for the size determination of a memory allocation
> indicated that an array data structure should be processed.
> Thus use the corresponding function "devm_kcalloc".
>
> * Replace the specification of a data structure by a pointer dereference
> to make the corresponding size determination a bit safer according to
> the Linux coding style convention.
>
> Signed-off-by: Markus Elfring <[email protected]>

Thanks Markus.

Acked-by: Shannon Nelson <[email protected]>

> ---
> drivers/char/hw_random/n2-drv.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/char/hw_random/n2-drv.c b/drivers/char/hw_random/n2-drv.c
> index 31cbdbbaebfc..92dd4e925315 100644
> --- a/drivers/char/hw_random/n2-drv.c
> +++ b/drivers/char/hw_random/n2-drv.c
> @@ -748,9 +748,7 @@ static int n2rng_probe(struct platform_device *op)
>
> dev_info(&op->dev, "Registered RNG HVAPI major %lu minor %lu\n",
> np->hvapi_major, np->hvapi_minor);
> -
> - np->units = devm_kzalloc(&op->dev,
> - sizeof(struct n2rng_unit) * np->num_units,
> + np->units = devm_kcalloc(&op->dev, np->num_units, sizeof(*np->units),
> GFP_KERNEL);
> err = -ENOMEM;
> if (!np->units)
>

2017-04-19 15:24:41

by Shannon Nelson

[permalink] [raw]
Subject: Re: [PATCH 2/2] n2rng: Combine substrings for two messages in n2rng_probe()

On 4/19/2017 2:11 AM, SF Markus Elfring wrote:
> From: Markus Elfring <[email protected]>
> Date: Wed, 19 Apr 2017 10:50:04 +0200
>
> The script "checkpatch.pl" pointed information out like the following.
>
> WARNING: quoted string split across lines
>
> Thus fix the affected source code places.
>
> Signed-off-by: Markus Elfring <[email protected]>

Thanks Markus.

Acked-by: Shannon Nelson <[email protected]>


> ---
> drivers/char/hw_random/n2-drv.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/char/hw_random/n2-drv.c b/drivers/char/hw_random/n2-drv.c
> index 92dd4e925315..f3e67c768101 100644
> --- a/drivers/char/hw_random/n2-drv.c
> +++ b/drivers/char/hw_random/n2-drv.c
> @@ -723,16 +723,16 @@ static int n2rng_probe(struct platform_device *op)
> if (sun4v_hvapi_register(HV_GRP_RNG,
> np->hvapi_major,
> &np->hvapi_minor)) {
> - dev_err(&op->dev, "Cannot register suitable "
> - "HVAPI version.\n");
> + dev_err(&op->dev,
> + "Cannot register suitable HVAPI version.\n");
> goto out;
> }
> }
>
> if (np->flags & N2RNG_FLAG_MULTI) {
> if (np->hvapi_major < 2) {
> - dev_err(&op->dev, "multi-unit-capable RNG requires "
> - "HVAPI major version 2 or later, got %lu\n",
> + dev_err(&op->dev,
> + "multi-unit-capable RNG requires HVAPI major version 2 or later, got %lu\n",
> np->hvapi_major);
> goto out_hvapi_unregister;
> }
>

2017-04-21 11:38:55

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH 2/2] n2rng: Combine substrings for two messages in n2rng_probe()

On Wed, Apr 19, 2017 at 11:11:35AM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <[email protected]>
> Date: Wed, 19 Apr 2017 10:50:04 +0200
>
> The script "checkpatch.pl" pointed information out like the following.
>
> WARNING: quoted string split across lines
>
> Thus fix the affected source code places.
>
> Signed-off-by: Markus Elfring <[email protected]>

This patch doesn't seem to add any value so I'm not taking it.

Please don't send patches based purely on a checkpatch complaint.

Thanks,
--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

2017-04-21 13:16:13

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH 1/2] n2rng: Use devm_kcalloc() in n2rng_probe()

On Wed, Apr 19, 2017 at 11:10:07AM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <[email protected]>
> Date: Wed, 19 Apr 2017 10:30:47 +0200
>
> * A multiplication for the size determination of a memory allocation
> indicated that an array data structure should be processed.
> Thus use the corresponding function "devm_kcalloc".
>
> * Replace the specification of a data structure by a pointer dereference
> to make the corresponding size determination a bit safer according to
> the Linux coding style convention.
>
> Signed-off-by: Markus Elfring <[email protected]>

Patch applied. Thanks.
--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

2017-04-21 18:32:31

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 2/2] n2rng: Combine substrings for two messages in n2rng_probe()

From: Herbert Xu <[email protected]>
Date: Fri, 21 Apr 2017 19:36:41 +0800

> On Wed, Apr 19, 2017 at 11:11:35AM +0200, SF Markus Elfring wrote:
>> From: Markus Elfring <[email protected]>
>> Date: Wed, 19 Apr 2017 10:50:04 +0200
>>
>> The script "checkpatch.pl" pointed information out like the following.
>>
>> WARNING: quoted string split across lines
>>
>> Thus fix the affected source code places.
>>
>> Signed-off-by: Markus Elfring <[email protected]>
>
> This patch doesn't seem to add any value so I'm not taking it.
>
> Please don't send patches based purely on a checkpatch complaint.

Thank you Herbert.

2017-04-21 18:22:49

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH 2/2] n2rng: Combine substrings for two messages in n2rng_probe()

On Fri, 2017-04-21 at 19:36 +0800, Herbert Xu wrote:
> On Wed, Apr 19, 2017 at 11:11:35AM +0200, SF Markus Elfring wrote:
> > From: Markus Elfring <[email protected]>
> > Date: Wed, 19 Apr 2017 10:50:04 +0200
> >
> > The script "checkpatch.pl" pointed information out like the following.
> >
> > WARNING: quoted string split across lines
> >
> > Thus fix the affected source code places.
> >
> > Signed-off-by: Markus Elfring <[email protected]>
>
> This patch doesn't seem to add any value so I'm not taking it.

Your choice.

The general reason to merge strings is in CodingStyle

2) Breaking long lines and strings
[]
never break user-visible strings such as
printk messages, because that breaks the ability to grep for them.