txtinfo: review /lin
authorFerry Huberts <ferry.huberts@pelagic.nl>
Fri, 19 Feb 2016 12:48:48 +0000 (13:48 +0100)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Fri, 19 Feb 2016 17:00:10 +0000 (18:00 +0100)
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
lib/txtinfo/src/olsrd_txtinfo.c

index eb07d29..3db57f2 100644 (file)
@@ -152,31 +152,38 @@ void ipc_print_neighbors(struct autobuf *abuf) {
 }
 
 void ipc_print_links(struct autobuf *abuf) {
-  struct ipaddr_str buf1, buf2;
-  struct lqtextbuffer lqbuffer1, lqbuffer2;
-
-  struct link_entry *my_link = NULL;
+  struct link_entry *my_link;
 
-  if (vtime)
+  if (vtime) {
     abuf_puts(abuf, "Table: Links\nLocal IP\tRemote IP\tVTime\tLQ\tNLQ\tCost\n");
-  else
+  } else {
     abuf_puts(abuf, "Table: Links\nLocal IP\tRemote IP\tHyst.\tLQ\tNLQ\tCost\n");
+  }
 
   /* Link set */
   OLSR_FOR_ALL_LINK_ENTRIES(my_link)
       {
+        struct ipaddr_str localAddr;
+        struct ipaddr_str remoteAddr;
+        struct lqtextbuffer lqbuffer;
+        struct lqtextbuffer costbuffer;
+
         if (vtime) {
           int diff = (unsigned int) (my_link->link_timer->timer_clock - now_times);
 
-          abuf_appendf(abuf, "%s\t%s\t%d.%03d\t%s\t%s\t\n", olsr_ip_to_string(&buf1, &my_link->local_iface_addr),
-              olsr_ip_to_string(&buf2, &my_link->neighbor_iface_addr),
-              diff / 1000, abs(diff % 1000),
-              get_link_entry_text(my_link, '\t', &lqbuffer1),
-              get_linkcost_text(my_link->linkcost, false, &lqbuffer2));
+          abuf_appendf(abuf, "%s\t%s\t%d.%03d\t%s\t%s\t\n",
+              olsr_ip_to_string(&localAddr, &my_link->local_iface_addr),
+              olsr_ip_to_string(&remoteAddr, &my_link->neighbor_iface_addr),
+              diff / 1000,
+              abs(diff % 1000),
+              get_link_entry_text(my_link, '\t', &lqbuffer),
+              get_linkcost_text(my_link->linkcost, false, &costbuffer));
         } else {
-          abuf_appendf(abuf, "%s\t%s\t0.00\t%s\t%s\t\n", olsr_ip_to_string(&buf1, &my_link->local_iface_addr),
-              olsr_ip_to_string(&buf2, &my_link->neighbor_iface_addr), get_link_entry_text(my_link, '\t', &lqbuffer1),
-              get_linkcost_text(my_link->linkcost, false, &lqbuffer2));
+          abuf_appendf(abuf, "%s\t%s\t0.00\t%s\t%s\t\n",
+              olsr_ip_to_string(&localAddr, &my_link->local_iface_addr),
+              olsr_ip_to_string(&remoteAddr, &my_link->neighbor_iface_addr),
+              get_link_entry_text(my_link, '\t', &lqbuffer),
+              get_linkcost_text(my_link->linkcost, false, &costbuffer));
         }
       }OLSR_FOR_ALL_LINK_ENTRIES_END(my_link);