diff mbox series

printk: simplify no_printk()

Message ID 1505660504-11059-1-git-send-email-yamada.masahiro@socionext.com
State Accepted
Commit 93b138dd9d6e01cd360f347512b6c5bf6f0c4ce2
Headers show
Series printk: simplify no_printk() | expand

Commit Message

Masahiro Yamada Sept. 17, 2017, 3:01 p.m. UTC
Commit 069f0cd00df0 ("printk: Make the printk*once() variants return
a value") surrounded the macro implementation with ({ ... }).

Now, the inner do { ... } while (0); is redundant.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

---

 include/linux/printk.h | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

-- 
2.7.4

Comments

Joe Perches Sept. 17, 2017, 6:31 p.m. UTC | #1
On Mon, 2017-09-18 at 00:01 +0900, Masahiro Yamada wrote:
> Commit 069f0cd00df0 ("printk: Make the printk*once() variants return

> a value") surrounded the macro implementation with ({ ... }).

> 

> Now, the inner do { ... } while (0); is redundant.


thanks.

> diff --git a/include/linux/printk.h b/include/linux/printk.h

[]
> @@ -131,10 +131,8 @@ struct va_format {

>   */

>  #define no_printk(fmt, ...)				\

>  ({							\

> -	do {						\

> -		if (0)					\

> -			printk(fmt, ##__VA_ARGS__);	\

> -	} while (0);					\

> +	if (0)						\

> +		printk(fmt, ##__VA_ARGS__);		\

>  	0;						\

>  })
Sergey Senozhatsky Sept. 26, 2017, 6:43 a.m. UTC | #2
On (09/18/17 00:01), Masahiro Yamada wrote:
> Commit 069f0cd00df0 ("printk: Make the printk*once() variants return

> a value") surrounded the macro implementation with ({ ... }).

> 

> Now, the inner do { ... } while (0); is redundant.

> 

> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


looks ok to me. can't say that I see a huge difference, tho,
but, FWIW:

Reviewed-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>


	-ss
Petr Mladek Oct. 2, 2017, 2:56 p.m. UTC | #3
On Mon 2017-09-18 00:01:44, Masahiro Yamada wrote:
> Commit 069f0cd00df0 ("printk: Make the printk*once() variants return

> a value") surrounded the macro implementation with ({ ... }).

> 

> Now, the inner do { ... } while (0); is redundant.

> 

> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


Looks fine to me. The return value is slightly more visible now ;-)

Reviewed-by: Petr Mladek <pmladek@suse.com>


JFYI, I have pushed it into for-4.15 branch.

Best Regards,
Petr
Masahiro Yamada Oct. 19, 2017, 10:48 a.m. UTC | #4
Hi Petr,

2017-10-02 23:56 GMT+09:00 Petr Mladek <pmladek@suse.com>:
> On Mon 2017-09-18 00:01:44, Masahiro Yamada wrote:

>> Commit 069f0cd00df0 ("printk: Make the printk*once() variants return

>> a value") surrounded the macro implementation with ({ ... }).

>>

>> Now, the inner do { ... } while (0); is redundant.

>>

>> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

>

> Looks fine to me. The return value is slightly more visible now ;-)

>

> Reviewed-by: Petr Mladek <pmladek@suse.com>

>

> JFYI, I have pushed it into for-4.15 branch.

>

> Best Regards,

> Petr



A minor problem.

I think "Reviewed-by: " is missing before Sergey.

I am not sure if this is too late, or not...




commit 38a8c55325f5d4f261fde8b1bebfa2e9daf7c3e1
Author: Masahiro Yamada <yamada.masahiro@socionext.com>
Date:   Mon Sep 18 00:01:44 2017 +0900

    printk: simplify no_printk()

    Commit 069f0cd00df0 ("printk: Make the printk*once() variants return
    a value") surrounded the macro implementation with ({ ... }).

    Now, the inner do { ... } while (0); is redundant.

    Link: http://lkml.kernel.org/r/1505660504-11059-1-git-send-email-yamada.masahiro@socionext.com
    Cc: Andrew Morton <akpm@linux-foundation.org>
    Cc: Ingo Molnar <mingo@kernel.org>
    Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
    Cc: Steven Rostedt <rostedt@goodmis.org>
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

    Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
    Signed-off-by: Petr Mladek <pmladek@suse.com>




-- 
Best Regards
Masahiro Yamada
Petr Mladek Oct. 19, 2017, 1:38 p.m. UTC | #5
On Thu 2017-10-19 19:48:15, Masahiro Yamada wrote:
> Hi Petr,

> 

> 2017-10-02 23:56 GMT+09:00 Petr Mladek <pmladek@suse.com>:

> > On Mon 2017-09-18 00:01:44, Masahiro Yamada wrote:

> >> Commit 069f0cd00df0 ("printk: Make the printk*once() variants return

> >> a value") surrounded the macro implementation with ({ ... }).

> >>

> >> Now, the inner do { ... } while (0); is redundant.

> >>

> >> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

> >

> > Looks fine to me. The return value is slightly more visible now ;-)

> >

> > Reviewed-by: Petr Mladek <pmladek@suse.com>

> >

> > JFYI, I have pushed it into for-4.15 branch.

> >

> > Best Regards,

> > Petr

> 

> 

> A minor problem.

> 

> I think "Reviewed-by: " is missing before Sergey.


Great catch! Thanks for double checking!

> I am not sure if this is too late, or not...


Just pushed a fix.

Best Regards,
Petr
diff mbox series

Patch

diff --git a/include/linux/printk.h b/include/linux/printk.h
index e10f27468322..7911f7364346 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -131,10 +131,8 @@  struct va_format {
  */
 #define no_printk(fmt, ...)				\
 ({							\
-	do {						\
-		if (0)					\
-			printk(fmt, ##__VA_ARGS__);	\
-	} while (0);					\
+	if (0)						\
+		printk(fmt, ##__VA_ARGS__);		\
 	0;						\
 })