* [PATCH] Put braces around potentially empty 'if' body in handle_pte_fault()
@ 2011-12-18 0:03 Jesper Juhl
2011-12-18 0:18 ` Eric Dumazet
0 siblings, 1 reply; 6+ messages in thread
From: Jesper Juhl @ 2011-12-18 0:03 UTC (permalink / raw)
To: linux-mm
Cc: linux-kernel, Andrew Morton, Michel Lespinasse, Hugh Dickins,
Andrea Arcangeli, KAMEZAWA Hiroyuki
[-- Attachment #1: Type: TEXT/PLAIN, Size: 1068 bytes --]
If one builds the kernel with -Wempty-body one gets this warning:
mm/memory.c:3432:46: warning: suggest braces around empty body in an !ifc statement [-Wempty-body]
due to the fact that 'flush_tlb_fix_spurious_fault' is a macro that
can sometimes be defined to nothing.
I suggest we heed gcc's advice and put a pair of braces on that if.
Signed-off-by: Jesper Juhl <jj@chaosbits.net>
---
mm/memory.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/mm/memory.c b/mm/memory.c
index 829d437..9cf1b48 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -3428,9 +3428,9 @@ int handle_pte_fault(struct mm_struct *mm,
* This still avoids useless tlb flushes for .text page faults
* with threads.
*/
- if (flags & FAULT_FLAG_WRITE)
+ if (flags & FAULT_FLAG_WRITE) {
flush_tlb_fix_spurious_fault(vma, address);
+ }
}
unlock:
pte_unmap_unlock(pte, ptl);
--
1.7.8
--
Jesper Juhl <jj@chaosbits.net> http://www.chaosbits.net/
Don't top-post http://www.catb.org/jargon/html/T/top-post.html
Plain text mails only, please.
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] Put braces around potentially empty 'if' body in handle_pte_fault()
2011-12-18 0:03 [PATCH] Put braces around potentially empty 'if' body in handle_pte_fault() Jesper Juhl
@ 2011-12-18 0:18 ` Eric Dumazet
2011-12-18 0:26 ` Jesper Juhl
2011-12-18 0:34 ` Al Viro
0 siblings, 2 replies; 6+ messages in thread
From: Eric Dumazet @ 2011-12-18 0:18 UTC (permalink / raw)
To: Jesper Juhl
Cc: linux-mm, linux-kernel, Andrew Morton, Michel Lespinasse,
Hugh Dickins, Andrea Arcangeli, KAMEZAWA Hiroyuki
Le dimanche 18 dA(C)cembre 2011 A 01:03 +0100, Jesper Juhl a A(C)crit :
> If one builds the kernel with -Wempty-body one gets this warning:
>
> mm/memory.c:3432:46: warning: suggest braces around empty body in an a??ifa?? statement [-Wempty-body]
>
> due to the fact that 'flush_tlb_fix_spurious_fault' is a macro that
> can sometimes be defined to nothing.
>
> I suggest we heed gcc's advice and put a pair of braces on that if.
>
> Signed-off-by: Jesper Juhl <jj@chaosbits.net>
> ---
> mm/memory.c | 3 ++-
> 1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/mm/memory.c b/mm/memory.c
> index 829d437..9cf1b48 100644
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -3428,9 +3428,9 @@ int handle_pte_fault(struct mm_struct *mm,
> * This still avoids useless tlb flushes for .text page faults
> * with threads.
> */
> - if (flags & FAULT_FLAG_WRITE)
> + if (flags & FAULT_FLAG_WRITE) {
> flush_tlb_fix_spurious_fault(vma, address);
> + }
> }
> unlock:
> pte_unmap_unlock(pte, ptl);
> --
> 1.7.8
>
Thats should be fixed in the reverse way :
#define flush_tlb_fix_spurious_fault(vma, address) do { } while (0)
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Put braces around potentially empty 'if' body in handle_pte_fault()
2011-12-18 0:18 ` Eric Dumazet
@ 2011-12-18 0:26 ` Jesper Juhl
2011-12-18 0:34 ` Al Viro
1 sibling, 0 replies; 6+ messages in thread
From: Jesper Juhl @ 2011-12-18 0:26 UTC (permalink / raw)
To: Eric Dumazet
Cc: linux-mm, linux-kernel, Andrew Morton, Michel Lespinasse,
Hugh Dickins, Andrea Arcangeli, KAMEZAWA Hiroyuki
[-- Attachment #1: Type: TEXT/PLAIN, Size: 1690 bytes --]
On Sun, 18 Dec 2011, Eric Dumazet wrote:
> Le dimanche 18 dA(C)cembre 2011 A 01:03 +0100, Jesper Juhl a A(C)crit :
> > If one builds the kernel with -Wempty-body one gets this warning:
> >
> > mm/memory.c:3432:46: warning: suggest braces around empty body in an a??ifa?? statement [-Wempty-body]
> >
> > due to the fact that 'flush_tlb_fix_spurious_fault' is a macro that
> > can sometimes be defined to nothing.
> >
> > I suggest we heed gcc's advice and put a pair of braces on that if.
> >
> > Signed-off-by: Jesper Juhl <jj@chaosbits.net>
> > ---
> > mm/memory.c | 3 ++-
> > 1 files changed, 2 insertions(+), 1 deletions(-)
> >
> > diff --git a/mm/memory.c b/mm/memory.c
> > index 829d437..9cf1b48 100644
> > --- a/mm/memory.c
> > +++ b/mm/memory.c
> > @@ -3428,9 +3428,9 @@ int handle_pte_fault(struct mm_struct *mm,
> > * This still avoids useless tlb flushes for .text page faults
> > * with threads.
> > */
> > - if (flags & FAULT_FLAG_WRITE)
> > + if (flags & FAULT_FLAG_WRITE) {
> > flush_tlb_fix_spurious_fault(vma, address);
> > + }
> > }
> > unlock:
> > pte_unmap_unlock(pte, ptl);
> > --
> > 1.7.8
> >
>
> Thats should be fixed in the reverse way :
>
> #define flush_tlb_fix_spurious_fault(vma, address) do { } while (0)
>
I did consider that, bot opted for the other solution since there was only
one user. But, on second thought, you are right, I should just have made
the macro safe so that future uses also won't have problems. Will send a
new patch in a minute.
--
Jesper Juhl <jj@chaosbits.net> http://www.chaosbits.net/
Don't top-post http://www.catb.org/jargon/html/T/top-post.html
Plain text mails only, please.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Put braces around potentially empty 'if' body in handle_pte_fault()
2011-12-18 0:18 ` Eric Dumazet
2011-12-18 0:26 ` Jesper Juhl
@ 2011-12-18 0:34 ` Al Viro
2011-12-18 1:18 ` Alexey Dobriyan
1 sibling, 1 reply; 6+ messages in thread
From: Al Viro @ 2011-12-18 0:34 UTC (permalink / raw)
To: Eric Dumazet
Cc: Jesper Juhl, linux-mm, linux-kernel, Andrew Morton,
Michel Lespinasse, Hugh Dickins, Andrea Arcangeli,
KAMEZAWA Hiroyuki
On Sun, Dec 18, 2011 at 01:18:55AM +0100, Eric Dumazet wrote:
> Thats should be fixed in the reverse way :
>
> #define flush_tlb_fix_spurious_fault(vma, address) do { } while (0)
There's a better way to do that -
#define f(a) do { } while(0)
does not work as a function returning void -
f(1), g();
won't work. OTOH
#define f(a) ((void)0)
works just fine.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Put braces around potentially empty 'if' body in handle_pte_fault()
2011-12-18 0:34 ` Al Viro
@ 2011-12-18 1:18 ` Alexey Dobriyan
2011-12-19 22:03 ` Andrew Morton
0 siblings, 1 reply; 6+ messages in thread
From: Alexey Dobriyan @ 2011-12-18 1:18 UTC (permalink / raw)
To: Al Viro
Cc: Eric Dumazet, Jesper Juhl, linux-mm, linux-kernel, Andrew Morton,
Michel Lespinasse, Hugh Dickins, Andrea Arcangeli,
KAMEZAWA Hiroyuki
On Sun, Dec 18, 2011 at 12:34:19AM +0000, Al Viro wrote:
> On Sun, Dec 18, 2011 at 01:18:55AM +0100, Eric Dumazet wrote:
> > Thats should be fixed in the reverse way :
> >
> > #define flush_tlb_fix_spurious_fault(vma, address) do { } while (0)
>
> There's a better way to do that -
> #define f(a) do { } while(0)
> does not work as a function returning void -
> f(1), g();
> won't work. OTOH
> #define f(a) ((void)0)
> works just fine.
Two words: static inline.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Put braces around potentially empty 'if' body in handle_pte_fault()
2011-12-18 1:18 ` Alexey Dobriyan
@ 2011-12-19 22:03 ` Andrew Morton
0 siblings, 0 replies; 6+ messages in thread
From: Andrew Morton @ 2011-12-19 22:03 UTC (permalink / raw)
To: Alexey Dobriyan
Cc: Al Viro, Eric Dumazet, Jesper Juhl, linux-mm, linux-kernel,
Michel Lespinasse, Hugh Dickins, Andrea Arcangeli,
KAMEZAWA Hiroyuki
On Sun, 18 Dec 2011 04:18:28 +0300
Alexey Dobriyan <adobriyan@gmail.com> wrote:
> On Sun, Dec 18, 2011 at 12:34:19AM +0000, Al Viro wrote:
> > On Sun, Dec 18, 2011 at 01:18:55AM +0100, Eric Dumazet wrote:
> > > Thats should be fixed in the reverse way :
> > >
> > > #define flush_tlb_fix_spurious_fault(vma, address) do { } while (0)
> >
> > There's a better way to do that -
> > #define f(a) do { } while(0)
> > does not work as a function returning void -
> > f(1), g();
> > won't work. OTOH
> > #define f(a) ((void)0)
> > works just fine.
>
> Two words: static inline.
Amen. How often must we teach ourselves this lesson?
It gets a bit messy because of:
#ifndef flush_tlb_fix_spurious_fault
#define flush_tlb_fix_spurious_fault(vma, address) flush_tlb_page(vma, address)
#endif
But that can be handled with
static inline void flush_tlb_fix_spurious_fault(...)
{
...
}
#define flush_tlb_fix_spurious_fault flush_tlb_fix_spurious_fault
and
#ifndef flush_tlb_fix_spurious_fault
static inline void flush_tlb_fix_spurious_fault(...)
{
}
#define flush_tlb_fix_spurious_fault flush_tlb_fix_spurious_fault
#endif
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-12-19 22:03 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-18 0:03 [PATCH] Put braces around potentially empty 'if' body in handle_pte_fault() Jesper Juhl
2011-12-18 0:18 ` Eric Dumazet
2011-12-18 0:26 ` Jesper Juhl
2011-12-18 0:34 ` Al Viro
2011-12-18 1:18 ` Alexey Dobriyan
2011-12-19 22:03 ` Andrew Morton
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).