Whamcloud - gitweb
LU-9119 lnet: whitespace cleanup for wirecheck.c 46/55446/5
authorOlaf Weber <olaf@sgi.com>
Mon, 17 Jun 2024 04:14:17 +0000 (00:14 -0400)
committerOleg Drokin <green@whamcloud.com>
Tue, 25 Jun 2024 03:33:59 +0000 (03:33 +0000)
Clean up the whitespace use in lnet/utils/wirecheck.c

Test-Parameters: trivial
Signed-off-by: Olaf Weber <olaf@sgi.com>
Signed-off-by: Olaf Weber <olaf.weber@hpe.com>
Change-Id: I5c90d09fd694c8151f6f11f716c491ac3db79eb0
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/55446
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Chris Horn <chris.horn@hpe.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lnet/utils/wirecheck.c

index 5038a3d..c431bf3 100644 (file)
 #define strnlen(s, i) strlen(s)
 #endif
 
-#define BLANK_LINE()                            \
-do {                                            \
-        printf ("\n");                          \
-} while (0)
+#define BLANK_LINE() printf("\n")
 
-#define COMMENT(c)                              \
-do {                                            \
-        printf ("        /* "c" */\n");         \
-} while (0)
+#define COMMENT(c) printf("        /* "c" */\n")
 
 #define STRINGIFY(a) #a
 
