tipc: Minor enhancements to name table display format
authorAllan Stephens <allan.stephens@windriver.com>
Tue, 17 Aug 2010 11:00:14 +0000 (11:00 +0000)
committerDavid S. Miller <davem@davemloft.net>
Wed, 18 Aug 2010 00:31:58 +0000 (17:31 -0700)
Eliminate printing of dashes after name table column headers
(to adhere more closely to the standard format used in tipc-config),
and simplify name table display logic using array lookups rather
than if-then-else logic.

Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/tipc/name_table.c

index 8ba79620db3f705941fa04ba25aeda92f1215d98..d504e490fd02726140549606074afa2ebcce6c29 100644 (file)
@@ -877,7 +877,7 @@ static void subseq_list(struct sub_seq *sseq, struct print_buf *buf, u32 depth,
                        u32 index)
 {
        char portIdStr[27];
-       char *scopeStr;
+       const char *scope_str[] = {"", " zone", " cluster", " node"};
        struct publication *publ = sseq->zone_list;
 
        tipc_printf(buf, "%-10u %-10u ", sseq->lower, sseq->upper);
@@ -893,15 +893,8 @@ static void subseq_list(struct sub_seq *sseq, struct print_buf *buf, u32 depth,
                         tipc_node(publ->node), publ->ref);
                tipc_printf(buf, "%-26s ", portIdStr);
                if (depth > 3) {
-                       if (publ->node != tipc_own_addr)
-                               scopeStr = "";
-                       else if (publ->scope == TIPC_NODE_SCOPE)
-                               scopeStr = "node";
-                       else if (publ->scope == TIPC_CLUSTER_SCOPE)
-                               scopeStr = "cluster";
-                       else
-                               scopeStr = "zone";
-                       tipc_printf(buf, "%-10u %s", publ->key, scopeStr);
+                       tipc_printf(buf, "%-10u %s", publ->key,
+                                   scope_str[publ->scope]);
                }
 
                publ = publ->zone_list_next;
@@ -951,24 +944,19 @@ static void nameseq_list(struct name_seq *seq, struct print_buf *buf, u32 depth,
 
 static void nametbl_header(struct print_buf *buf, u32 depth)
 {
-       tipc_printf(buf, "Type       ");
-
-       if (depth > 1)
-               tipc_printf(buf, "Lower      Upper      ");
-       if (depth > 2)
-               tipc_printf(buf, "Port Identity              ");
-       if (depth > 3)
-               tipc_printf(buf, "Publication");
-
-       tipc_printf(buf, "\n-----------");
-
-       if (depth > 1)
-               tipc_printf(buf, "--------------------- ");
-       if (depth > 2)
-               tipc_printf(buf, "-------------------------- ");
-       if (depth > 3)
-               tipc_printf(buf, "------------------");
-
+       const char *header[] = {
+               "Type       ",
+               "Lower      Upper      ",
+               "Port Identity              ",
+               "Publication Scope"
+       };
+
+       int i;
+
+       if (depth > 4)
+               depth = 4;
+       for (i = 0; i < depth; i++)
+               tipc_printf(buf, header[i]);
        tipc_printf(buf, "\n");
 }