public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Heinrich Schuchardt <xypron.glpk@gmx.de>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: gxt@mprc.pku.edu.cn, paul.gortmaker@windriver.com,
	vapier@gentoo.org, totglx@linutronix.de,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/1] __init setup_early_printk: missing initialization
Date: Mon, 27 Jan 2014 23:58:54 +0100	[thread overview]
Message-ID: <52E6E4AE.4040906@gmx.de> (raw)
In-Reply-To: <20140127134959.72c65d0091554e36d1755ab0@linux-foundation.org>

On 27.01.2014 22:49, Andrew Morton wrote:
> On Mon, 27 Jan 2014 19:10:24 +0100 xypron.glpk@gmx.de wrote:
>
>> From: Heinrich Schuchardt <xypron.glpk@gmx.de>
>>
>> If is based on uninitialized value keep_early.
>> This leads to unpredictable result.
>>
>> ...
>>
>> --- a/arch/unicore32/kernel/early_printk.c
>> +++ b/arch/unicore32/kernel/early_printk.c
>> @@ -35,7 +35,7 @@ static struct console early_ocd_console = {
>>
>>   static int __init setup_early_printk(char *buf)
>>   {
>> -	int keep_early;
>> +	int keep_early = 0;
>>
>>   	if (!buf || early_console)
>>   		return 0;
>
> yup.
>
> But that code is quite overcooked.  How about this?
>
> --- a/arch/unicore32/kernel/early_printk.c~arch-unicore32-kernel-early_printkc-setup_early_printk-missing-initialization-fix
> +++ a/arch/unicore32/kernel/early_printk.c
> @@ -35,17 +35,11 @@ static struct console early_ocd_console
>
>   static int __init setup_early_printk(char *buf)
>   {
> -	int keep_early = 0;
> -
>   	if (!buf || early_console)
>   		return 0;
>
> -	if (strstr(buf, "keep"))
> -		keep_early = 1;
> -
>   	early_console = &early_ocd_console;
> -
> -	if (keep_early)
> +	if (strstr(buf, "keep"))
>   		early_console->flags &= ~CON_BOOT;
>   	else
>   		early_console->flags |= CON_BOOT;
> _
>
>

Your code is easier to read, and has same functionality.

  reply	other threads:[~2014-01-27 22:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-27 18:10 [PATCH 1/1] __init setup_early_printk: missing initialization xypron.glpk
2014-01-27 21:49 ` Andrew Morton
2014-01-27 22:58   ` Heinrich Schuchardt [this message]
2014-01-28  8:05   ` 回复: " 管雪涛

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52E6E4AE.4040906@gmx.de \
    --to=xypron.glpk@gmx.de \
    --cc=akpm@linux-foundation.org \
    --cc=gxt@mprc.pku.edu.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paul.gortmaker@windriver.com \
    --cc=totglx@linutronix.de \
    --cc=vapier@gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox