]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
man/man2/userfaultfd.2: EXAMPLES: Reduce scope of local variables
authorAlejandro Colomar <alx@kernel.org>
Sun, 8 Feb 2026 21:42:25 +0000 (22:42 +0100)
committerAlejandro Colomar <alx@kernel.org>
Sun, 8 Feb 2026 21:56:32 +0000 (22:56 +0100)
Signed-off-by: Alejandro Colomar <alx@kernel.org>
man/man2/userfaultfd.2

index f656115da879f0adc5ac88580251b5f4264fa56f..26ba727b12ae4b39903741dd81ece3a8649e309f 100644 (file)
@@ -765,11 +765,7 @@ static int page_size;
 static void *
 fault_handler_thread(void *arg)
 {
-    int                 nready;
-    long                uffd;   /* userfaultfd file descriptor */
-    ssize_t             nread;
-    struct pollfd       pollfd;
-    struct uffdio_copy  uffdio_copy;
+    long  uffd;   /* userfaultfd file descriptor */
 \&
     static int      fault_cnt = 0; /* Number of faults so far handled */
     static char     *page = NULL;
@@ -790,6 +786,10 @@ fault_handler_thread(void *arg)
        file descriptor.  */
 \&
     for (;;) {
+        int                 nready;
+        ssize_t             nread;
+        struct pollfd       pollfd;
+        struct uffdio_copy  uffdio_copy;
 \&
         /* See what poll() tells us about the userfaultfd.  */
 \&
@@ -858,7 +858,6 @@ int
 main(int argc, char *argv[])
 {
     int        s;
-    char       c;
     char       *addr;   /* Start of region handled by userfaultfd */
     long       uffd;    /* userfaultfd file descriptor */
     size_t     size, i;  /* Size of region handled by userfaultfd */
@@ -929,6 +928,8 @@ main(int argc, char *argv[])
                    boundary, in order to test that we correctly
                    handle that case in fault_handling_thread().  */
     while (i < size) {
+        char  c;
+\&
         c = addr[i];
         printf("Read address %p in %s(): ", addr + i, __func__);
         printf("%c\[rs]n", c);