All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] close_range.2: Add _GNU_SOURCE and unistd.h to SYNOPSIS
@ 2024-02-12 12:07 Mark Wielaard
  2024-02-18  1:09 ` Alejandro Colomar
  0 siblings, 1 reply; 8+ messages in thread
From: Mark Wielaard @ 2024-02-12 12:07 UTC (permalink / raw)
  To: linux-man; +Cc: Alejandro Colomar, Mark Wielaard, Alexandra Hájková

close_range is defined in unistd.h when _GNU_SOURCE is defined.
The linux/close_range.h include file only defines the (linux specific)
flags constants. The flags argument is an int, not an unsigned int, in
the glibc wrapper. Use the close_range library call in the example code
instead of syscall.

Fixes: 71a62d6c3c56 ("close_range.2: Glibc added a wrapper recently")
Fixes: c2356ba085ed ("close_range.2: Glibc 2.34 has added a close_range() wrapper")

Reported-by: Alexandra Hájková <ahajkova@redhat.com>
Signed-off-by: Mark Wielaard <mark@klomp.org>
---
 man2/close_range.2 | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/man2/close_range.2 b/man2/close_range.2
index 380a47365..53ee5524e 100644
--- a/man2/close_range.2
+++ b/man2/close_range.2
@@ -11,10 +11,14 @@ Standard C library
 .RI ( libc ", " \-lc )
 .SH SYNOPSIS
 .nf
-.B #include <linux/close_range.h>
+.BR "#define _GNU_SOURCE" "         /* See feature_test_macros(7) */"
+.B #include <unistd.h>
+.P
+.BR "#include <linux/close_range.h>" " /* Definition of " CLOSE_RANGE_* "
+.BR "" "                                  constants */"
 .P
 .BI "int close_range(unsigned int " first ", unsigned int " last ,
-.BI "                unsigned int " flags );
+.BI "                int " flags );
 .fi
 .SH DESCRIPTION
 The
@@ -205,7 +209,6 @@ result from the calls to
 #include <limits.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <sys/syscall.h>
 #include <unistd.h>
 \&
 /* Show the contents of the symbolic links in /proc/self/fd */
@@ -259,7 +262,7 @@ main(int argc, char *argv[])
 \&
     printf("========= About to call close_range() =======\en");
 \&
-    if (syscall(SYS_close_range, 3, \[ti]0U, 0) == \-1) {
+    if (close_range(3, \[ti]0U, 0) == \-1) {
         perror("close_range");
         exit(EXIT_FAILURE);
     }
-- 
2.39.3


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

end of thread, other threads:[~2024-02-18 16:36 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-12 12:07 [PATCH v3] close_range.2: Add _GNU_SOURCE and unistd.h to SYNOPSIS Mark Wielaard
2024-02-18  1:09 ` Alejandro Colomar
2024-02-18 12:00   ` Mark Wielaard
2024-02-18 13:08     ` Alejandro Colomar
2024-02-18 14:14       ` man page base paragraph inset/indentation (was: [PATCH v3] close_range.2: Add _GNU_SOURCE and unistd.h to SYNOPSIS) G. Branden Robinson
2024-02-18 15:18         ` Alejandro Colomar
2024-02-18 16:36           ` groff 1.24 scheduling thoughts (was: man page base paragraph inset/indentation) G. Branden Robinson
2024-02-18 13:15     ` [PATCH v3] close_range.2: Add _GNU_SOURCE and unistd.h to SYNOPSIS Alejandro Colomar

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.