linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] m68k: Fine-tuning for sys_cacheflush()
@ 2017-01-18 16:45 SF Markus Elfring
  2017-01-18 16:47 ` [PATCH 1/3] m68k: Return directly after a failed capable() in sys_cacheflush() SF Markus Elfring
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: SF Markus Elfring @ 2017-01-18 16:45 UTC (permalink / raw)
  To: linux-m68k, Geert Uytterhoeven; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 18 Jan 2017 17:42:34 +0100

A few update suggestions were taken into account
from static source code analysis.

Markus Elfring (3):
  Return directly after a failed capable()
  Delete an unnecessary variable assignment
  Add some spaces for better code readability

 arch/m68k/kernel/sys_m68k.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

-- 
2.11.0

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/3] m68k: Return directly after a failed capable() in sys_cacheflush()
  2017-01-18 16:45 [PATCH 0/3] m68k: Fine-tuning for sys_cacheflush() SF Markus Elfring
@ 2017-01-18 16:47 ` SF Markus Elfring
  2017-02-09 11:06   ` Geert Uytterhoeven
  2017-01-18 16:49 ` [PATCH 2/3] m68k: Delete an unnecessary variable assignment " SF Markus Elfring
  2017-01-18 16:50 ` [PATCH 3/3] m68k: Add some spaces for better code readability " SF Markus Elfring
  2 siblings, 1 reply; 8+ messages in thread
From: SF Markus Elfring @ 2017-01-18 16:47 UTC (permalink / raw)
  To: linux-m68k, Geert Uytterhoeven; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 18 Jan 2017 16:30:36 +0100

Return directly after a call of the function "capable" failed
at the beginning.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/m68k/kernel/sys_m68k.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/m68k/kernel/sys_m68k.c b/arch/m68k/kernel/sys_m68k.c
index 9aa01adb407f..62bfeb3716a7 100644
--- a/arch/m68k/kernel/sys_m68k.c
+++ b/arch/m68k/kernel/sys_m68k.c
@@ -384,9 +384,8 @@ sys_cacheflush (unsigned long addr, int scope, int cache, unsigned long len)
 
 	if (scope == FLUSH_SCOPE_ALL) {
 		/* Only the superuser may explicitly flush the whole cache. */
-		ret = -EPERM;
 		if (!capable(CAP_SYS_ADMIN))
-			goto out;
+			return -EPERM;
 	} else {
 		struct vm_area_struct *vma;
 
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/3] m68k: Delete an unnecessary variable assignment in sys_cacheflush()
  2017-01-18 16:45 [PATCH 0/3] m68k: Fine-tuning for sys_cacheflush() SF Markus Elfring
  2017-01-18 16:47 ` [PATCH 1/3] m68k: Return directly after a failed capable() in sys_cacheflush() SF Markus Elfring
