diff mbox series

[v1] nitro_enclaves: Fixup type of the poll result assigned value

Message ID 20201014090500.75678-1-andraprs@amazon.com
State New, archived
Headers show
Series [v1] nitro_enclaves: Fixup type of the poll result assigned value | expand

Commit Message

Paraschiv, Andra-Irina Oct. 14, 2020, 9:05 a.m. UTC
Update the assigned value of the poll result to be EPOLLHUP instead of
POLLHUP to match the __poll_t type.

Signed-off-by: Andra Paraschiv <andraprs@amazon.com>
Reported-by: kernel test robot <lkp@intel.com>
---
 drivers/virt/nitro_enclaves/ne_misc_dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Alexander Graf Nov. 2, 2020, 4:16 p.m. UTC | #1
On 14.10.20 11:05, Andra Paraschiv wrote:
> Update the assigned value of the poll result to be EPOLLHUP instead of
> POLLHUP to match the __poll_t type.
> 
> Signed-off-by: Andra Paraschiv <andraprs@amazon.com>
> Reported-by: kernel test robot <lkp@intel.com>
> ---
>   drivers/virt/nitro_enclaves/ne_misc_dev.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/virt/nitro_enclaves/ne_misc_dev.c b/drivers/virt/nitro_enclaves/ne_misc_dev.c
> index f06622b48d69..9148566455e8 100644
> --- a/drivers/virt/nitro_enclaves/ne_misc_dev.c
> +++ b/drivers/virt/nitro_enclaves/ne_misc_dev.c
> @@ -1508,7 +1508,7 @@ static __poll_t ne_enclave_poll(struct file *file, poll_table *wait)
>   	if (!ne_enclave->has_event)
>   		return mask;
>   
> -	mask = POLLHUP;
> +	mask = EPOLLHUP;

That whole function looks a bit ... convoluted? How about this? I guess 
you could trim it down even further, but this looks quite readable to me:

diff --git a/drivers/virt/nitro_enclaves/ne_misc_dev.c 
b/drivers/virt/nitro_enclaves/ne_misc_dev.c
index f06622b48d69..5b7f45e2eb4c 100644
--- a/drivers/virt/nitro_enclaves/ne_misc_dev.c
+++ b/drivers/virt/nitro_enclaves/ne_misc_dev.c
@@ -1505,10 +1505,8 @@ static __poll_t ne_enclave_poll(struct file 
*file, poll_table *wait)

  	poll_wait(file, &ne_enclave->eventq, wait);

-	if (!ne_enclave->has_event)
-		return mask;
-
-	mask = POLLHUP;
+	if (ne_enclave->has_event)
+		mask |= POLLHUP;

  	return mask;
  }


Alex



Amazon Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss
Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B
Sitz: Berlin
Ust-ID: DE 289 237 879
Paraschiv, Andra-Irina Nov. 2, 2020, 5:42 p.m. UTC | #2
On 02/11/2020 18:16, Alexander Graf wrote:
>
>
> On 14.10.20 11:05, Andra Paraschiv wrote:
>> Update the assigned value of the poll result to be EPOLLHUP instead of
>> POLLHUP to match the __poll_t type.
>>
>> Signed-off-by: Andra Paraschiv <andraprs@amazon.com>
>> Reported-by: kernel test robot <lkp@intel.com>
>> ---
>>   drivers/virt/nitro_enclaves/ne_misc_dev.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/virt/nitro_enclaves/ne_misc_dev.c 
>> b/drivers/virt/nitro_enclaves/ne_misc_dev.c
>> index f06622b48d69..9148566455e8 100644
>> --- a/drivers/virt/nitro_enclaves/ne_misc_dev.c
>> +++ b/drivers/virt/nitro_enclaves/ne_misc_dev.c
>> @@ -1508,7 +1508,7 @@ static __poll_t ne_enclave_poll(struct file 
>> *file, poll_table *wait)
>>       if (!ne_enclave->has_event)
>>           return mask;
>>   -    mask = POLLHUP;
>> +    mask = EPOLLHUP;
>
> That whole function looks a bit ... convoluted? How about this? I 
> guess you could trim it down even further, but this looks quite 
> readable to me:
>
> diff --git a/drivers/virt/nitro_enclaves/ne_misc_dev.c 
> b/drivers/virt/nitro_enclaves/ne_misc_dev.c
> index f06622b48d69..5b7f45e2eb4c 100644
> --- a/drivers/virt/nitro_enclaves/ne_misc_dev.c
> +++ b/drivers/virt/nitro_enclaves/ne_misc_dev.c
> @@ -1505,10 +1505,8 @@ static __poll_t ne_enclave_poll(struct file 
> *file, poll_table *wait)
>
>      poll_wait(file, &ne_enclave->eventq, wait);
>
> -    if (!ne_enclave->has_event)
> -        return mask;
> -
> -    mask = POLLHUP;
> +    if (ne_enclave->has_event)
> +        mask |= POLLHUP;
>
>      return mask;
>  }
>

Good point, I updated the logic and sent the v2 of the patch.

https://lore.kernel.org/lkml/20201102173622.32169-1-andraprs@amazon.com/

Thank you.

Andra




Amazon Development Center (Romania) S.R.L. registered office: 27A Sf. Lazar Street, UBC5, floor 2, Iasi, Iasi County, 700045, Romania. Registered in Romania. Registration number J22/2621/2005.
diff mbox series

Patch

diff --git a/drivers/virt/nitro_enclaves/ne_misc_dev.c b/drivers/virt/nitro_enclaves/ne_misc_dev.c
index f06622b48d69..9148566455e8 100644
--- a/drivers/virt/nitro_enclaves/ne_misc_dev.c
+++ b/drivers/virt/nitro_enclaves/ne_misc_dev.c
@@ -1508,7 +1508,7 @@  static __poll_t ne_enclave_poll(struct file *file, poll_table *wait)
 	if (!ne_enclave->has_event)
 		return mask;
 
-	mask = POLLHUP;
+	mask = EPOLLHUP;
 
 	return mask;
 }