linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] hwmon-NCT: Fine-tuning for four function implementations
@ 2017-04-27  9:27 SF Markus Elfring
  2017-04-27  9:28 ` [PATCH 1/4] hwmon-nct6683: Use devm_kcalloc() in nct6683_create_attr_group() SF Markus Elfring
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: SF Markus Elfring @ 2017-04-27  9:27 UTC (permalink / raw)
  To: linux-hwmon, Günter Röck, Jean Delvare; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 27 Apr 2017 11:18:22 +0200

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

Markus Elfring (4):
  Use devm_kcalloc() in nct6683_create_attr_group()
  Adjust five checks for null pointers
  Use devm_kcalloc() in nct6775_create_attr_group()
  Adjust seven checks for null pointers

 drivers/hwmon/nct6683.c | 15 +++++++--------
 drivers/hwmon/nct6775.c | 19 +++++++++----------
 2 files changed, 16 insertions(+), 18 deletions(-)

-- 
2.12.2

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/4] hwmon-nct6683: Use devm_kcalloc() in nct6683_create_attr_group()
  2017-04-27  9:27 [PATCH 0/4] hwmon-NCT: Fine-tuning for four function implementations SF Markus Elfring
@ 2017-04-27  9:28 ` SF Markus Elfring
  2017-04-27  9:29 ` [PATCH 2/4] hwmon-nct6683: Adjust five checks for null pointers SF Markus Elfring
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: SF Markus Elfring @ 2017-04-27  9:28 UTC (permalink / raw)
  To: linux-hwmon, Günter Röck, Jean Delvare; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 27 Apr 2017 10:10:36 +0200

Multiplications for the size determination of memory allocations
indicated that array data structures should be processed.
Thus use the corresponding function "devm_kcalloc".

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/hwmon/nct6683.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/hwmon/nct6683.c b/drivers/hwmon/nct6683.c
index 8b0bc4fc06e8..dd14a98cc6dd 100644
--- a/drivers/hwmon/nct6683.c
+++ b/drivers/hwmon/nct6683.c
@@ -426,13 +426,12 @@ nct6683_create_attr_group(struct device *dev,
 	if (group == NULL)
 		return ERR_PTR(-ENOMEM);
 
-	attrs = devm_kzalloc(dev, sizeof(*attrs) * (repeat * count + 1),
+	attrs = devm_kcalloc(dev, repeat * count + 1, sizeof(*attrs),
 			     GFP_KERNEL);
 	if (attrs == NULL)
 		return ERR_PTR(-ENOMEM);
 
-	su = devm_kzalloc(dev, sizeof(*su) * repeat * count,
-			  GFP_KERNEL);
+	su = devm_kcalloc(dev, repeat * count, sizeof(*su), GFP_KERNEL);
 	if (su == NULL)
 		return ERR_PTR(-ENOMEM);
 
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/4] hwmon-nct6683: Adjust five checks for null pointers
  2017-04-27  9:27 [PATCH 0/4] hwmon-NCT: Fine-tuning for four function implementations SF Markus Elfring
  2017-04-27  9:28 ` [PATCH 1/4] hwmon-nct6683: Use devm_kcalloc() in nct6683_create_attr_group() SF Markus Elfring
@ 2017-04-27  9:29 ` SF Markus Elfring
  2017-04-27  9:30 ` [PATCH 3/4] hwmon-nct6775: Use devm_kcalloc() in nct6775_create_attr_group() SF Markus Elfring
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: SF Markus Elfring @ 2017-04-27  9:29 UTC (permalink / raw)
  To: linux-hwmon, Günter Röck, Jean Delvare; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 27 Apr 2017 10:22:39 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The script “checkpatch.pl” pointed information out like the following.

Comparison to NULL could be written …