@ 2017-01-18 16:49 ` SF Markus Elfring
  2017-02-09 13:23   ` Geert Uytterhoeven
  2017-01-18 16:50 ` [PATCH 3/3] m68k: Add some spaces for better code readability " SF Markus Elfring
  2 siblings, 1 reply; 8+ messages in thread
From: SF Markus Elfring @ 2017-01-18 16:49 UTC (permalink / raw)
  To: linux-m68k, Geert Uytterhoeven; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 18 Jan 2017 17:07:52 +0100

Delete an assignment for the local variable "ret" in an if branch
because it was initialised by the same value.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/m68k/kernel/sys_m68k.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/m68k/kernel/sys_m68k.c b/arch/m68k/kernel/sys_m68k.c
index 62bfeb3716a7..9870d00d2215 100644
--- a/arch/m68k/kernel/sys_m68k.c
+++ b/arch/m68k/kernel/sys_m68k.c
@@ -397,7 +397,6 @@ sys_cacheflush (unsigned long addr, int scope, int cache, unsigned long len)
 		 * Verify that the specified address region actually belongs
 		 * to this process.
 		 */
-		ret = -EINVAL;
 		down_read(&current->mm->mmap_sem);
 		vma = find_vma(current->mm, addr);
 		if (!vma || addr < vma->vm_start || addr + len > vma->vm_end)
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/3] m68k: Add some spaces for better code readability in sys_cacheflush()
  2017-01-18 16:45 [PATCH 0/3] m68k: Fine-tuning for sys_cacheflush() SF Markus Elfring
  2017-01-18 16:47 ` [PATCH 1/3] m68k: Return directly after a failed capable() in sys_cacheflush() SF Markus Elfring
  2017-01-18 16:49 ` [PATCH 2/3] m68k: Delete an unnecessary variable assignment " SF Markus Elfring
@ 2017-01-18 16:50 ` SF Markus Elfring
  2017-02-09 11:12   ` Geert Uytterhoeven
  2 siblings, 1 reply; 8+ messages in thread
From: SF Markus Elfring @ 2017-01-18 16:50 UTC (permalink / raw)
  To: linux-m68k, Geert Uytterhoeven; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 18 Jan 2017 17:34:29 +0100

* Use space characters at some source code places according to
  the Linux coding style convention.

* Adjust indentation a bit.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/m68k/kernel/sys_m68k.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/arch/m68k/kernel/sys_m68k.c b/arch/m68k/kernel/sys_m68k.c
index 9870d00d2215..5b351f7a6c11 100644
--- a/arch/m68k/kernel/sys_m68k.c
+++ b/arch/m68k/kernel/sys_m68k.c
@@ -436,11 +436,10 @@ sys_cacheflush (unsigned long addr, int scope, int cache, unsigned long len)
 	     * 040 or 060: don't blindly trust 'scope', someone could
 	     * try to flush a few megs of memory.
 	     */
-
-	    if (len>=3*PAGE_SIZE && scope<FLUSH_SCOPE_PAGE)
-	        scope=FLUSH_SCOPE_PAGE;
-	    if (len>=10*PAGE_SIZE && scope<FLUSH_SCOPE_ALL)
-	        scope=FLUSH_SCOPE_ALL;
+		if (len >= 3 * PAGE_SIZE && scope < FLUSH_SCOPE_PAGE)
+			scope = FLUSH_SCOPE_PAGE;
+		if (len >= 10 * PAGE_SIZE && scope < FLUSH_SCOPE_ALL)
+			scope = FLUSH_SCOPE_ALL;
 	    if (CPU_IS_040) {
 		ret = cache_flush_040 (addr, scope, cache, len);
 	    } else if (CPU_IS_060) {
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/3] m68k: Return directly after a failed capable() in sys_cacheflush()
  2017-01-18 16:47 ` [PATCH 1/3] m68k: Return directly after a failed capable() in sys_cacheflush() SF Markus Elfring
@ 2017-02-09 11:06   ` Geert Uytterhoeven
  0 siblings, 0 replies; 8+ messages in thread
From: Geert Uytterhoeven @ 2017-02-09 11:06 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: linux-m68k, LKML, kernel-janitors

Hi Markus,

On Wed, Jan 18, 2017 at 5:47 PM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 18 Jan 2017 16:30:36 +0100
>
> Return directly after a call of the function "capable" failed
> at the beginning.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  arch/m68k/kernel/sys_m68k.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/arch/m68k/kernel/sys_m68k.c b/arch/m68k/kernel/sys_m68k.c
> index 9aa01adb407f..62bfeb3716a7 100644
> --- a/arch/m68k/kernel/sys_m68k.c
> +++ b/arch/m68k/kernel/sys_m68k.c
> @@ -384,9 +384,8 @@ sys_cacheflush (unsigned long addr, int scope, int cache, unsigned long len)
>
>         if (scope == FLUSH_SCOPE_ALL) {
>                 /* Only the superuser may explicitly flush the whole cache. */
> -               ret = -EPERM;
>                 if (!capable(CAP_SYS_ADMIN))
> -                       goto out;
> +                       return -EPERM;

Given there is another "goto out" before this, I won't take this patch as-is.

>         } else {
>                 struct vm_area_struct *vma;

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 3/3] m68k: Add some spaces for better code readability in sys_cacheflush()
  2017-01-18 16:50 ` [PATCH 3/3] m68k: Add some spaces for better code readability " SF Markus Elfring
