All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] kstrtox: delete end-of-string test
@ 2017-05-14 19:37 Alexey Dobriyan
  2017-05-27 19:39 ` Andy Shevchenko
  0 siblings, 1 reply; 2+ messages in thread
From: Alexey Dobriyan @ 2017-05-14 19:37 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel

Standard "while (*s)" test is unnecessary because NUL won't pass
valid-digit test anyway. Save one branch per parsed character.

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---

 lib/kstrtox.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/lib/kstrtox.c
+++ b/lib/kstrtox.c
@@ -51,7 +51,7 @@ unsigned int _parse_integer(const char *s, unsigned int base, unsigned long long
 
 	res = 0;
 	rv = 0;
-	while (*s) {
+	while (1) {
 		unsigned int val;
 
 		if ('0' <= *s && *s <= '9')

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/2] kstrtox: delete end-of-string test
  2017-05-14 19:37 [PATCH 1/2] kstrtox: delete end-of-string test Alexey Dobriyan
@ 2017-05-27 19:39 ` Andy Shevchenko
  0 siblings, 0 replies; 2+ messages in thread
From: Andy Shevchenko @ 2017-05-27 19:39 UTC (permalink / raw)
  To: Alexey Dobriyan; +Cc: Andrew Morton, linux-kernel

On Sun, May 14, 2017 at 10:37 PM, Alexey Dobriyan <adobriyan@gmail.com> wrote:
> Standard "while (*s)" test is unnecessary because NUL won't pass
> valid-digit test anyway. Save one branch per parsed character.

> -       while (*s) {
> +       while (1) {

In such cases I prefer

do {} while ();

Since it makes easier to reader to catch that the loop is going at
least once (and less error prone (1) vs. (l) depending on font in
use).

...however, I see that patch is already applied.

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-05-27 19:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-14 19:37 [PATCH 1/2] kstrtox: delete end-of-string test Alexey Dobriyan
2017-05-27 19:39 ` Andy Shevchenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.