Re: [PATCH v3] dm cache: parse invalidate_cblocks with kstrtouint()
Ming Hung Tsai <[email protected]> Mon, 13 Jul 2026 17:26:22 +0800
| Newsgroups | dev.linux.lists.dm-devel,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <CALjSBEvnJj=C4N1g2c7vuVorCA0vsSP=xNwQhDdChQTANTwadA@mail.gmail.com> |
On Sun, Jul 12, 2026 at 5:39 AM Samuel Moelius <[email protected]> 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.