@ 2017-02-09 11:12   ` Geert Uytterhoeven
  2017-02-09 13:05     ` SF Markus Elfring
  0 siblings, 1 reply; 8+ messages in thread
From: Geert Uytterhoeven @ 2017-02-09 11:12 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: linux-m68k, LKML, kernel-janitors

Hi Markus,

On Wed, Jan 18, 2017 at 5:50 PM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 18 Jan 2017 17:34:29 +0100
>
> * Use space characters at some source code places according to
>   the Linux coding style convention.
>
> * Adjust indentation a bit.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  arch/m68k/kernel/sys_m68k.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/arch/m68k/kernel/sys_m68k.c b/arch/m68k/kernel/sys_m68k.c
> index 9870d00d2215..5b351f7a6c11 100644
> --- a/arch/m68k/kernel/sys_m68k.c
> +++ b/arch/m68k/kernel/sys_m68k.c
> @@ -436,11 +436,10 @@ sys_cacheflush (unsigned long addr, int scope, int cache, unsigned long len)
>              * 040 or 060: don't blindly trust 'scope', someone could
>              * try to flush a few megs of memory.
>              */
> -
> -           if (len>=3*PAGE_SIZE && scope<FLUSH_SCOPE_PAGE)
> -               scope=FLUSH_SCOPE_PAGE;
> -           if (len>=10*PAGE_SIZE && scope<FLUSH_SCOPE_ALL)
> -               scope=FLUSH_SCOPE_ALL;
> +               if (len >= 3 * PAGE_SIZE && scope < FLUSH_SCOPE_PAGE)
> +                       scope = FLUSH_SCOPE_PAGE;
> +               if (len >= 10 * PAGE_SIZE && scope < FLUSH_SCOPE_ALL)
> +                       scope = FLUSH_SCOPE_ALL;
>             if (CPU_IS_040) {
>                 ret = cache_flush_040 (addr, scope, cache, len);
>             } else if (CPU_IS_060) {

What prevented you from correcting the indentation of the comments before,
and the statements after?
Now the lines in the else branch are no longer aligned at all!

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: m68k: Add some spaces for better code readability in sys_cacheflush()
  2017-02-09 11:12   ` Geert Uytterhoeven
@ 2017-02-09 13:05     ` SF Markus Elfring
  0 siblings, 0 replies; 8+ messages in thread
From: SF Markus Elfring @ 2017-02-09 13:05 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: linux-m68k, LKML, kernel-janitors

> What prevented you from correcting the indentation of the comments before,
> and the statements after?

I left this implementation detail over for further improvements by other
software developers.


> Now the lines in the else branch are no longer aligned at all!

Would you like to pick any related update candidates up?

Regards,
Markus

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/3] m68k: Delete an unnecessary variable assignment in sys_cacheflush()
  2017-01-18 16:49 ` [PATCH 2/3] m68k: Delete an unnecessary variable assignment " SF Markus Elfring
@ 2017-02-09 13:23   ` Geert Uytterhoeven
  0 siblings, 0 replies; 8+ messages in thread
From: Geert Uytterhoeven @ 2017-02-09 13:23 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: linux-m68k, LKML, kernel-janitors

On Wed, Jan 18, 2017 at 5:49 PM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 18 Jan 2017 17:07:52 +0100
>
> Delete an assignment for the local variable "ret" in an if branch
> because it was initialised by the same value.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Thanks, applied and queued for v4.11.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-02-09 13:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-18 16:45 [PATCH 0/3] m68k: Fine-tuning for sys_cacheflush() SF Markus Elfring
2017-01-18 16:47 ` [PATCH 1/3] m68k: Return directly after a failed capable() in sys_cacheflush() SF Markus Elfring
2017-02-09 11:06   ` Geert Uytterhoeven
2017-01-18 16:49 ` [PATCH 2/3] m68k: Delete an unnecessary variable assignment " SF Markus Elfring
2017-02-09 13:23   ` Geert Uytterhoeven
2017-01-18 16:50 ` [PATCH 3/3] m68k: Add some spaces for better code readability " SF Markus Elfring
2017-02-09 11:12   ` Geert Uytterhoeven
2017-02-09 13:05     ` SF Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).