# Re: \[PATCH 1/8\] cfq-iosched: simplify control flow in cfq\_get\_queue()

- From: Jeff Moyer \<hidden\>
- Date: 2015-06-08 18:37:03 
- List: cgroups
- Page: https://ratatoskr.run/cgroups/2015/06/4511322
- Thread: https://ratatoskr.run/cgroups/2015/06/4511322/t.md

```text
Tejun Heo [ref] writes:

> cfq_get_queue()'s control flow looks like the following.
>
> 	async_cfqq = NULL;
> 	cfqq = NULL;
>
> 	if (!is_sync) {
> 		...
> 		async_cfqq = ...;
> 		cfqq = *async_cfqq;
> 	}
>
> 	if (!cfqq)
> 		cfqq = ...;
>
> 	if (!is_sync && !(*async_cfqq))
> 		...;
>
> The only thing the local variable init, the second if, and the
> async_cfqq test in the third if achieves is to skip cfqq creation and
> installation if *async_cfqq was already non-NULL.  This is needlessly
> complicated with different tests examining the same condition.
> Simplify it to the following.
>
> 	if (!is_sync) {
> 		...
> 		async_cfqq = ...;
> 		cfqq = *async_cfqq;
> 		if (cfqq)
> 			goto out;
> 	}
>
> 	cfqq = ...;
>
> 	if (!is_sync)
> 		...;
>  out:
>
> Signed-off-by: Tejun Heo <redacted>
> Cc: Vivek Goyal <redacted>
> Cc: Arianna Avanzini <redacted>

Acked-by: Jeff Moyer <redacted>
```
