Merge branch 'collectd-5.7' into collectd-5.8
[collectd.git] / src / ntpd.c
index fb41a7d..0faf2a2 100644 (file)
@@ -669,7 +669,7 @@ static int ntpd_send_request(int req_code, int req_items, int req_size,
         (void *)req_data);
 
   status = swrite(sd, (const char *)&req, REQ_LEN_NOMAC);
-  if (status < 0) {
+  if (status != 0) {
     DEBUG("`swrite' failed. Closing socket #%i", sd);
     close(sd);
     sock_descr = sd = -1;
@@ -783,7 +783,7 @@ static int ntpd_get_name_refclock(char *buffer, size_t buffer_size,
 
   if (include_unit_id)
     snprintf(buffer, buffer_size, "%s-%" PRIu32, refclock_names[refclock_id],
-              unit_id);
+             unit_id);
   else
     sstrncpy(buffer, refclock_names[refclock_id], buffer_size);
 
@@ -846,9 +846,9 @@ static int ntpd_read(void) {
   }
 
   /* kerninfo -> estimated error */
-  offset_loop = scale_loop * ((gauge_t)ntohl(ik->offset));
+  offset_loop = (gauge_t)((int32_t)ntohl(ik->offset) * scale_loop);
   freq_loop = ntpd_read_fp(ik->freq);
-  offset_error = scale_error * ((gauge_t)ntohl(ik->esterror));
+  offset_error = (gauge_t)((int32_t)ntohl(ik->esterror) * scale_error);
 
   DEBUG("info_kernel:\n"
         "  pll offset    = %.8g\n"