cpupower: Fix comparing pointer to 0 coccicheck warns
Shuah Khan
maintainerPATCH 1/1 cpupower: Fix comparing pointer to 0 coccicheck warns
Fix cocciccheck wanrns found by:
make coccicheck MODE=report M=tools/power/cpupower/
tools/power/cpupower/utils/helpers/bitmask.c:29:12-13: WARNING comparing pointer to 0, suggest !E tools/power/cpupower/utils/helpers/bitmask.c:29:12-13: WARNING comparing pointer to 0 tools/power/cpupower/utils/helpers/bitmask.c:43:12-13: WARNING comparing pointer to 0
--- tools/power/cpupower/utils/helpers/bitmask.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/power/cpupower/utils/helpers/bitmask.c +3 -3
@@ -26,11 +26,11 @@ struct bitmask *bitmask_alloc(unsigned int n)struct bitmask *bmp; bmp =malloc (sizeof (*bmp)); -if (bmp ==0 ) +if (!bmp)return 0 ; bmp->size = n; bmp->maskp =calloc (longsperbits (n),sizeof (unsigned long )); -if (bmp->maskp ==0 ) { +if (!bmp->maskp) {free (bmp);return 0 ; }
@@ -40,7 +40,7 @@ struct bitmask *bitmask_alloc(unsigned int n)/* Free `struct bitmask` */ void bitmask_free (struct bitmask *bmp) { -if (bmp ==0 ) +if (!bmp)return ;free (bmp->maskp); bmp->maskp = (unsigned long *)0xdeadcdef ;/* double free tripwire */
Signature · 1 line
2.25.1
Shuah Khan
maintainerPATCH 1/1 cpupower: Fix NULL but dereferenced coccicheck errors
Fix NULL but dereferenced coccicheck errors found by:
make coccicheck MODE=report M=tools/power/cpupower
tools/power/cpupower/lib/cpufreq.c:384:19-23: ERROR: first is NULL but dereferenced. tools/power/cpupower/lib/cpufreq.c:440:19-23: ERROR: first is NULL but dereferenced. tools/power/cpupower/lib/cpufreq.c:308:19-23: ERROR: first is NULL but dereferenced. tools/power/cpupower/lib/cpufreq.c:753:19-23: ERROR: first is NULL but dereferenced.
--- tools/power/cpupower/lib/cpufreq.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
tools/power/cpupower/lib/cpufreq.c +5 -5
@@ -285,7 +285,7 @@ struct cpufreq_available_governors *cpufreq_get_available_governors(unsigned }else { first =malloc (sizeof (*first));if (!first) - goto error_out; +return NULL ; current = first; } current->first = first;
@@ -362,7 +362,7 @@ struct cpufreq_available_frequencies }else { first =malloc (sizeof (*first));if (!first) - goto error_out; +return NULL ; current = first; } current->first = first;
@@ -418,7 +418,7 @@ struct cpufreq_available_frequencies }else { first =malloc (sizeof (*first));if (!first) - goto error_out; +return NULL ; current = first; } current->first = first;
@@ -493,7 +493,7 @@ static struct cpufreq_affected_cpus *sysfs_get_cpu_list(unsigned int cpu, }else { first =malloc (sizeof (*first));if (!first) - goto error_out; +return NULL ; current = first; } current->first = first;
@@ -726,7 +726,7 @@ struct cpufreq_stats *cpufreq_get_stats(unsigned int cpu, }else { first =malloc (sizeof (*first));if (!first) - goto error_out; +return NULL ; current = first; } current->first = first;
Signature · 1 line
2.25.1