public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Petr Mladek <pmladek@suse.com>
To: Richard Fitzgerald <rf@opensource.cirrus.com>
Cc: rostedt@goodmis.org, sergey.senozhatsky@gmail.com,
	shuah@kernel.org, patches@opensource.cirrus.com,
	linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: Re: [PATCH v2 2/4] lib: test_scanf: Add tests for sscanf number conversion
Date: Wed, 16 Dec 2020 16:00:10 +0100	[thread overview]
Message-ID: <X9og+nKP18bUsi6x@alley> (raw)
In-Reply-To: <f3e97a68-71fe-c077-5add-a6c0fb397032@opensource.cirrus.com>

On Tue 2020-12-15 14:26:53, Richard Fitzgerald wrote:
> 
> 
> On 09/12/2020 14:15, Petr Mladek wrote:
> > On Mon 2020-11-30 14:57:58, Richard Fitzgerald wrote:
> > > Adds test_sscanf to test various number conversion cases, as
> > > number conversion was previously broken.
> > > 
> > > This also tests the simple_strtoxxx() functions exported from
> > > vsprintf.c.
> > 
> > It is impressive.
> > 
> > Honestly, I do not feel to be expert on testing and mathematics.
> > I am not sure how comprehensive the test is. Also I am not
> > sure what experts would say about the tricks with random
> > numbers.
> > 
> > Anyway, this is much more than what I have expected. And it checks
> > great number of variants and corner cases.
> > 
> > I suggest only one small change, see below.
> > 
> > > --- /dev/null
> > > +++ b/lib/test_scanf.c
> > > +#define test_one_number(T, gen_fmt, scan_fmt, val, fn)			\
> > > +do {									\
> > > +	const T expect_val = (T)(val);					\
> > > +	T result = ~expect_val; /* should be overwritten */		\
> > 
> > If I get it correctly, this is supposed to initialize the temporary
> > variable with a value that is different from the expected value.
> > It will cause test failure when it is not updated by vsscanf().
> > 
> > It does not work for zero value. A better solution might be to add
> 
> That's a ~, not a -
> ~0 = 0xFFFFFFFF
> ~-1 = 0

I see. This works well.

I am sorry for the noise. Sigh, I think that I need stronger glasses
or use a monitor. I am not able to distinguish the two characeters
without staring closely on the laptop screen. I wish I was able to
work from the office again.

Best Regards,
Petr

  reply	other threads:[~2020-12-16 15:01 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-30 14:57 [PATCH v2 1/4] lib: vsprintf: Fix handling of number field widths in vsscanf Richard Fitzgerald
2020-11-30 14:57 ` [PATCH v2 2/4] lib: test_scanf: Add tests for sscanf number conversion Richard Fitzgerald
2020-12-09 14:15   ` Petr Mladek
2020-12-15 14:26     ` Richard Fitzgerald
2020-12-16 15:00       ` Petr Mladek [this message]
2020-11-30 14:57 ` [PATCH v2 3/4] selftests: lib: Add wrapper script for test_scanf Richard Fitzgerald
2020-12-09 14:20   ` Petr Mladek
2020-11-30 14:58 ` [PATCH v2 4/4] MAINTAINERS: Add lib/test_scanf.c to VSPRINTF Richard Fitzgerald
2020-12-09 14:22   ` Petr Mladek
2020-12-15 18:45     ` Shuah Khan
2020-12-08 16:59 ` [PATCH v2 1/4] lib: vsprintf: Fix handling of number field widths in vsscanf pmladek

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=X9og+nKP18bUsi6x@alley \
    --to=pmladek@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=patches@opensource.cirrus.com \
    --cc=rf@opensource.cirrus.com \
    --cc=rostedt@goodmis.org \
    --cc=sergey.senozhatsky@gmail.com \
    --cc=shuah@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