X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fmultimeter.c;h=02fe1ad312f4be22a58982bb91f5ce033e29dd3f;hb=6fc6255c95b966014ee02a2a37666b2c4880ff8d;hp=03608e6cfe5e61110e13552f43f7fd8e5963c46c;hpb=b8913bc047474aa0a3bfbf03ecbb3b5050605ed1;p=collectd.git diff --git a/src/multimeter.c b/src/multimeter.c index 03608e6c..02fe1ad3 100644 --- a/src/multimeter.c +++ b/src/multimeter.c @@ -23,6 +23,7 @@ **/ #include "collectd.h" + #include "common.h" #include "plugin.h" @@ -148,22 +149,21 @@ static int multimeter_read_value(double *value) static int multimeter_init (void) { - int i; char device[] = "/dev/ttyS "; - for (i = 0; i < 10; i++) + for (int i = 0; i < 10; i++) { device[strlen(device)-1] = i + '0'; if ((fd = open(device, O_RDWR | O_NOCTTY)) != -1) { - struct termios tios; + struct termios tios = { 0 }; int rts = TIOCM_RTS; double value; tios.c_cflag = B1200 | CS7 | CSTOPB | CREAD | CLOCAL; tios.c_iflag = IGNBRK | IGNPAR; - tios.c_oflag = 0; + tios.c_oflag = 0; tios.c_lflag = 0; tios.c_cc[VTIME] = 3; tios.c_cc[VMIN] = LINE_LENGTH;