# Re: \[f2fs-dev\] \[PATCH v1 3/5\] treewide: use get\_random\_u32() when possible

- From: Andy Shevchenko \<andriy.shevchenko@linux.intel.com\>
- Date: 2022-10-06 13:01:48 
- List: linux-fbdev
- Page: https://ratatoskr.run/linux-fbdev/2022/10/236681
- Thread: https://ratatoskr.run/dri-devel/2022/10/236652/t.md

```text
On Thu, Oct 06, 2022 at 06:33:15AM -0600, Jason A. Donenfeld wrote:
> On Thu, Oct 06, 2022 at 10:43:31AM +0200, Jan Kara wrote:

...

> > The code here is effectively doing the
> > 
> > 	parent_group = prandom_u32_max(ngroups);
> > 
> > Similarly here we can use prandom_u32_max(ngroups) like:
> > 
> > 		if (qstr) {
> > 			...
> > 			parent_group = hinfo.hash % ngroups;
> > 		} else
> > 			parent_group = prandom_u32_max(ngroups);
> 
> Nice catch. I'll move these to patch #1.

I believe coccinelle is able to handle this kind of code as well, so Kees'
proposal to use it seems more plausible since it's less error prone and more
flexible / powerful.

-- 
With Best Regards,
Andy Shevchenko


```
