MIPS-kernel: Adjustments for some function implementations
Subsystems (2)
cover MIPS-kernel: Adjustments for some function implementations
From: Markus Elfring <[email protected]>
Date: Tue, 23 May 2017 22:40:04 +0200
A few update suggestions were taken into account
from static source code analysis.
Markus Elfring (5):
Delete an error message for a failed memory allocation in cps_pm_online_cpu() Delete error messages for failed memory allocations in cps_prepare_cpus() Delete an error message for a failed memory allocation in vpe_open() Improve a size determination in two functions
Adjust 13 checks for null pointers
arch/mips/kernel/pm-cps.c | 5 ++--- arch/mips/kernel/smp-cps.c | 9 ++------- arch/mips/kernel/vpe.c | 37 +++++++++++++++++-------------------- 3 files changed, 21 insertions(+), 30 deletions(-)
Signature · 1 line
2.13.0
PATCH 1/5 MIPS: pm-cps: Delete an error message for a failed memory allocation in cps_pm_online_cpu()
From c7eaa7be6235b37023b23b40b36737f72e5b4b3f Mon Sep 17 00:00:00 2001
From: Markus Elfring <[email protected]>
Date: Tue, 23 May 2017 21:30:11 +0200
Subject: [PATCH 1/5] MIPS: pm-cps: Delete an error message for a failed memory allocation in cps_pm_online_cpu()
Omit an extra message for a memory allocation failure in this function.
This issue was detected by using the Coccinelle software.
--- arch/mips/kernel/pm-cps.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
arch/mips/kernel/pm-cps.c +2 -3
@@ -666,7 +666,6 @@ static int cps_pm_online_cpu(unsigned int cpu) -if (!core_rc) { -pr_err ("Failed allocate core %u ready_count\n" , core); +if (!core_rc)return -ENOMEM ; - } +per_cpu (ready_count_alloc, core) = core_rc;/* Ensure ready_count is aligned to a cacheline boundary */
Signature · 1 line
2.13.0
PATCH 2/5 MIPS: smp-cps: Delete error messages for failed memory allocations in cps_prepare_cpus()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 23 May 2017 21:41:32 +0200
Omit two extra messages for memory allocation failures in this function.
This issue was detected by using the Coccinelle software.
--- arch/mips/kernel/smp-cps.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
arch/mips/kernel/smp-cps.c +2 -7
@@ -171,7 +171,5 @@ static void __init cps_prepare_cpus(unsigned int max_cpus) -if (!mips_cps_core_bootcfg) { -pr_err ("Failed to allocate boot config for %u cores\n" , ncores); +if (!mips_cps_core_bootcfg) goto err_out; - }/* Allocate VPE boot configuration structs */ for (c =0 ; c < ncores; c++) {
@@ -182,8 +180,5 @@ static void __init cps_prepare_cpus(unsigned int max_cpus) -if (!mips_cps_core_bootcfg[c].vpe_config) { -pr_err ("Failed to allocate %u VPE boot configs\n" , - core_vpes); +if (!mips_cps_core_bootcfg[c].vpe_config) goto err_out; - } }/* Mark this CPU as booted */
Signature · 1 line
2.13.0
PATCH 3/5 MIPS: VPE: Delete an error message for a failed memory allocation in vpe_open()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 23 May 2017 21:54:42 +0200
Omit an extra message for a memory allocation failure in this function.
This issue was detected by using the Coccinelle software.
--- arch/mips/kernel/vpe.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
arch/mips/kernel/vpe.c +2 -3
@@ -799,7 +799,6 @@ static int vpe_open(struct inode *inode, struct file *filp) -if (!v->pbuffer) { -pr_warn ("VPE loader: unable to allocate memory\n" ); +if (!v->pbuffer)return -ENOMEM ; - } + v->plen =P_SIZE ; v->load_addr =NULL ; v->len =0 ;
Signature · 1 line
2.13.0
PATCH 4/5 MIPS: VPE: Improve a size determination in two functions
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 23 May 2017 22:04:17 +0200
Replace the specification of two data structures by pointer dereferences as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention.
--- arch/mips/kernel/vpe.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/mips/kernel/vpe.c +2 -2
@@ -93,7 +93,7 @@ struct vpe *alloc_vpe(int minor) {struct vpe *v; - v =kzalloc (sizeof (struct vpe ),GFP_KERNEL ); + v =kzalloc (sizeof (*v),GFP_KERNEL );if (v =NULL ) goto out;
@@ -114,7 +114,7 @@ struct tc *alloc_tc(int index) {struct tc *tc; - tc =kzalloc (sizeof (struct tc ),GFP_KERNEL ); + tc =kzalloc (sizeof (*tc),GFP_KERNEL );if (tc =NULL ) goto out;
Signature · 1 line
2.13.0
PATCH 5/5 MIPS: VPE: Adjust 13 checks for null pointers
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 23 May 2017 22:16: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.
--- arch/mips/kernel/vpe.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-)
arch/mips/kernel/vpe.c +13 -15
@@ -97,4 +97,4 @@ struct vpe *alloc_vpe(int minor) -if (v =NULL ) +if (!v) goto out;INIT_LIST_HEAD (&v->tc);
@@ -118,4 +118,4 @@ struct tc *alloc_tc(int index) -if (tc =NULL ) +if (!tc) goto out;INIT_LIST_HEAD (&tc->tc);
@@ -340,10 +340,9 @@ static int apply_r_mips_lo16(struct module *me, uint32_t *location,/* Sign extend the addend we extract from the lo insn. */ vallo = ((insnlo &0xffff ) ^0x8000 ) -0x8000 ; -if (mips_hi16_list !=NULL ) { - +if (mips_hi16_list) { l = mips_hi16_list; -while (l !=NULL ) { +while (l) {unsigned long insn;/*
@@ -391,7 +390,7 @@ static int apply_r_mips_lo16(struct module *me, uint32_t *location,return 0 ; out_free: -while (l !=NULL ) { +while (l) { next = l->next;kfree (l); l = next;
@@ -562,7 +561,7 @@ static int find_vpe_symbols(struct vpe *v, Elf_Shdr *sechdrs, v->shared_ptr = (void *)sym[i].st_value; } -if ((v->__start =0 ) || (v->shared_ptr =NULL )) +if ((v->__start =0 ) || !v->shared_ptr)return -1 ;return 0 ;
@@ -737,7 +736,7 @@ static int vpe_elfload(struct vpe *v)return -ENOEXEC ; } -if (v->shared_ptr =NULL ) +if (!v->shared_ptr)pr_warn ("VPE loader: program does not contain vpe_shared symbol.\n" " Unable to use AMVP (AP/SP) facilities.\n" ); }
@@ -777,7 +776,7 @@ static int vpe_open(struct inode *inode, struct file *filp) } v =get_vpe (aprp_cpu_index ()); -if (v =NULL ) { +if (!v) {pr_warn ("VPE loader: unable to get vpe\n" );return -ENODEV ;
@@ -822,7 +821,7 @@ static int vpe_release(struct inode *inode, struct file *filp)int ret =0 ; v =get_vpe (aprp_cpu_index ()); -if (v =NULL ) +if (!v)return -ENODEV ; hdr = (Elf_Ehdr *) v->pbuffer;
@@ -866,8 +865,7 @@ static ssize_t vpe_write(struct file *file, const char __user *buffer,return -ENODEV ; v =get_vpe (aprp_cpu_index ()); - -if (v =NULL ) +if (!v)return -ENODEV ;if ((count + v->len) > v->plen) {
@@ -895,7 +893,7 @@ void *vpe_get_shared(int index) {struct vpe *v =get_vpe (index); -if (v =NULL ) +if (!v)return NULL ;return v->shared_ptr;
@@ -906,7 +904,7 @@ int vpe_notify(int index, struct vpe_notifications *notify) {struct vpe *v =get_vpe (index); -if (v =NULL ) +if (!v)return -1 ;list_add (¬ify->list, &v->notify);
@@ -918,7 +916,7 @@ char *vpe_getcwd(int index) {struct vpe *v =get_vpe (index); -if (v =NULL ) +if (!v)return NULL ;return v->cwd;
Signature · 1 line
2.13.0
Quoted 5 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Tue, 23 May 2017 22:40:04 +0200A few update suggestions were taken into account
from static source code analysis.
Stop sending new patches until you handle the
feedback you receive on old patches.