Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1631986 > unrolled thread

[PATCH 0/4] hwmon-NCT: Fine-tuning for four function implementations

Started bySF Markus Elfring <elfring@users.sourceforge.net>
First post2017-04-27 11:30 +0200
Last post2017-04-27 15:30 +0200
Articles 7 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 0/4] hwmon-NCT: Fine-tuning for four function implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2017-04-27 11:30 +0200
    [PATCH 4/4] hwmon-nct6775: Adjust seven checks for null pointers SF Markus Elfring <elfring@users.sourceforge.net> - 2017-04-27 11:40 +0200
    [PATCH 1/4] hwmon-nct6683: Use devm_kcalloc() in  nct6683_create_attr_group() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-04-27 11:40 +0200
    [PATCH 2/4] hwmon-nct6683: Adjust five checks for null pointers SF Markus Elfring <elfring@users.sourceforge.net> - 2017-04-27 11:40 +0200
    [PATCH 3/4] hwmon-nct6775: Use devm_kcalloc() in  nct6775_create_attr_group() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-04-27 11:40 +0200
    Re: [PATCH 0/4] hwmon-NCT: Fine-tuning for four function  implementations Jean Delvare <jdelvare@suse.de> - 2017-04-27 15:00 +0200
      Re: hwmon-NCT: Fine-tuning for four function implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2017-04-27 15:30 +0200

#1631986 — [PATCH 0/4] hwmon-NCT: Fine-tuning for four function implementations

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2017-04-27 11:30 +0200
Subject[PATCH 0/4] hwmon-NCT: Fine-tuning for four function implementations
Message-ID<tANUl-6Xr-13@gated-at.bofh.it>
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

[toc] | [next] | [standalone]


#1631990 — [PATCH 4/4] hwmon-nct6775: Adjust seven checks for null pointers

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2017-04-27 11:40 +0200
Subject[PATCH 4/4] hwmon-nct6775: Adjust seven checks for null pointers
Message-ID<tAO42-716-25@gated-at.bofh.it>
In reply to#1631986
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

[toc] | [prev] | [next] | [standalone]


#1631991 — [PATCH 1/4] hwmon-nct6683: Use devm_kcalloc() in nct6683_create_attr_group()

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2017-04-27 11:40 +0200
Subject[PATCH 1/4] hwmon-nct6683: Use devm_kcalloc() in nct6683_create_attr_group()
Message-ID<tAO42-716-19@gated-at.bofh.it>
In reply to#1631986
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

[toc] | [prev] | [next] | [standalone]


#1631992 — [PATCH 2/4] hwmon-nct6683: Adjust five checks for null pointers

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2017-04-27 11:40 +0200
Subject[PATCH 2/4] hwmon-nct6683: Adjust five checks for null pointers
Message-ID<tAO42-716-23@gated-at.bofh.it>
In reply to#1631986
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

[toc] | [prev] | [next] | [standalone]


#1631993 — [PATCH 3/4] hwmon-nct6775: Use devm_kcalloc() in nct6775_create_attr_group()

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2017-04-27 11:40 +0200
Subject[PATCH 3/4] hwmon-nct6775: Use devm_kcalloc() in nct6775_create_attr_group()
Message-ID<tAO42-716-31@gated-at.bofh.it>
In reply to#1631986
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

[toc] | [prev] | [next] | [standalone]


#1632085 — Re: [PATCH 0/4] hwmon-NCT: Fine-tuning for four function implementations

FromJean Delvare <jdelvare@suse.de>
Date2017-04-27 15:00 +0200
SubjectRe: [PATCH 0/4] hwmon-NCT: Fine-tuning for four function implementations
Message-ID<tARbz-Jt-1@gated-at.bofh.it>
In reply to#1631986
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

[toc] | [prev] | [next] | [standalone]


#1632096 — Re: hwmon-NCT: Fine-tuning for four function implementations

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2017-04-27 15:30 +0200
SubjectRe: hwmon-NCT: Fine-tuning for four function implementations
Message-ID<tAREB-1aB-13@gated-at.bofh.it>
In reply to#1632085

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

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web