Re: [PATCH v3] dm cache: parse invalidate_cblocks with kstrtouint()

From: Ming Hung Tsai

Date: Mon Jul 13 2026 - 05:26:44 EST


On Sun, Jul 12, 2026 at 5:39 AM Samuel Moelius
<sam.moelius@xxxxxxxxxxxxxxx> wrote:
>
> + if (str) {
> + blocknr = str;
> +
> + r = kstrtouint(blocknr, 10, &e);
> + if (r)
> + goto bad;
>
> - if (r == 1) {
> - result->begin = to_cblock(b);
> - result->end = to_cblock(from_cblock(result->begin) + 1u);
> + result->end = to_cblock(e);
> return 0;
> }
>
> - DMERR("%s: invalid cblock range '%s'", cache_device_name(cache), str);
> + result->end = cblock_succ(result->begin);
> + return 0;

A minor nit: the range vs. single-value cases are peer alternatives.
Rather than multiple "returns 0", using if-else makes the parallel
structure more explicit: both paths share the same prologue (parse
result->begin) and epilogue (return 0), differ only in how result->end
is computed.