2017-07-07 16:31:14

by pierre kuo

[permalink] [raw]
Subject: [PATCH] printk: Modify operators of printed_len

In 8b1742c9c207, we remove printk-recursion detection code in
vprintk_emit(), where it is the first place that printed_len calculated.
After removing above detection, it seems we can directly assign the
result of log_output to printed_len.

Signed-off-by: Pierre Kuo <[email protected]>
---
kernel/printk/printk.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index fc47863..16f3a61 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -1754,7 +1754,7 @@ asmlinkage int vprintk_emit(int facility, int level,
if (dict)
lflags |= LOG_PREFIX|LOG_NEWLINE;

- printed_len += log_output(facility, level, lflags, dict, dictlen, text, text_len);
+ printed_len = log_output(facility, level, lflags, dict, dictlen, text, text_len);

logbuf_unlock_irqrestore(flags);

--
1.7.9.5


2017-07-07 17:12:38

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH] printk: Modify operators of printed_len

On Sat, 2017-07-08 at 00:30 +0800, Pierre Kuo wrote:
> In 8b1742c9c207, we remove printk-recursion detection code in
> vprintk_emit(), where it is the first place that printed_len calculated.
> After removing above detection, it seems we can directly assign the
> result of log_output to printed_len.
[]
> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
[]
> @@ -1754,7 +1754,7 @@ asmlinkage int vprintk_emit(int facility, int level,
> if (dict)
> lflags |= LOG_PREFIX|LOG_NEWLINE;
>
> - printed_len += log_output(facility, level, lflags, dict, dictlen, text, text_len);
> + printed_len = log_output(facility, level, lflags, dict, dictlen, text, text_len);

If this is appropriate, this should also remove the
initialization of printed_len and perhaps rename it too.

2017-07-07 20:32:52

by pierre kuo

[permalink] [raw]
Subject: Re: [PATCH] printk: Modify operators of printed_len

hi Joe:
2017-07-08 1:12 GMT+08:00 Joe Perches <[email protected]>:
> On Sat, 2017-07-08 at 00:30 +0800, Pierre Kuo wrote:
>> In 8b1742c9c207, we remove printk-recursion detection code in
>> vprintk_emit(), where it is the first place that printed_len calculated.
>> After removing above detection, it seems we can directly assign the
>> result of log_output to printed_len.
> []
>> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
> []
>> @@ -1754,7 +1754,7 @@ asmlinkage int vprintk_emit(int facility, int level,
>> if (dict)
>> lflags |= LOG_PREFIX|LOG_NEWLINE;
>>
>> - printed_len += log_output(facility, level, lflags, dict, dictlen, text, text_len);
>> + printed_len = log_output(facility, level, lflags, dict, dictlen, text, text_len);
>
> If this is appropriate, this should also remove the
> initialization of printed_len and perhaps rename it too.
I cannot quite understand the reason why need to rename.
printed_len seems meet the meaning we expect for here.

thanks for your friendly comment.

2017-07-07 23:03:26

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH] printk: Modify operators of printed_len

On Sat, 2017-07-08 at 04:32 +0800, pierre kuo wrote:
> hi Joe:

Hello Pierre.

> 2017-07-08 1:12 GMT+08:00 Joe Perches <[email protected]>:
> > On Sat, 2017-07-08 at 00:30 +0800, Pierre Kuo wrote:
> > > In 8b1742c9c207, we remove printk-recursion detection code in
> > > vprintk_emit(), where it is the first place that printed_len calculated.
> > > After removing above detection, it seems we can directly assign the
> > > result of log_output to printed_len.
> >
> > []
> > > diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
> >
> > []
> > > @@ -1754,7 +1754,7 @@ asmlinkage int vprintk_emit(int facility, int level,
> > > if (dict)
> > > lflags |= LOG_PREFIX|LOG_NEWLINE;
> > >
> > > - printed_len += log_output(facility, level, lflags, dict, dictlen, text, text_len);
> > > + printed_len = log_output(facility, level, lflags, dict, dictlen, text, text_len);
> >
> > If this is appropriate, this should also remove the
> > initialization of printed_len and perhaps rename it too.
>
> I cannot quite understand the reason why need to rename.
> printed_len seems meet the meaning we expect for here.

Verbosity. To me, len would be adequate.

Anyway, the real point was the declaration of printed_len could
remove the " = 0" as it's now only set once.

cheers, Joe

2017-07-08 02:49:39

by pierre kuo

[permalink] [raw]
Subject: Re: [PATCH] printk: Modify operators of printed_len

hi Joe
>> > []
>> > > diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
>> >
>> > []
>> > > @@ -1754,7 +1754,7 @@ asmlinkage int vprintk_emit(int facility, int level,
>> > > if (dict)
>> > > lflags |= LOG_PREFIX|LOG_NEWLINE;
>> > >
>> > > - printed_len += log_output(facility, level, lflags, dict, dictlen, text, text_len);
>> > > + printed_len = log_output(facility, level, lflags, dict, dictlen, text, text_len);
>> >
>> > If this is appropriate, this should also remove the
>> > initialization of printed_len and perhaps rename it too.
>>
>> I cannot quite understand the reason why need to rename.
>> printed_len seems meet the meaning we expect for here.
>
> Verbosity. To me, len would be adequate.
>
> Anyway, the real point was the declaration of printed_len could
> remove the " = 0" as it's now only set once.
Got it and I will resend the patch again.

Appreciate your kind advice.