Thus fix the affected source code places.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/hwmon/nct6683.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/hwmon/nct6683.c b/drivers/hwmon/nct6683.c
index dd14a98cc6dd..4deb46ce8834 100644
--- a/drivers/hwmon/nct6683.c
+++ b/drivers/hwmon/nct6683.c
@@ -423,16 +423,16 @@ nct6683_create_attr_group(struct device *dev,
 		return ERR_PTR(-EINVAL);
 
 	group = devm_kzalloc(dev, sizeof(*group), GFP_KERNEL);
-	if (group == NULL)
+	if (!group)
 		return ERR_PTR(-ENOMEM);
 
 	attrs = devm_kcalloc(dev, repeat * count + 1, sizeof(*attrs),
 			     GFP_KERNEL);
-	if (attrs == NULL)
+	if (!attrs)
 		return ERR_PTR(-ENOMEM);
 
 	su = devm_kcalloc(dev, repeat * count, sizeof(*su), GFP_KERNEL);
-	if (su == NULL)
+	if (!su)
 		return ERR_PTR(-ENOMEM);
 
 	group->attrs = attrs;
@@ -440,7 +440,7 @@ nct6683_create_attr_group(struct device *dev,
 
 	for (i = 0; i < repeat; i++) {
 		t = tg->templates;
-		for (j = 0; *t != NULL; j++) {
+		for (j = 0; *t; j++) {
 			snprintf(su->name, sizeof(su->name),
 				 (*t)->dev_attr.attr.name, tg->base + i);
 			if ((*t)->s2) {
@@ -1179,7 +1179,7 @@ static void nct6683_setup_sensors(struct nct6683_data *data)
 		if (reg >= NUM_MON_LABELS)
 			continue;
 		/* Skip if disabled or reserved */
-		if (nct6683_mon_label[reg] == NULL)
+		if (!nct6683_mon_label[reg])
 			continue;
 		if (reg < MON_VOLTAGE_START) {
 			data->temp_index[data->temp_num] = i;
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/4] hwmon-nct6775: Use devm_kcalloc() in nct6775_create_attr_group()
  2017-04-27  9:27 [PATCH 0/4] hwmon-NCT: Fine-tuning for four function implementations SF Markus Elfring
  2017-04-27  9:28 ` [PATCH 1/4] hwmon-nct6683: Use devm_kcalloc() in nct6683_create_attr_group() SF Markus Elfring
  2017-04-27  9:29 ` [PATCH 2/4] hwmon-nct6683: Adjust five checks for null pointers SF Markus Elfring
@ 2017-04-27  9:30 ` SF Markus Elfring
  2017-04-27  9:31 ` [PATCH 4/4] hwmon-nct6775: Adjust seven checks for null pointers SF Markus Elfring
  2017-04-27 12:50 ` [PATCH 0/4] hwmon-NCT: Fine-tuning for four function implementations Jean Delvare
  4 siblings, 0 replies; 7+ messages in thread
From: SF Markus Elfring @ 2017-04-27  9:30 UTC (permalink / raw)
  To: linux-hwmon, Günter Röck, Jean Delvare; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 27 Apr 2017 10:35:36 +0200

Multiplications for the size determination of memory allocations
indicated that array data structures should be processed.
Thus use the corresponding function "devm_kcalloc".

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/hwmon/nct6775.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c
index 2458b406f6aa..d552ab7901a7 100644
--- a/drivers/hwmon/nct6775.c
+++ b/drivers/hwmon/nct6775.c
@@ -1073,13 +1073,12 @@ nct6775_create_attr_group(struct device *dev,
 	if (group == NULL)
 		return ERR_PTR(-ENOMEM);
 
-	attrs = devm_kzalloc(dev, sizeof(*attrs) * (repeat * count + 1),
+	attrs = devm_kcalloc(dev, repeat * count + 1, sizeof(*attrs),
 			     GFP_KERNEL);
 	if (attrs == NULL)
 		return ERR_PTR(-ENOMEM);
 
-	su = devm_kzalloc(dev, sizeof(*su) * repeat * count,
-			       GFP_KERNEL);
+	su = devm_kcalloc(dev, repeat * count, sizeof(*su), GFP_KERNEL);
 	if (su == NULL)
 		return ERR_PTR(-ENOMEM);
 
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 4/4] hwmon-nct6775: Adjust seven checks for null pointers
  2017-04-27  9:27 [PATCH 0/4] hwmon-NCT: Fine-tuning for four function implementations SF Markus Elfring
                   ` (2 preceding siblings ...)
  2017-04-27  9:30 ` [PATCH 3/4] hwmon-nct6775: Use devm_kcalloc() in nct6775_create_attr_group() SF Markus Elfring
@ 2017-04-27  9:31 ` SF Markus Elfring
  2017-04-27 12:50 ` [PATCH 0/4] hwmon-NCT: Fine-tuning for four function implementations Jean Delvare
  4 siblings, 0 replies; 7+ messages in thread
From: SF Markus Elfring @ 2017-04-27  9:31 UTC (permalink / raw)
  To: linux-hwmon, Günter Röck, Jean Delvare; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 27 Apr 2017 10:55:24 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The script “checkpatch.pl” pointed information out like the following.

Comparison to NULL could be written …

Thus fix the affected source code places.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/hwmon/nct6775.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c
index d552ab7901a7..fe8713fb548c 100644
--- a/drivers/hwmon/nct6775.c
+++ b/drivers/hwmon/nct6775.c
@@ -1070,16 +1070,16 @@ nct6775_create_attr_group(struct device *dev,
 		return ERR_PTR(-EINVAL);
 
 	group = devm_kzalloc(dev, sizeof(*group), GFP_KERNEL);
-	if (group == NULL)
+	if (!group)
 		return ERR_PTR(-ENOMEM);
 
 	attrs = devm_kcalloc(dev, repeat * count + 1, sizeof(*attrs),
 			     GFP_KERNEL);
-	if (attrs == NULL)
+	if (!attrs)
 		return ERR_PTR(-ENOMEM);
 
 	su = devm_kcalloc(dev, repeat * count, sizeof(*su), GFP_KERNEL);
-	if (su == NULL)
+	if (!su)
 		return ERR_PTR(-ENOMEM);
 
 	group->attrs = attrs;
@@ -1087,7 +1087,7 @@ nct6775_create_attr_group(struct device *dev,
 
 	for (i = 0; i < repeat; i++) {
 		t = tg->templates;
-		while (*t != NULL) {
+		while (*t) {
 			snprintf(su->name, sizeof(su->name),
 				 (*t)->dev_attr.attr.name, tg->base + i);
 			if ((*t)->s2) {
@@ -3000,11 +3000,11 @@ static umode_t nct6775_pwm_is_visible(struct kobject *kobj,
 	if ((nr >= 14 && nr <= 18) || nr == 21)   /* weight */
 		if (!data->REG_WEIGHT_TEMP_SEL[pwm])
 			return 0;
-	if (nr == 19 && data->REG_PWM[3] == NULL) /* pwm_max */
+	if (nr == 19 && !data->REG_PWM[3]) /* pwm_max */
 		return 0;
-	if (nr == 20 && data->REG_PWM[4] == NULL) /* pwm_step */
+	if (nr == 20 && !data->REG_PWM[4]) /* pwm_step */
 		return 0;
-	if (nr == 21 && data->REG_PWM[6] == NULL) /* weight_duty_base */
+	if (nr == 21 && !data->REG_PWM[6]) /* weight_duty_base */
 		return 0;
 
 	if (nr >= 22 && nr <= 35) {		/* auto point */
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/4] hwmon-NCT: Fine-tuning for four function implementations
  2017-04-27  9:27 [PATCH 0/4] hwmon-NCT: Fine-tuning for four function implementations SF Markus Elfring
                   ` (3 preceding siblings ...)
  2017-04-27  9:31 ` [PATCH 4/4] hwmon-nct6775: Adjust seven checks for null pointers SF Markus Elfring
@ 2017-04-27 12:50 ` Jean Delvare
  2017-04-27 13:23   ` SF Markus Elfring
  4 siblings, 1 reply; 7+ messages in thread
From: Jean Delvare @ 2017-04-27 12:50 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-hwmon, Günter Röck, LKML, kernel-janitors

On Thu, 27 Apr 2017 11:27:21 +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 27 Apr 2017 11:18:22 +0200
> 
> A few update suggestions were taken into account
> from static source code analysis.
> 
> Markus Elfring (4):
>   Use devm_kcalloc() in nct6683_create_attr_group()
>   Adjust five checks for null pointers
>   Use devm_kcalloc() in nct6775_create_attr_group()
>   Adjust seven checks for null pointers
> 
>  drivers/hwmon/nct6683.c | 15 +++++++--------
>  drivers/hwmon/nct6775.c | 19 +++++++++----------
>  2 files changed, 16 insertions(+), 18 deletions(-)

Nack. You have proven in the past on various lists that 1* you have no
understanding about the changes you are proposing and 2* you have no
skills to discuss any problem that could be found in your patches.

So I'll make it straight: we will not take any patch from you. You are
an annoyance we don't need. Do not waste our time. Go away.

-- 
Jean Delvare
SUSE L3 Support

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: hwmon-NCT: Fine-tuning for four function implementations
  2017-04-27 12:50 ` [PATCH 0/4] hwmon-NCT: Fine-tuning for four function implementations Jean Delvare
@ 2017-04-27 13:23   ` SF Markus Elfring
  0 siblings, 0 replies; 7+ messages in thread
From: SF Markus Elfring @ 2017-04-27 13:23 UTC (permalink / raw)
  To: Jean Delvare; +Cc: linux-hwmon, Günter Röck, LKML, kernel-janitors



Am 27.04.2017 um 14:50 schrieb Jean Delvare:
> On Thu, 27 Apr 2017 11:27:21 +0200, SF Markus Elfring wrote:
>> From: Markus Elfring <elfring@users.sourceforge.net>
>> Date: Thu, 27 Apr 2017 11:18:22 +0200
>>
>> A few update suggestions were taken into account
>> from static source code analysis.
>>
>> Markus Elfring (4):
>>   Use devm_kcalloc() in nct6683_create_attr_group()
>>   Adjust five checks for null pointers
>>   Use devm_kcalloc() in nct6775_create_attr_group()
>>   Adjust seven checks for null pointers
>>
>>  drivers/hwmon/nct6683.c | 15 +++++++--------
>>  drivers/hwmon/nct6775.c | 19 +++++++++----------
>>  2 files changed, 16 insertions(+), 18 deletions(-)
> 
> You have proven in the past on various lists that 1* you have no
> understanding about the changes you are proposing

You are right in the sense that my knowledge is still incomplete
in some areas.


> and 2* you have no skills to discuss any problem that could be found
> in your patches.

But I disagree to this view. My skills might not fit to your expectations
at the moment. But I hope that there are further opportunities to resolve
remaining software development concerns.

Regards,
Markus

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-04-27 13:24 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-27  9:27 [PATCH 0/4] hwmon-NCT: Fine-tuning for four function implementations SF Markus Elfring
2017-04-27  9:28 ` [PATCH 1/4] hwmon-nct6683: Use devm_kcalloc() in nct6683_create_attr_group() SF Markus Elfring
2017-04-27  9:29 ` [PATCH 2/4] hwmon-nct6683: Adjust five checks for null pointers SF Markus Elfring
2017-04-27  9:30 ` [PATCH 3/4] hwmon-nct6775: Use devm_kcalloc() in nct6775_create_attr_group() SF Markus Elfring
2017-04-27  9:31 ` [PATCH 4/4] hwmon-nct6775: Adjust seven checks for null pointers SF Markus Elfring
2017-04-27 12:50 ` [PATCH 0/4] hwmon-NCT: Fine-tuning for four function implementations Jean Delvare
2017-04-27 13:23   ` SF Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).