projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request #1856 from rubenk/snmp-dont-dispatch-values-with-empty-type-instance
[collectd.git]
/
src
/
hddtemp.c
diff --git
a/src/hddtemp.c
b/src/hddtemp.c
index
c32aa35
..
8213e97
100644
(file)
--- a/
src/hddtemp.c
+++ b/
src/hddtemp.c
@@
-30,6
+30,7
@@
**/
#include "collectd.h"
**/
#include "collectd.h"
+
#include "common.h"
#include "plugin.h"
#include "configfile.h"
#include "common.h"
#include "plugin.h"
#include "configfile.h"
@@
-88,17
+89,9
@@
static int hddtemp_query_daemon (char *buffer, int buffer_size)
const char *host;
const char *port;
const char *host;
const char *port;
- struct addrinfo ai_hints = { 0 };
- struct addrinfo *ai_list, *ai_ptr;
+ struct addrinfo *ai_list;
int ai_return;
int ai_return;
-#ifdef AI_ADDRCONFIG
- ai_hints.ai_flags |= AI_ADDRCONFIG;
-#endif
- ai_hints.ai_family = PF_UNSPEC;
- ai_hints.ai_socktype = SOCK_STREAM;
- ai_hints.ai_protocol = IPPROTO_TCP;
-
host = hddtemp_host;
if (host == NULL)
host = HDDTEMP_DEF_HOST;
host = hddtemp_host;
if (host == NULL)
host = HDDTEMP_DEF_HOST;
@@
-107,6
+100,13
@@
static int hddtemp_query_daemon (char *buffer, int buffer_size)
if (strlen (port) == 0)
port = HDDTEMP_DEF_PORT;
if (strlen (port) == 0)
port = HDDTEMP_DEF_PORT;
+ struct addrinfo ai_hints = {
+ .ai_flags = AI_ADDRCONFIG,
+ .ai_family = AF_UNSPEC,
+ .ai_protocol = IPPROTO_TCP,
+ .ai_socktype = SOCK_STREAM
+ };
+
if ((ai_return = getaddrinfo (host, port, &ai_hints, &ai_list)) != 0)
{
char errbuf[1024];
if ((ai_return = getaddrinfo (host, port, &ai_hints, &ai_list)) != 0)
{
char errbuf[1024];
@@
-119,7
+119,7
@@
static int hddtemp_query_daemon (char *buffer, int buffer_size)
}
fd = -1;
}
fd = -1;
- for (ai_ptr = ai_list; ai_ptr != NULL; ai_ptr = ai_ptr->ai_next)
+ for (
struct addrinfo *
ai_ptr = ai_list; ai_ptr != NULL; ai_ptr = ai_ptr->ai_next)
{
/* create our socket descriptor */
fd = socket (ai_ptr->ai_family, ai_ptr->ai_socktype,
{
/* create our socket descriptor */
fd = socket (ai_ptr->ai_family, ai_ptr->ai_socktype,
@@
-250,7
+250,6
@@
static int hddtemp_read (void)
char *saveptr;
int num_fields;
int num_disks;
char *saveptr;
int num_fields;
int num_disks;
- int i;
/* get data from daemon */
if (hddtemp_query_daemon (buf, sizeof (buf)) < 0)
/* get data from daemon */
if (hddtemp_query_daemon (buf, sizeof (buf)) < 0)
@@
-271,7
+270,7
@@
static int hddtemp_read (void)
num_disks = num_fields / 4;
num_disks = num_fields / 4;
- for (i = 0; i < num_disks; i++)
+ for (i
nt i
= 0; i < num_disks; i++)
{
char *name;
double temperature;
{
char *name;
double temperature;