tools/gpio/gpio-event-mon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
From: Wang Jiang <jiangwang@kylinos.cn>
Using explicit O_RDONLY flag for open() improves code readability
and aligns with kernel coding standards instead of using raw 0.
Signed-off-by: Wang Jiang <jiangwang@kylinos.cn>
---
tools/gpio/gpio-event-mon.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/gpio/gpio-event-mon.c b/tools/gpio/gpio-event-mon.c
index b70813b0bf8e..590ca8db25cf 100644
--- a/tools/gpio/gpio-event-mon.c
+++ b/tools/gpio/gpio-event-mon.c
@@ -41,7 +41,7 @@ int monitor_device(const char *device_name,
if (ret < 0)
return -ENOMEM;
- cfd = open(chrdev_name, 0);
+ cfd = open(chrdev_name, O_RDONLY);
if (cfd == -1) {
ret = -errno;
fprintf(stderr, "Failed to open %s\n", chrdev_name);
--
2.25.1
On Wed, May 20, 2026 at 12:18 PM <2564278112@qq.com> wrote:
>
> From: Wang Jiang <jiangwang@kylinos.cn>
>
> Using explicit O_RDONLY flag for open() improves code readability
> and aligns with kernel coding standards instead of using raw 0.
>
> Signed-off-by: Wang Jiang <jiangwang@kylinos.cn>
> ---
> tools/gpio/gpio-event-mon.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/gpio/gpio-event-mon.c b/tools/gpio/gpio-event-mon.c
> index b70813b0bf8e..590ca8db25cf 100644
> --- a/tools/gpio/gpio-event-mon.c
> +++ b/tools/gpio/gpio-event-mon.c
> @@ -41,7 +41,7 @@ int monitor_device(const char *device_name,
> if (ret < 0)
> return -ENOMEM;
>
> - cfd = open(chrdev_name, 0);
> + cfd = open(chrdev_name, O_RDONLY);
> if (cfd == -1) {
> ret = -errno;
> fprintf(stderr, "Failed to open %s\n", chrdev_name);
> --
> 2.25.1
>
>
Why only here and not elsewhere? Please mention in the commit message
that 0 is effectively O_RDONLY so there's no functional change.
Bart
© 2016 - 2026 Red Hat, Inc.