-#define CHECK_BUILD_TEST(a)                                    \
-       printf("        BUILD_BUG_ON("#a");\n")
+#define CHECK_BUILD_TEST(a) printf("   BUILD_BUG_ON("#a");\n")
 
-#define CHECK_DEFINE(a)                                                 \
-do {                                                                    \
-        printf ("        BUILD_BUG_ON("#a" != "STRINGIFY(a)");\n");     \
-} while (0)
+#define CHECK_DEFINE(a)                                                        \
+       printf("        BUILD_BUG_ON("#a" != "STRINGIFY(a)");\n")
 
-#define CHECK_VALUE(a)                                     \
-do {                                                       \
-        printf ("        BUILD_BUG_ON("#a" != %d);\n", a); \
-} while (0)
+#define CHECK_VALUE(a)                                                 \
+       printf("        BUILD_BUG_ON("#a" != %d);\n", a)
 
-#define CHECK_MEMBER_OFFSET(s,m)                \
-do {                                            \
-        CHECK_VALUE((int)offsetof(s, m));       \
-} while (0)
+#define CHECK_MEMBER_OFFSET(s, m) CHECK_VALUE((int)offsetof(s, m))
 
-#define CHECK_MEMBER_SIZEOF(s,m)                \
-do {                                            \
-        CHECK_VALUE((int)sizeof(((s *)0)->m));  \
-} while (0)
+#define CHECK_MEMBER_SIZEOF(s, m) CHECK_VALUE((int)sizeof(((s *)0)->m))
 
-#define CHECK_MEMBER_IS_FLEXIBLE(s, m)                 \
+#define CHECK_MEMBER_IS_FLEXIBLE(s, m)                                 \
 do {                                                                   \
        CHECK_MEMBER_OFFSET(s, m);                                      \
        CHECK_BUILD_TEST(offsetof(struct s, m) != sizeof(struct s));    \
 } while (0)
 
-#define CHECK_MEMBER(s,m)                       \
-do {                                            \
-        CHECK_MEMBER_OFFSET(s, m);              \
-        CHECK_MEMBER_SIZEOF(s, m);              \
+#define CHECK_MEMBER(s, m)                                             \
+do {                                                                   \
+       CHECK_MEMBER_OFFSET(s, m);                                      \
+       CHECK_MEMBER_SIZEOF(s, m);                                      \
 } while (0)
 
-#define CHECK_STRUCT(s)                         \
-do {                                            \
-        BLANK_LINE ();                          \
-        COMMENT ("Checks for struct "#s);       \
-        CHECK_VALUE((int)sizeof(s));            \
+#define CHECK_STRUCT(s)                                                        \
+do {                                                                   \
+       BLANK_LINE();                                                   \
+       COMMENT("Checks for struct "#s);                                \
+       CHECK_VALUE((int)sizeof(s));                                    \
 } while (0)
 
 static void
@@ -91,7 +74,7 @@ check_lnet_handle_wire(void)
 }
 
 static void
-check_lnet_magicversion (void)
+check_lnet_magicversion(void)
 {
        CHECK_STRUCT(struct lnet_magicversion);
        CHECK_MEMBER(struct lnet_magicversion, magic);
@@ -111,34 +94,34 @@ check_lnet_hdr_nid4(void)
        CHECK_MEMBER(struct _lnet_hdr_nid4, payload_length);
        CHECK_MEMBER(struct _lnet_hdr_nid4, msg);
 
-        BLANK_LINE ();
-        COMMENT ("Ack");
+       BLANK_LINE();
+       COMMENT("Ack");
        CHECK_MEMBER(struct _lnet_hdr_nid4, msg.ack.dst_wmd);
        CHECK_MEMBER(struct _lnet_hdr_nid4, msg.ack.match_bits);
        CHECK_MEMBER(struct _lnet_hdr_nid4, msg.ack.mlength);
 
-        BLANK_LINE ();
-        COMMENT ("Put");
+       BLANK_LINE();
+       COMMENT("Put");
        CHECK_MEMBER(struct _lnet_hdr_nid4, msg.put.ack_wmd);
        CHECK_MEMBER(struct _lnet_hdr_nid4, msg.put.match_bits);
        CHECK_MEMBER(struct _lnet_hdr_nid4, msg.put.hdr_data);
        CHECK_MEMBER(struct _lnet_hdr_nid4, msg.put.ptl_index);
        CHECK_MEMBER(struct _lnet_hdr_nid4, msg.put.offset);
 
-        BLANK_LINE ();
-        COMMENT ("Get");
+       BLANK_LINE();
+       COMMENT("Get");
        CHECK_MEMBER(struct _lnet_hdr_nid4, msg.get.return_wmd);
        CHECK_MEMBER(struct _lnet_hdr_nid4, msg.get.match_bits);
        CHECK_MEMBER(struct _lnet_hdr_nid4, msg.get.ptl_index);
        CHECK_MEMBER(struct _lnet_hdr_nid4, msg.get.src_offset);
        CHECK_MEMBER(struct _lnet_hdr_nid4, msg.get.sink_length);
 
-        BLANK_LINE ();
-        COMMENT ("Reply");
+       BLANK_LINE();
+       COMMENT("Reply");
        CHECK_MEMBER(struct _lnet_hdr_nid4, msg.reply.dst_wmd);
 
-        BLANK_LINE ();
-        COMMENT ("Hello");
+       BLANK_LINE();
+       COMMENT("Hello");
        CHECK_MEMBER(struct _lnet_hdr_nid4, msg.hello.incarnation);
        CHECK_MEMBER(struct _lnet_hdr_nid4, msg.hello.type);
 }
@@ -191,86 +174,85 @@ check_lnet_ping_info(void)
 static void
 system_string(char *cmdline, char *str, int len)
 {
-        int   fds[2];
-        int   rc;
-        pid_t pid;
+       int fds[2];
+       int rc;
+       pid_t pid;
 
-        rc = pipe (fds);
-        if (rc != 0)
-                abort ();
+       rc = pipe(fds);
+       if (rc != 0)
+               abort();
 
-        pid = fork ();
-        if (pid == 0) {
-                /* child */
-                int   fd = fileno(stdout);
+       pid = fork();
+       if (pid == 0) {
+               /* child */
+               int fd = fileno(stdout);
 
-                rc = dup2(fds[1], fd);
-                if (rc != fd)
-                        abort();
+               rc = dup2(fds[1], fd);
+               if (rc != fd)
+                       abort();
 
-                exit(system(cmdline));
-                /* notreached */
-        } else if ((int)pid < 0) {
-                abort();
-        } else {
-                FILE *f = fdopen (fds[0], "r");
+               exit(system(cmdline));
+               /* notreached */
+       } else if ((int)pid < 0) {
+               abort();
+       } else {
+               FILE *f = fdopen(fds[0], "r");
 
-                if (f == NULL)
-                        abort();
+               if (f == NULL)
+                       abort();
 
-                close(fds[1]);
+               close(fds[1]);
 
-                if (fgets(str, len, f) == NULL)
-                        abort();
+               if (fgets(str, len, f) == NULL)
+                       abort();
 
-                if (waitpid(pid, &rc, 0) != pid)
-                        abort();
+               if (waitpid(pid, &rc, 0) != pid)
+                       abort();
 
-                if (!WIFEXITED(rc) ||
-                    WEXITSTATUS(rc) != 0)
-                        abort();
+               if (!WIFEXITED(rc) || WEXITSTATUS(rc) != 0)
+                       abort();
 
-                if (strnlen(str, len) == len)
-                        str[len - 1] = 0;
+               if (strnlen(str, len) == len)
+                       str[len - 1] = 0;
 
-                if (str[strlen(str) - 1] == '\n')
-                        str[strlen(str) - 1] = 0;
+               if (str[strlen(str) - 1] == '\n')
+                       str[strlen(str) - 1] = 0;
 
-                fclose(f);
-        }
+               fclose(f);
+       }
 }
 
 int
-main (int argc, char **argv)
+main(int argc, char **argv)
 {
-        char unameinfo[256];
-        char gccinfo[256];
+       char unameinfo[256];
+       char gccinfo[256];
 
-        system_string("uname -a", unameinfo, sizeof(unameinfo));
-        system_string("gcc -v 2>&1 | tail -1", gccinfo, sizeof(gccinfo));
+       system_string("uname -a", unameinfo, sizeof(unameinfo));
+       system_string("gcc -v 2>&1 | tail -1", gccinfo, sizeof(gccinfo));
 
-        printf ("void lnet_assert_wire_constants (void)\n"
-                "{\n"
-                "        /* Wire protocol assertions generated by 'wirecheck'\n"
-                "         * running on %s\n"
-                "         * with %s */\n"
-                "\n", unameinfo, gccinfo);
+       printf("void lnet_assert_wire_constants (void)\n"
+              "{\n"
+              "        /* Wire protocol assertions generated by 'wirecheck'\n"
+              "         * running on %s\n"
+              "         * with %s */\n"
+              "\n", unameinfo, gccinfo);
 
-        BLANK_LINE ();
+       BLANK_LINE();
 
-        COMMENT ("Constants...");
+       COMMENT("Constants...");
 
-        CHECK_DEFINE (LNET_PROTO_RA_MAGIC);
+       CHECK_DEFINE(LNET_PROTO_RA_MAGIC);
 
-        CHECK_DEFINE (LNET_PROTO_TCP_MAGIC);
-        CHECK_DEFINE (LNET_PROTO_TCP_VERSION_MAJOR);
-        CHECK_DEFINE (LNET_PROTO_TCP_VERSION_MINOR);
+       CHECK_DEFINE(LNET_PROTO_TCP_MAGIC);
+       CHECK_DEFINE(LNET_PROTO_TCP_VERSION_MAJOR);
+       CHECK_DEFINE(LNET_PROTO_TCP_VERSION_MINOR);
 
-        CHECK_VALUE (LNET_MSG_ACK);
-        CHECK_VALUE (LNET_MSG_PUT);
-        CHECK_VALUE (LNET_MSG_GET);
-        CHECK_VALUE (LNET_MSG_REPLY);
-        CHECK_VALUE (LNET_MSG_HELLO);
+       CHECK_VALUE(LNET_MSG_ACK);
+       CHECK_VALUE(LNET_MSG_PUT);
+       CHECK_VALUE(LNET_MSG_GET);
+       CHECK_VALUE(LNET_MSG_REPLY);
+       CHECK_VALUE(LNET_MSG_HELLO);
 
        check_lnet_handle_wire();
        check_lnet_magicversion();
@@ -278,7 +260,7 @@ main (int argc, char **argv)
        check_lnet_ni_status();
        check_lnet_ping_info();
 
-        printf ("}\n\n");
+       printf("}\n\n");
 
-        return (0);
+       return 0;
 }