If open returns 0 we leak fd.
CID #38016
Signed-off-by: Florian Forster <octo@collectd.org>
for (i = 0; i < 10; i++)
{
- device[strlen(device)-1] = i + '0';
+ device[strlen(device)-1] = i + '0';
- if ((fd = open(device, O_RDWR | O_NOCTTY)) > 0)
+ if ((fd = open(device, O_RDWR | O_NOCTTY)) != -1)
{
struct termios tios;
int rts = TIOCM_RTS;
tcflush(fd, TCIFLUSH);
tcsetattr(fd, TCSANOW, &tios);
ioctl(fd, TIOCMBIC, &rts);
-
+
if (multimeter_read_value (&value) < -1)
{
close (fd);