]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
sources: optimize SRC_ReportSource() a bit
authorMiroslav Lichvar <mlichvar@redhat.com>
Tue, 19 Jul 2016 13:57:16 +0000 (15:57 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Wed, 20 Jul 2016 07:34:11 +0000 (09:34 +0200)
Remove unnecessary memset() call and use the default case of the switch
to report the unreachable state.

sources.c

index 79f72cfe2d941b65a9c487190121a21c41614a29..e5627edc45b35233f2809f1755dfbfcb285c1a71 100644 (file)
--- a/sources.c
+++ b/sources.c
@@ -1294,7 +1294,6 @@ SRC_ReportSource(int index, RPT_SourceReport *report, struct timeval *now)
   } else {
     src = sources[index];
 
-    memset(&report->ip_addr, 0, sizeof (report->ip_addr));
     if (src->ip_addr)
       report->ip_addr = *src->ip_addr;
     else {
@@ -1304,14 +1303,6 @@ SRC_ReportSource(int index, RPT_SourceReport *report, struct timeval *now)
     }
 
     switch (src->status) {
-      case SRC_UNSELECTABLE:
-      case SRC_BAD_STATS:
-      case SRC_BAD_DISTANCE:
-      case SRC_STALE:
-      case SRC_ORPHAN:
-      case SRC_WAITS_STATS:
-        report->state = RPT_UNREACH;
-        break;
       case SRC_FALSETICKER:
         report->state = RPT_FALSETICKER;
         break;
@@ -1331,9 +1322,8 @@ SRC_ReportSource(int index, RPT_SourceReport *report, struct timeval *now)
       case SRC_SELECTED:
         report->state = RPT_SYNC;
         break;
-      case SRC_OK:
       default:
-        assert(0);
+        report->state = RPT_UNREACH;
         break;
     }