projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added missing include of "collectd.h"
[collectd.git]
/
src
/
multimeter.c
diff --git
a/src/multimeter.c
b/src/multimeter.c
index
da1a8c8
..
fc69e02
100644
(file)
--- a/
src/multimeter.c
+++ b/
src/multimeter.c
@@
-27,8
+27,7
@@
#include "common.h"
#include "plugin.h"
#include "common.h"
#include "plugin.h"
-#if HAVE_TERMIOS_H && HAVE_SYS_IOCTL_H && HAVE_MATH_H
-#include <math.h>
+#if HAVE_TERMIOS_H && HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#include <termios.h>
#else
#include <sys/ioctl.h>
#include <termios.h>
#else
@@
-50,7
+49,7
@@
static int multimeter_read_value(double *value) {
char errbuf[1024];
ERROR("multimeter plugin: gettimeofday failed: %s",
sstrerror(errno, errbuf, sizeof(errbuf)));
char errbuf[1024];
ERROR("multimeter plugin: gettimeofday failed: %s",
sstrerror(errno, errbuf, sizeof(errbuf)));
- return
(-1)
;
+ return
-1
;
}
time_end.tv_sec++;
}
time_end.tv_sec++;
@@
-63,9
+62,9
@@
static int multimeter_read_value(double *value) {
struct timeval time_now;
status = swrite(fd, "D", 1);
struct timeval time_now;
status = swrite(fd, "D", 1);
- if (status
<
0) {
+ if (status
!=
0) {
ERROR("multimeter plugin: swrite failed.");
ERROR("multimeter plugin: swrite failed.");
- return
(-1)
;
+ return
-1
;
}
FD_ZERO(&rfds);
}
FD_ZERO(&rfds);
@@
-76,7
+75,7
@@
static int multimeter_read_value(double *value) {
ERROR("multimeter plugin: "
"gettimeofday failed: %s",
sstrerror(errno, errbuf, sizeof(errbuf)));
ERROR("multimeter plugin: "
"gettimeofday failed: %s",
sstrerror(errno, errbuf, sizeof(errbuf)));
- return
(-1)
;
+ return
-1
;
}
if (timeval_cmp(time_end, time_now, &timeout) < 0)
break;
}
if (timeval_cmp(time_end, time_now, &timeout) < 0)
break;
@@
-121,9
+120,9
@@
static int multimeter_read_value(double *value) {
break;
}
} else
break;
}
} else
- return
(-1)
; /* Overflow */
+ return
-1
; /* Overflow */
- return
(0)
; /* value received */
+ return
0
; /* value received */
} else
break;
} else if (!status) /* Timeout */
} else
break;
} else if (!status) /* Timeout */
@@
-142,7
+141,7
@@
static int multimeter_read_value(double *value) {
}
} while (--retry);
}
} while (--retry);
- return
(-2)
; /* no value received */
+ return
-2
; /* no value received */
} /* int multimeter_read_value */
static int multimeter_init(void) {
} /* int multimeter_read_value */
static int multimeter_init(void) {
@@
-174,25
+173,21
@@
static int multimeter_init(void) {
INFO("multimeter plugin: Device "
"found at %s",
device);
INFO("multimeter plugin: Device "
"found at %s",
device);
- return
(0)
;
+ return
0
;
}
}
}
ERROR("multimeter plugin: No device found");
}
}
}
ERROR("multimeter plugin: No device found");
- return
(-1)
;
+ return
-1
;
}
#undef LINE_LENGTH
static void multimeter_submit(double value) {
}
#undef LINE_LENGTH
static void multimeter_submit(double value) {
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
value_list_t vl = VALUE_LIST_INIT;
- values[0].gauge = value;
-
- vl.values = values;
+ vl.values = &(value_t){.gauge = value};
vl.values_len = 1;
vl.values_len = 1;
- sstrncpy(vl.host, hostname_g, sizeof(vl.host));
sstrncpy(vl.plugin, "multimeter", sizeof(vl.plugin));
sstrncpy(vl.type, "multimeter", sizeof(vl.type));
sstrncpy(vl.plugin, "multimeter", sizeof(vl.plugin));
sstrncpy(vl.type, "multimeter", sizeof(vl.type));
@@
-203,13
+198,13
@@
static int multimeter_read(void) {
double value;
if (fd < 0)
double value;
if (fd < 0)
- return
(-1)
;
+ return
-1
;
if (multimeter_read_value(&value) != 0)
if (multimeter_read_value(&value) != 0)
- return
(-1)
;
+ return
-1
;
multimeter_submit(value);
multimeter_submit(value);
- return
(0)
;
+ return
0
;
} /* int multimeter_read */
static int multimeter_shutdown(void) {
} /* int multimeter_read */
static int multimeter_shutdown(void) {
@@
-218,7
+213,7
@@
static int multimeter_shutdown(void) {
fd = -1;
}
fd = -1;
}
- return
(0)
;
+ return
0
;
}
void module_register(void) {
}
void module_register(void) {