Skip to contentSkip to conversation

posix clocks: correct error value in posix_clock_poll()

PATCH In review Nicolas Kaiser 2 participants 3 messages May 24, 2011 Posix clocks and timers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 posix clocks: correct error value in posix_clock_poll()

---
It looks to me like -ENODEV might not be a good return value in poll(). Would POLLERR be the correct one in this case?

 kernel/time/posix-clock.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/time/posix-clock.c +1 -1
index c340ca6..2424d3f 100644
@@ -71,7 +71,7 @@ static unsigned int posix_clock_poll(struct file *fp, poll_table *wait)
 	int result = 0;
 
 	if (!clk)
-		return -ENODEV;
+		return POLLERR;
 
 	if (clk->ops.poll)
 		result = clk->ops.poll(clk, fp, wait);
Signature · 1 line
1.7.5.rc3
#1 lore raw
Quoted 13 lines · Nicolas Kaiser

---
It looks to me like -ENODEV might not be a good return value in poll(). Would POLLERR be the correct one in this case?

 kernel/time/posix-clock.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/time/posix-clock.c +0 -0
index c340ca6..2424d3f 100644

kernel/time/posix-clock.c static unsigned int posix_clock_poll(struct file *fp, poll_table *wait) · line 74

Quoted 5 lines
kernel/time/posix-clock.c +1 -1
@@ -71,7 +71,7 @@ static unsigned int posix_clock_poll(struct file *fp, poll_table *wait)
 	int result = 0;
 
 	if (!clk)
-		return -ENODEV;
+		return POLLERR;

The condition (!clk) is only satisfied when 'zombie' is set, indicating that the dynamic clock has disappeared. That is why the file operations uniformly return ENODEV. So, I think it makes sense the way that it is.

In addition, man 2 poll says,

POLLERR
Error condition (output only).

so using that error code would be misleading, IMHO.

Thanks,
Richard

#2 lore raw

* Richard Cochran <[email protected]>:

Quoted 9 lines · Nicolas Kaiser
Quoted 2 lines

It looks to me like -ENODEV might not be a good return value in poll(). Would POLLERR be the correct one in this case?

The condition (!clk) is only satisfied when 'zombie' is set, indicating that the dynamic clock has disappeared. That is why the file operations uniformly return ENODEV. So, I think it makes sense the way that it is.

Quoted 6 lines

In addition, man 2 poll says,

POLLERR
Error condition (output only).

so using that error code would be misleading, IMHO.

I see. Sorry for the noise.

Best regards,
Nicolas Kaiser