]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
sock_diag.7: ffix: white space tweaks in example program
authorMichael Kerrisk <mtk.manpages@gmail.com>
Wed, 7 Dec 2016 14:23:33 +0000 (15:23 +0100)
committerMichael Kerrisk <mtk.manpages@gmail.com>
Wed, 7 Dec 2016 14:23:33 +0000 (15:23 +0100)
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
man7/sock_diag.7

index ca12dedffe29dc3a81acfa3e472ed7a41d9f4362..fa5969931a36119b38c16081c0ffaed7010bfc12 100644 (file)
@@ -733,9 +733,11 @@ send_query(int fd)
         if (sendmsg(fd, &msg, 0) < 0) {
             if (errno == EINTR)
                 continue;
+
             perror("sendmsg");
             return \-1;
         }
+
         return 0;
     }
 }
@@ -761,19 +763,20 @@ print_diag(const struct unix_diag_msg *diag, unsigned int len)
     for (attr = (struct rtattr *) (diag + 1);
              RTA_OK(attr, rta_len); attr = RTA_NEXT(attr, rta_len)) {
         switch (attr\->rta_type) {
-            case UNIX_DIAG_NAME:
-                if (!path_len) {
-                    path_len = RTA_PAYLOAD(attr);
-                    if (path_len > sizeof(path) \- 1)
-                        path_len = sizeof(path) \- 1;
-                    memcpy(path, RTA_DATA(attr), path_len);
-                    path[path_len] = '\\0';
-                }
-                break;
-            case UNIX_DIAG_PEER:
-                if (RTA_PAYLOAD(attr) >= sizeof(peer))
-                    peer = *(unsigned int *) RTA_DATA(attr);
-                break;
+        case UNIX_DIAG_NAME:
+            if (!path_len) {
+                path_len = RTA_PAYLOAD(attr);
+                if (path_len > sizeof(path) \- 1)
+                    path_len = sizeof(path) \- 1;
+                memcpy(path, RTA_DATA(attr), path_len);
+                path[path_len] = '\\0';
+            }
+            break;
+
+        case UNIX_DIAG_PEER:
+            if (RTA_PAYLOAD(attr) >= sizeof(peer))
+                peer = *(unsigned int *) RTA_DATA(attr);
+            break;
         }
     }
 
@@ -783,7 +786,8 @@ print_diag(const struct unix_diag_msg *diag, unsigned int len)
         printf(", peer=%u", peer);
 
     if (path_len)
-        printf(", name=%s%s", *path ? "" : "@", *path ? path : path + 1);
+        printf(", name=%s%s", *path ? "" : "@",
+                *path ? path : path + 1);
 
     putchar('\\n');
     return 0;
@@ -815,6 +819,7 @@ receive_responses(int fd)
         if (ret < 0) {
             if (errno == EINTR)
                 continue;
+
             perror("recvmsg");
             return \-1;
         }
@@ -827,9 +832,11 @@ receive_responses(int fd)
             fputs("!NLMSG_OK\\n", stderr);
             return \-1;
         }
+
         for (; NLMSG_OK(h, ret); h = NLMSG_NEXT(h, ret)) {
             if (h\->nlmsg_type == NLMSG_DONE)
                 return 0;
+
             if (h\->nlmsg_type == NLMSG_ERROR) {
                 const struct nlmsgerr *err = NLMSG_DATA(h);
 
@@ -839,8 +846,10 @@ receive_responses(int fd)
                     errno = \-err\->error;
                     perror("NLMSG_ERROR");
                 }
+
                 return \-1;
             }
+
             if (h\->nlmsg_type != SOCK_DIAG_BY_FAMILY) {
                 fprintf(stderr, "unexpected nlmsg_type %u\\n",
                         (unsigned) h\->nlmsg_type);