multimeter plugin: Check the return value of `write'.
authorFlorian Forster <octo@leeloo.lan.home.verplant.org>
Mon, 24 Nov 2008 18:23:25 +0000 (19:23 +0100)
committerFlorian Forster <octo@leeloo.lan.home.verplant.org>
Mon, 24 Nov 2008 18:23:25 +0000 (19:23 +0100)
This resolves warnings when compiling on GNU with:
  CPPFLAGS="-D_FORTIFY_SOURCE"

src/multimeter.c

index c6b070a..db35746 100644 (file)
@@ -86,7 +86,12 @@ static int multimeter_read_value(double *value)
                        struct timeval timeout;
                        struct timeval time_now;
 
-                       write(fd, "D", 1);
+                       status = swrite (fd, "D", 1);
+                       if (status < 0)
+                       {
+                               ERROR ("multimeter plugin: swrite failed.");
+                               return (-1);
+                       }
 
                        FD_ZERO(&rfds);
                        FD_SET(fd, &rfds);