hwmon-NCT: Fine-tuning for four function implementations
Subsystems (2)
cover hwmon-NCT: Fine-tuning for four function implementations
From: Markus Elfring <[email protected]>
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(-)
Signature · 1 line
2.12.2
PATCH 1/4 hwmon-nct6683: Use devm_kcalloc() in nct6683_create_attr_group()
From: Markus Elfring <[email protected]>
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.
--- drivers/hwmon/nct6683.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/hwmon/nct6683.c +2 -3
@@ -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 );
Signature · 1 line
2.12.2
PATCH 2/4 hwmon-nct6683: Adjust five checks for null pointers
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
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.
--- drivers/hwmon/nct6683.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/hwmon/nct6683.c +5 -5
@@ -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;
Signature · 1 line
2.12.2
PATCH 3/4 hwmon-nct6775: Use devm_kcalloc() in nct6775_create_attr_group()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
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.
--- drivers/hwmon/nct6775.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/hwmon/nct6775.c +2 -3
@@ -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 );
Signature · 1 line
2.12.2
PATCH 4/4 hwmon-nct6775: Adjust seven checks for null pointers
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
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.
--- drivers/hwmon/nct6775.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/hwmon/nct6775.c +7 -7
@@ -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 */
Signature · 1 line
2.12.2
Quoted 12 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Thu, 27 Apr 2017 11:18:22 +0200A few update suggestions were taken into account
from static source code analysis.Markus Elfring (4):
Usedevm_kcalloc()innct6683_create_attr_group()Adjust five checks for null pointers
Usedevm_kcalloc()innct6775_create_attr_group()Adjust seven checks for null pointers
Quoted 3 lines
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.
Signature · 2 lines
Jean Delvare SUSE L3 Support
Am 27.04.2017 um 14:50 schrieb Jean Delvare:
Quoted 13 lines · SF Markus Elfring
Quoted 12 lines
From: Markus Elfring <[email protected]>
Date: Thu, 27 Apr 2017 11:18:22 +0200A few update suggestions were taken into account
from static source code analysis.Markus Elfring (4):
Usedevm_kcalloc()innct6683_create_attr_group()Adjust five checks for null pointers
Usedevm_kcalloc()innct6775_create_attr_group()Adjust seven checks for null pointers
Quoted 6 lines
Quoted 3 lines
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.
Quoted 2 lines
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