On 10/28/25 7:03 PM, Jonas Rebmann wrote:
> The idr_for_each_entry() macro uses an if statement to update _entry and
> _in in the loop body. This can lead to dangling else issues, or at least
> a compiler warning of the potential thereof.
> 
> We build with -Werror=dangling-else in CI and that is triggered very
> easily by this construct.
> 
> Move the loop body into an else to avoid this issue.
> 
> Signed-off-by: Jonas Rebmann <[email protected]>

Reviewed-by: Ahmad Fatoum <[email protected]>



> ---
>  include/linux/idr.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/linux/idr.h b/include/linux/idr.h
> index e726d17b59..206c006c62 100644
> --- a/include/linux/idr.h
> +++ b/include/linux/idr.h
> @@ -41,7 +41,7 @@ struct idr {
>            *tmp = iter ? list_next_entry(iter, list) : NULL;          \
>            (iter && iter != (_idr)) || (_entry = NULL);               \
>            iter = tmp, tmp = tmp ?  list_next_entry(tmp, list) : NULL)\
> -     if ((_entry = iter->ptr, _id = iter->id, true))
> +     if ((_entry = iter->ptr, _id = iter->id, false)) {} else
>  
>  struct idr *__idr_find(struct idr *head, int lookup_id);
>  
> 

-- 
Pengutronix e.K.                  |                             |
Steuerwalder Str. 21              | http://www.pengutronix.de/  |
31137 Hildesheim, Germany         | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686  | Fax:   +49-5121-206917-5555 |


Reply via email to