projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
processes plugin: Fix error message.
[collectd.git]
/
src
/
ntpd.c
diff --git
a/src/ntpd.c
b/src/ntpd.c
index
68ac3a7
..
39bbeeb
100644
(file)
--- a/
src/ntpd.c
+++ b/
src/ntpd.c
@@
-267,7
+267,7
@@
static int ntpd_config(const char *key, const char *value) {
} else if (strcasecmp(key, "Port") == 0) {
int port = (int)(atof(value));
if ((port > 0) && (port <= 65535))
} else if (strcasecmp(key, "Port") == 0) {
int port = (int)(atof(value));
if ((port > 0) && (port <= 65535))
- s
s
nprintf(ntpd_port, sizeof(ntpd_port), "%i", port);
+ snprintf(ntpd_port, sizeof(ntpd_port), "%i", port);
else
sstrncpy(ntpd_port, value, sizeof(ntpd_port));
} else if (strcasecmp(key, "ReverseLookups") == 0) {
else
sstrncpy(ntpd_port, value, sizeof(ntpd_port));
} else if (strcasecmp(key, "ReverseLookups") == 0) {
@@
-337,10
+337,8
@@
static int ntpd_connect(void) {
.ai_socktype = SOCK_DGRAM};
if ((status = getaddrinfo(host, port, &ai_hints, &ai_list)) != 0) {
.ai_socktype = SOCK_DGRAM};
if ((status = getaddrinfo(host, port, &ai_hints, &ai_list)) != 0) {
- char errbuf[1024];
ERROR("ntpd plugin: getaddrinfo (%s, %s): %s", host, port,
ERROR("ntpd plugin: getaddrinfo (%s, %s): %s", host, port,
- (status == EAI_SYSTEM) ? sstrerror(errno, errbuf, sizeof(errbuf))
- : gai_strerror(status));
+ (status == EAI_SYSTEM) ? STRERRNO : gai_strerror(status));
return -1;
}
return -1;
}
@@
-409,9
+407,7
@@
static int ntpd_receive_response(int *res_items, int *res_size, char **res_data,
*res_data = NULL;
if (gettimeofday(&time_end, NULL) < 0) {
*res_data = NULL;
if (gettimeofday(&time_end, NULL) < 0) {
- char errbuf[1024];
- ERROR("ntpd plugin: gettimeofday failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("ntpd plugin: gettimeofday failed: %s", STRERRNO);
return -1;
}
time_end.tv_sec++; /* wait for a most one second */
return -1;
}
time_end.tv_sec++; /* wait for a most one second */
@@
-421,9
+417,7
@@
static int ntpd_receive_response(int *res_items, int *res_size, char **res_data,
struct timeval time_left;
if (gettimeofday(&time_now, NULL) < 0) {
struct timeval time_left;
if (gettimeofday(&time_now, NULL) < 0) {
- char errbuf[1024];
- ERROR("ntpd plugin: gettimeofday failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("ntpd plugin: gettimeofday failed: %s", STRERRNO);
return -1;
}
return -1;
}
@@
-447,9
+441,7
@@
static int ntpd_receive_response(int *res_items, int *res_size, char **res_data,
continue;
if (status < 0) {
continue;
if (status < 0) {
- char errbuf[1024];
- ERROR("ntpd plugin: poll failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("ntpd plugin: poll failed: %s", STRERRNO);
return -1;
}
return -1;
}
@@
-466,8
+458,7
@@
static int ntpd_receive_response(int *res_items, int *res_size, char **res_data,
continue;
if (status < 0) {
continue;
if (status < 0) {
- char errbuf[1024];
- INFO("recv(2) failed: %s", sstrerror(errno, errbuf, sizeof(errbuf)));
+ INFO("recv(2) failed: %s", STRERRNO);
DEBUG("Closing socket #%i", sd);
close(sd);
sock_descr = sd = -1;
DEBUG("Closing socket #%i", sd);
close(sd);
sock_descr = sd = -1;
@@
-669,7
+660,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);
(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;
DEBUG("`swrite' failed. Closing socket #%i", sd);
close(sd);
sock_descr = sd = -1;
@@
-763,10
+754,8
@@
static int ntpd_get_name_from_address(char *buffer, size_t buffer_size,
buffer_size, NULL, 0, /* No port name */
flags);
if (status != 0) {
buffer_size, NULL, 0, /* No port name */
flags);
if (status != 0) {
- char errbuf[1024];
ERROR("ntpd plugin: getnameinfo failed: %s",
ERROR("ntpd plugin: getnameinfo failed: %s",
- (status == EAI_SYSTEM) ? sstrerror(errno, errbuf, sizeof(errbuf))
- : gai_strerror(status));
+ (status == EAI_SYSTEM) ? STRERRNO : gai_strerror(status));
return -1;
}
return -1;
}
@@
-782,8
+771,8
@@
static int ntpd_get_name_refclock(char *buffer, size_t buffer_size,
return ntpd_get_name_from_address(buffer, buffer_size, peer_info, 0);
if (include_unit_id)
return ntpd_get_name_from_address(buffer, buffer_size, peer_info, 0);
if (include_unit_id)
- s
s
nprintf(buffer, buffer_size, "%s-%" PRIu32, refclock_names[refclock_id],
-
unit_id);
+ snprintf(buffer, buffer_size, "%s-%" PRIu32, refclock_names[refclock_id],
+ unit_id);
else
sstrncpy(buffer, refclock_names[refclock_id], buffer_size);
else
sstrncpy(buffer, refclock_names[refclock_id], buffer_size);
@@
-846,9
+835,9
@@
static int ntpd_read(void) {
}
/* kerninfo -> estimated error */
}
/* 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);
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"
DEBUG("info_kernel:\n"
" pll offset = %.8g\n"