]> git.ipfire.org Git - thirdparty/mtr.git/commitdiff
display: avoid unnecessary switch case clauses
authorSami Kerola <kerolasa@iki.fi>
Sat, 8 Oct 2016 10:28:57 +0000 (11:28 +0100)
committerSami Kerola <kerolasa@iki.fi>
Tue, 11 Oct 2016 18:29:20 +0000 (19:29 +0100)
These functions are shorter, and more simple, with if clause.

display.c

index ed59a7e901f713ec16ea9599a6cebe53defdf77b..d3c95c5a39131479053e00e68f97992263082c07 100644 (file)
--- a/display.c
+++ b/display.c
@@ -190,104 +190,40 @@ extern int display_keyaction(struct mtr_ctl *ctl)
 
 extern void display_rawxmit(struct mtr_ctl *ctl, int host, int seq)
 {
-  switch(ctl->DisplayMode) {
-  case DisplayRaw:
+  if (ctl->DisplayMode == DisplayRaw)
     raw_rawxmit (host, seq);
-    break;
-  }
 }
 
 
 extern void display_rawping(struct mtr_ctl *ctl, int host, int msec, int seq)
 {
-  switch(ctl->DisplayMode) {
-  case DisplayReport:
-  case DisplayTXT:
-  case DisplayJSON:
-  case DisplayXML:
-  case DisplayCSV:
-  case DisplaySplit:
-#ifdef HAVE_NCURSES
-  case DisplayCurses:
-#endif
-#ifdef HAVE_GTK
-  case DisplayGTK:
-#endif
-    break;
-  case DisplayRaw:
+  if (ctl->DisplayMode == DisplayRaw)
     raw_rawping (ctl, host, msec, seq);
-    break;
-  }
 }
 
 
 extern void display_rawhost(struct mtr_ctl *ctl, int host, ip_t *ip_addr)
 {
-  switch(ctl->DisplayMode) {
-  case DisplayReport:
-  case DisplayTXT:
-  case DisplayJSON:
-  case DisplayXML:
-  case DisplayCSV:
-  case DisplaySplit:
-#ifdef HAVE_NCURSES
-  case DisplayCurses:
-#endif
-#ifdef HAVE_GTK
-  case DisplayGTK:
-#endif
-    break;
-  case DisplayRaw:
+  if (ctl->DisplayMode == DisplayRaw)
     raw_rawhost (ctl, host, ip_addr);
-    break;
-  }
 }
 
 
 extern void display_loop(struct mtr_ctl *ctl)
 {
-  switch(ctl->DisplayMode) {
-  case DisplayReport:
-  case DisplayTXT:
-  case DisplayJSON:
-  case DisplayXML:
-  case DisplayCSV:
-  case DisplaySplit:
-#ifdef HAVE_NCURSES
-  case DisplayCurses:
-#endif
-  case DisplayRaw:
-    select_loop(ctl);
-    break;
 #ifdef HAVE_GTK
-  case DisplayGTK:
+  if (ctl->DisplayMode == DisplayGTK)
     gtk_loop(ctl);
-    break;
+  else
 #endif
-  }
+    select_loop(ctl);
 }
 
 
 extern void display_clear(struct mtr_ctl *ctl)
 {
-  switch(ctl->DisplayMode) {
 #ifdef HAVE_NCURSES
-  case DisplayCurses:
+  if (ctl->DisplayMode == DisplayCurses)
     mtr_curses_clear(ctl);
-    break;
-#endif
-  case DisplayReport:
-  case DisplayTXT:
-  case DisplayJSON:
-  case DisplayXML:
-  case DisplayCSV:
-  case DisplaySplit:
-  case DisplayRaw:
-    break;
-
-#ifdef HAVE_GTK
-  case DisplayGTK:
-    break;
 #endif
-  }
 }