Linux GPIO subsystem development
 help / color / mirror / Atom feed
* [PATCH] tools: gpio-watch: Preserve line event read errors
@ 2026-11-20  6:18 Zhu Jun
  2026-11-20  9:47 ` Andy Shevchenko
  0 siblings, 1 reply; 2+ messages in thread
From: Zhu Jun @ 2026-11-20  6:18 UTC (permalink / raw)
  To: brgl; +Cc: warthog618, andriy.shevchenko, linux-gpio, linux-kernel, Zhu Jun

The short-read check sets errno to EIO even when read() returns -1,
hiding errors such as EINTR. Set EIO only for a nonnegative short
read and keep the original errno for a failed read.

Fixes: 33f0c47b8fb4 ("tools: gpio: implement gpio-watch")
Signed-off-by: Zhu Jun <zhujun2@cmss.chinamobile.com>
---
 tools/gpio/gpio-watch.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/gpio/gpio-watch.c b/tools/gpio/gpio-watch.c
index 41e76d244192..a77f6d0cd0a0 100644
--- a/tools/gpio/gpio-watch.c
+++ b/tools/gpio/gpio-watch.c
@@ -63,8 +63,8 @@ int main(int argc, char **argv)
 		} else if (ret > 0) {
 			memset(&chg, 0, sizeof(chg));
 			rd = read(pfd.fd, &chg, sizeof(chg));
-			if (rd < 0 || rd != sizeof(chg)) {
-				if (rd != sizeof(chg))
+			if (rd != sizeof(chg)) {
+				if (rd >= 0)
 					errno = EIO;
 
 				perror("error reading line change event");



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] tools: gpio-watch: Preserve line event read errors
  2026-11-20  6:18 [PATCH] tools: gpio-watch: Preserve line event read errors Zhu Jun
@ 2026-11-20  9:47 ` Andy Shevchenko
  0 siblings, 0 replies; 2+ messages in thread
From: Andy Shevchenko @ 2026-11-20  9:47 UTC (permalink / raw)
  To: Zhu Jun; +Cc: brgl, warthog618, linux-gpio, linux-kernel

On Fri, Nov 20, 2026 at 02:18:36PM +0800, Zhu Jun wrote:
> The short-read check sets errno to EIO even when read() returns -1,
> hiding errors such as EINTR. Set EIO only for a nonnegative short
> read and keep the original errno for a failed read.

Isn't somebody sent similar change a week ago?
Before sending something like this, always check mailing list archive.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-20  9:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-20  6:18 [PATCH] tools: gpio-watch: Preserve line event read errors Zhu Jun
2026-11-20  9:47 ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox