Re: [RFC PATCH] vfio: type1: fix kthread use case

From: Markus Elfring
Date: Tue Jul 07 2020 - 02:05:22 EST


â
> +++ b/drivers/vfio/vfio_iommu_type1.c
> @@ -2798,7 +2798,7 @@ static int vfio_iommu_type1_dma_rw_chunk
â
> - bool kthread = current->mm == NULL;
> + bool kthread_load_mm;
> size_t offset;

How do you think about to reduce the scope for such variables?
https://refactoring.com/catalog/reduceScopeOfVariable.html


â
> @@ -2812,11 +2812,12 @@ static int vfio_iommu_type1_dma_rw_chunk
â
> if (!mm)
> return -EPERM;
â
> + kthread_load_mm = current->flags & PF_KTHREAD &&
> + current->mm == NULL;
â

Would you like to apply a more succinct code variant?

+ kthread_load_mm = current->flags & PF_KTHREAD && !current->mm;


Regards,
Markus