From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Vitaly Kuznetsov <vkuznets@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Ulf Hansson <ulf.hansson@linaro.org>,
James Bottomley <JBottomley@Odin.com>,
Kees Cook <keescook@chromium.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/3] lib/string_helpers.c: don't lose precision in string_get_size()
Date: Tue, 27 Oct 2015 18:24:16 +0200 [thread overview]
Message-ID: <1445963056.6332.41.camel@linux.intel.com> (raw)
In-Reply-To: <87pp00walr.fsf@vitty.brq.redhat.com>
On Tue, 2015-10-27 at 17:16 +0100, Vitaly Kuznetsov wrote:
> Andy Shevchenko <andriy.shevchenko@linux.intel.com> writes:
[]
> > + if (!blk_size) {
> > > + WARN_ON(1);
> >
> > Hmm... Isn't it too strong? WARN_ONCE() might reduce a noise. Or
> > even
> > pr_warn_once/ratelimited().
>
> Nobody is supposed to call string_get_size() with blk_size = 0, if
> someone does that - it is a bug and that's what WARN_ON is supposed
> to
> report. I'm OK with changing it to WARN_ONCE() but I don't see a big
> difference - nobody's calling string_get_size() in a loop, one/two
> calls
> per one storage device is expected.
I'm fine with WARN_ONCE() if there is no objection.
>
> >
> > > + size = 0;
> > > + goto out;
> > > }
> >
> > What about doing it before if (!size) ?
> >
> > Like
> >
> > if (!blk_size) {
> > pr_warn_once(); /* or WARN_ONCE() ? */
> > /* Override size to follow error path */
> > size = 0;
> > }
> >
> > if (!size)
>
> To be honest I don't see a big difference but I'm fine with the
> change :-)
Maybe Rasmus can judge me.
> > > - remainder %= divisor[units];
> > > + remainder -= (remainder / divisor[units]) *
> > > divisor[units];
> >
> > I'm sorry I didn't get what the purpose of change here.
> >
> > (Yes, I was thinking about u64 on 32-bit architecture, but % and /
> > are
> > working in the similar way aren't they?)
>
> Thanks for noticing, there is no functional change here, it just made
> the code easier to understand (for me only?). I'm OK with reverting
> it
> to '%='.
For me is the opposite. remainder = remainder % divisor[units] will
work as well, but why change the code at all.
--
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy
next prev parent reply other threads:[~2015-10-27 16:24 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-27 14:06 [PATCH v2 0/3] lib/string_helpers: fix precision issues and introduce tests Vitaly Kuznetsov
2015-10-27 14:06 ` [PATCH v2 1/3] lib/string_helpers: change blk_size to u32 for string_get_size() interface Vitaly Kuznetsov
2015-10-27 14:06 ` [PATCH v2 2/3] lib/string_helpers.c: don't lose precision in string_get_size() Vitaly Kuznetsov
2015-10-27 15:25 ` Andy Shevchenko
2015-10-27 16:16 ` Vitaly Kuznetsov
2015-10-27 16:24 ` Andy Shevchenko [this message]
2015-10-27 21:02 ` Rasmus Villemoes
2015-10-29 13:51 ` Vitaly Kuznetsov
2015-10-27 14:06 ` [PATCH v2 3/3] lib/test-string_helpers.c: add string_get_size() tests Vitaly Kuznetsov
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=1445963056.6332.41.camel@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=JBottomley@Odin.com \
--cc=akpm@linux-foundation.org \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=ulf.hansson@linaro.org \
--cc=vkuznets@redhat.com \
/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;
as well as URLs for NNTP newsgroup(s).