AVR32: Fine-tuning for two function implementations
cover AVR32: Fine-tuning for two function implementations
From: Markus Elfring <[email protected]>
Date: Wed, 18 Jan 2017 14:40:04 +0100
A few update suggestions were taken into account
from static source code analysis.
Markus Elfring (3):
Return directly after a failed access_ok() in setup_rt_frame() Delete an unnecessary variable initialisation in setup_rt_frame() Return an error code only as a constant in sys_cacheflush()
arch/avr32/kernel/signal.c | 5 ++--- arch/avr32/mm/cache.c | 21 +++++---------------- 2 files changed, 7 insertions(+), 19 deletions(-)
Signature · 1 line
2.11.0
PATCH 1/3 AVR32: Return directly after a failed access_ok() in setup_rt_frame()
From: Markus Elfring <[email protected]>
Date: Wed, 18 Jan 2017 13:50:38 +0100
Return directly after a call of the function "access_ok" failed at the beginning.
--- arch/avr32/kernel/signal.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/avr32/kernel/signal.c +1 -2
@@ -141,9 +141,8 @@ setup_rt_frame(struct ksignal *ksig, sigset_t *set, struct pt_regs *regs)int err =0 ; frame =get_sigframe (ksig, regs,sizeof (*frame)); - err = -EFAULT ;if (!access_ok (VERIFY_WRITE , frame,sizeof (*frame))) - goto out; +return -EFAULT ;/* * Set up the return code:
Signature · 1 line
2.11.0
PATCH 2/3 AVR32: Delete an unnecessary variable initialisation in setup_rt_frame()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 18 Jan 2017 14:03:10 +0100
The local variable "err" will be set to an appropriate value a bit later. Thus omit the explicit initialisation at the beginning.
--- arch/avr32/kernel/signal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/avr32/kernel/signal.c +1 -1
@@ -138,7 +138,7 @@ static int setup_rt_frame(struct ksignal *ksig, sigset_t *set, struct pt_regs *regs) { struct rt_sigframe __user *frame; -int err =0 ; +int err; frame =get_sigframe (ksig, regs,sizeof (*frame));if (!access_ok (VERIFY_WRITE , frame,sizeof (*frame)))
Signature · 1 line
2.11.0
PATCH 3/3 AVR32: Return an error code only as a constant in sys_cacheflush()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 18 Jan 2017 14:30:11 +0100
* Return an error code without storing it in an intermediate variable.
* Delete the local variable "ret" which became unnecessary with this refactoring.
--- arch/avr32/mm/cache.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-)
arch/avr32/mm/cache.c +5 -16
@@ -126,30 +126,19 @@ void flush_icache_page(struct vm_area_struct *vma, struct page *page) asmlinkage int sys_cacheflush(int operation, void __user *addr, size_t len) { -int ret; - -if (len >CACHEFLUSH_MAX_LEN ) { - ret = -EPERM ; -if (!capable (CAP_SYS_ADMIN )) - goto out; - } - - ret = -EFAULT ; +if (len >CACHEFLUSH_MAX_LEN && !capable (CAP_SYS_ADMIN )) +return -EPERM ;if (!access_ok (VERIFY_WRITE , addr, len)) - goto out; +return -EFAULT ;switch (operation) {case CACHE_IFLUSH :flush_icache_range ((unsigned long )addr, (unsigned long )addr + len); - ret =0 ; -break ; +return 0 ;default : - ret = -EINVAL ; +return -EINVAL ; } - -out: -return ret; } void copy_to_user_page(struct vm_area_struct *vma, struct page *page,
Signature · 1 line
2.11.0
Quoted 6 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 18 Jan 2017 14:40:04 +0100A few update suggestions were taken into account
from static source code analysis.
Quoted 8 lines
Markus Elfring (3):
Return directly after a failedaccess_ok()insetup_rt_frame()Delete an unnecessary variable initialisation insetup_rt_frame()Return an error code only as a constant insys_cacheflush()arch/avr32/kernel/signal.c | 5 ++--- arch/avr32/mm/cache.c | 21 +++++---------------- 2 files changed, 7 insertions(+), 19 deletions(-)
Ack, I guess it slightly simplifies reading. Will add to linux-avr32 git tree.
Signature · 2 lines
mvh Hans-Christian Noren Egtvedt