* [PATCH v1] lib/bitmap: Convert infinite while loop to for one
@ 2020-06-09 14:05 Andy Shevchenko
2020-06-09 14:23 ` Alexander Gordeev
0 siblings, 1 reply; 2+ messages in thread
From: Andy Shevchenko @ 2020-06-09 14:05 UTC (permalink / raw)
To: Andrew Morton, linux-kernel, yury.norov, agordeev; +Cc: Andy Shevchenko
Convert infinite while loop to for one in order to be more explicit
in one place what we are doing with chunks.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
Andrew, this can be folded to the fix
lib/bitmap.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/lib/bitmap.c b/lib/bitmap.c
index 10f8fa0497e3..03ef42fbe658 100644
--- a/lib/bitmap.c
+++ b/lib/bitmap.c
@@ -740,10 +740,10 @@ int bitmap_parse(const char *start, unsigned int buflen,
const char *end = strnchrnul(start, buflen, '\n') - 1;
int chunks = BITS_TO_U32(nmaskbits);
u32 *bitmap = (u32 *)maskp;
- int chunk = 0;
int unset_bit;
+ int chunk;
- while (1) {
+ for (chunk = 0; ; chunk++) {
end = bitmap_find_region_reverse(start, end);
if (start > end)
break;
@@ -758,7 +758,6 @@ int bitmap_parse(const char *start, unsigned int buflen,
#endif
if (IS_ERR(end))
return PTR_ERR(end);
- chunk++;
}
unset_bit = (BITS_TO_U32(nmaskbits) - chunks) * 32;
--
2.27.0.rc2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v1] lib/bitmap: Convert infinite while loop to for one
2020-06-09 14:05 [PATCH v1] lib/bitmap: Convert infinite while loop to for one Andy Shevchenko
@ 2020-06-09 14:23 ` Alexander Gordeev
0 siblings, 0 replies; 2+ messages in thread
From: Alexander Gordeev @ 2020-06-09 14:23 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: Andrew Morton, linux-kernel, yury.norov
On Tue, Jun 09, 2020 at 05:05:35PM +0300, Andy Shevchenko wrote:
> Convert infinite while loop to for one in order to be more explicit
> in one place what we are doing with chunks.
Reviewed-by: Alexander Gordeev <agordeev@linux.ibm.com>
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>
> Andrew, this can be folded to the fix
>
> lib/bitmap.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/lib/bitmap.c b/lib/bitmap.c
> index 10f8fa0497e3..03ef42fbe658 100644
> --- a/lib/bitmap.c
> +++ b/lib/bitmap.c
> @@ -740,10 +740,10 @@ int bitmap_parse(const char *start, unsigned int buflen,
> const char *end = strnchrnul(start, buflen, '\n') - 1;
> int chunks = BITS_TO_U32(nmaskbits);
> u32 *bitmap = (u32 *)maskp;
> - int chunk = 0;
> int unset_bit;
> + int chunk;
>
> - while (1) {
> + for (chunk = 0; ; chunk++) {
> end = bitmap_find_region_reverse(start, end);
> if (start > end)
> break;
> @@ -758,7 +758,6 @@ int bitmap_parse(const char *start, unsigned int buflen,
> #endif
> if (IS_ERR(end))
> return PTR_ERR(end);
> - chunk++;
> }
>
> unset_bit = (BITS_TO_U32(nmaskbits) - chunks) * 32;
> --
> 2.27.0.rc2
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-06-09 14:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-09 14:05 [PATCH v1] lib/bitmap: Convert infinite while loop to for one Andy Shevchenko
2020-06-09 14:23 ` Alexander Gordeev
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.