From: Ruben Kerkhof Date: Thu, 31 May 2018 15:14:44 +0000 (+0200) Subject: tcpconns plugin: fix implicit conversion warnings X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=99ddbf5989b80ae9eb8aea2a24b28c950d8e7977;p=collectd.git tcpconns plugin: fix implicit conversion warnings CC src/tcpconns.lo src/tcpconns.c:510:14: warning: implicit conversion loses integer precision: 'ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32] status = recvmsg(fd, (void *)&msg, /* flags = */ 0); ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/tcpconns.c:577:20: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32] int buffer_len = strlen(buffer); ~~~~~~~~~~ ^~~~~~~~~~~~~~ 2 warnings generated. --- diff --git a/src/tcpconns.c b/src/tcpconns.c index 90dedce4..5a3fd4ef 100644 --- a/src/tcpconns.c +++ b/src/tcpconns.c @@ -498,7 +498,6 @@ static int conn_read_netlink(void) { iov.iov_len = sizeof(buf); while (1) { - int status; struct nlmsghdr *h; memset(&msg, 0, sizeof(msg)); @@ -507,7 +506,7 @@ static int conn_read_netlink(void) { msg.msg_iov = &iov; msg.msg_iovlen = 1; - status = recvmsg(fd, (void *)&msg, /* flags = */ 0); + ssize_t status = recvmsg(fd, (void *)&msg, /* flags = */ 0); if (status < 0) { if ((errno == EINTR) || (errno == EAGAIN)) continue; @@ -574,11 +573,11 @@ static int conn_handle_line(char *buffer) { uint8_t state; - int buffer_len = strlen(buffer); + size_t buffer_len = strlen(buffer); while ((buffer_len > 0) && (buffer[buffer_len - 1] < 32)) buffer[--buffer_len] = '\0'; - if (buffer_len <= 0) + if (buffer_len == 0) return -1; fields_len = strsplit(buffer, fields, STATIC_ARRAY_SIZE(fields));