The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Feng Tang <feng.tang@intel.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Borislav Petkov <bp@alien8.de>, Ingo Molnar <mingo@kernel.org>,
	H Peter Anvin <hpa@linux.intel.com>,
	Peter Zijlstra <peterz@infradead.org>,
	"Stuart R . Anderson" <stuart.r.anderson@intel.com>,
	alan@linux.intel.com, x86@kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] x86/earlyprintk: Add a force option for pciserial device
Date: Tue, 2 Oct 2018 23:31:10 +0800	[thread overview]
Message-ID: <20181002153110.qyttitbdzhtatlev@shbuild888> (raw)
In-Reply-To: <20181002121046.lsqqnqfu42bazbfx@shbuild888>

On Tue, Oct 02, 2018 at 08:10:46PM +0800, Feng Tang wrote:
> Hi Thomas,
> 
> On Tue, Oct 02, 2018 at 12:44:36PM +0200, Thomas Gleixner wrote:
> > On Tue, 2 Oct 2018, Feng Tang wrote:
> > > On Tue, Oct 02, 2018 at 11:17:57AM +0200, Thomas Gleixner wrote:
> > > > On Tue, 2 Oct 2018, Feng Tang wrote:
> > > > 
> > > > > Hi Boris,
> > > > > 
> > > > > On Mon, Oct 01, 2018 at 10:30:04PM +0200, Borislav Petkov wrote:
> > > > > > On Mon, Oct 01, 2018 at 10:18:10PM +0800, Feng Tang wrote:
> > > > > > > As I rechecked, the baud rate for pciserial is optional, so there may
> > > > > > > be no ",baudrate" following the "force". So this 2 strncmp is to
> > > > > > > cover conditions for with and without baudrate.
> > > > > > 
> > > > > > And what guarantees you have a space after the "force"?
> > > > > > 
> > > > > > 	!strncmp(s, "force ", 6)
> > > > > > 			  ^
> > > > > 
> > > > > You are right, it can't be guranteed. Can we still use strncmp(s, "force", 5)
> > > > > and rely on developer to set it right? any suggestions? thanks,
> > > > 
> > > > I don't know why you want strncmp() in the first place. "force" is null
> > > > terminated already.
> > > 
> > > Current code uses: 
> > > 	earlyprintk=pciserial,bus:device.function[,baudrate]
> > > with the patch, it will be:
> > > 	earlyprintk=pciserial,bus:device.function[,force][,baudrate]
> > > 
> > > So the force could be followed by ",baudrate".
> > 
> > Sure, but that has nothing to do with strncmp(). The earlyprintk argument
> > string is tokenized by commata. It really does not matter where the 'force'
> > string is, but it matters that you check whether it is 'force' and not
> > 'force$RANDOMCHARACTERS'. That's why strncmp() is the wrong thing to do,
> > because it only compares the first 5 characters and ignores anything
> > beyond, unless you make sure that the command line part is exactly 5
> > characters long.
> 
> I don't know if I get it right due to my poor English, so for both cases
> of "xxx,force,baudrate" and "xxx,force", it could be covered by
> 
> 	if ((!strcmp(s, "force") || !strncmp(s, "force," 6))
> 		force = 1;

One idea is to change the new format to
	earlyprintk=pciserial[,force],bus:device.function[,baudrate]
Then we can use what Boris has suggested:
	!strncmp(s, "force,", 6)

Any thoughts?

Thanks,
Feng

  reply	other threads:[~2018-10-02 15:28 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-28  9:40 [PATCH v2] x86/earlyprintk: Add a force option for pciserial device Feng Tang
2018-09-29 16:34 ` Borislav Petkov
2018-09-30 13:16   ` Feng Tang
2018-10-01 12:39     ` Borislav Petkov
2018-10-01 14:18       ` Feng Tang
2018-10-01 20:30         ` Borislav Petkov
2018-10-02  9:16           ` Feng Tang
2018-10-02  9:17             ` Thomas Gleixner
2018-10-02  9:48               ` Feng Tang
2018-10-02 10:44                 ` Thomas Gleixner
2018-10-02 12:10                   ` Feng Tang
2018-10-02 15:31                     ` Feng Tang [this message]
2018-10-02 15:41                       ` Thomas Gleixner
2018-10-02 15:49                         ` Feng Tang

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=20181002153110.qyttitbdzhtatlev@shbuild888 \
    --to=feng.tang@intel.com \
    --cc=alan@linux.intel.com \
    --cc=bp@alien8.de \
    --cc=hpa@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=stuart.r.anderson@intel.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.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