]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
Various pages: EXAMPLES: Fix -Wdeclaration-after-statement errors
authorAlejandro Colomar <alx@kernel.org>
Wed, 25 Jan 2023 23:00:30 +0000 (00:00 +0100)
committerAlejandro Colomar <alx@kernel.org>
Thu, 26 Jan 2023 00:01:55 +0000 (01:01 +0100)
Signed-off-by: Alejandro Colomar <alx@kernel.org>
man2/mount_setattr.2
man3/getaddrinfo.3
man3/tsearch.3

index cfa1a6e5a39a0466fcb15e147adaaddf71ab3d46..0ad342b4dc053258d2649ab290de6fa07aca333c 100644 (file)
@@ -953,9 +953,12 @@ int
 main(int argc, char *argv[])
 {
     int                fd_userns = \-1;
+    int                fd_tree;
     int                index = 0;
     int                ret;
     bool               recursive = false;
+    const char         *source;
+    const char         *target;
     struct mount_attr  *attr = &(struct mount_attr){};
 
     while ((ret = getopt_long_only(argc, argv, "",
@@ -993,8 +996,8 @@ main(int argc, char *argv[])
     if ((argc \- optind) < 2)
         errx(EXIT_FAILURE, "Missing source or target mount point");
 
-    const char *source = argv[optind];
-    const char *target = argv[optind + 1];
+    source = argv[optind];
+    target = argv[optind + 1];
 
     /* In the following, \-1 as the \(aqdirfd\(aq argument ensures that
        open_tree() fails if \(aqsource\(aq is not an absolute pathname. */
@@ -1011,9 +1014,9 @@ main(int argc, char *argv[])
 .\"     If I can't operate based on a well-known dirfd I use absolute paths
 .\"     with a -EBADF dirfd passed to *at() functions.
 
-    int fd_tree = open_tree(\-1, source,
-                       OPEN_TREE_CLONE | OPEN_TREE_CLOEXEC |
-                       AT_EMPTY_PATH | (recursive ? AT_RECURSIVE : 0));
+    fd_tree = open_tree(\-1, source,
+                        OPEN_TREE_CLONE | OPEN_TREE_CLOEXEC |
+                        AT_EMPTY_PATH | (recursive ? AT_RECURSIVE : 0));
     if (fd_tree == \-1)
         err(EXIT_FAILURE, "open(%s)", source);
 
index 1248ae34d1c331472fd43a1a8d22f0c1f5984a2b..6b2ad1026b7cc6f867dc6698660c088903b68a19 100644 (file)
@@ -713,14 +713,14 @@ main(int argc, char *argv[])
     /* Read datagrams and echo them back to sender. */
 
     for (;;) {
+        char host[NI_MAXHOST], service[NI_MAXSERV];
+
         peer_addrlen = sizeof(peer_addr);
         nread = recvfrom(sfd, buf, BUF_SIZE, 0,
                          (struct sockaddr *) &peer_addr, &peer_addrlen);
         if (nread == \-1)
             continue;               /* Ignore failed request */
 
-        char host[NI_MAXHOST], service[NI_MAXSERV];
-
         s = getnameinfo((struct sockaddr *) &peer_addr,
                         peer_addrlen, host, NI_MAXHOST,
                         service, NI_MAXSERV, NI_NUMERICSERV);
index 169184b2e9173814571986dcbc0b9ef05aa595d8..7d56d9ab8df649a727a4eebfc6837b0893b3bc93 100644 (file)
@@ -309,11 +309,12 @@ action(const void *nodep, VISIT which, int depth)
 int
 main(void)
 {
-    int **val;
+    int  *ptr;
+    int  **val;
 
     srand(time(NULL));
     for (unsigned int i = 0; i < 12; i++) {
-        int *ptr = xmalloc(sizeof(*ptr));
+        ptr = xmalloc(sizeof(*ptr));
         *ptr = rand() & 0xff;
         val = tsearch(ptr, &root, compare);
         if (val == NULL)