[PATCH libevdev 2/3] tools: shut up coverity about a potential close(-1)

Peter Hutterer peter.hutterer at who-t.net
Mon Dec 21 16:01:14 PST 2015


Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 tools/libevdev-tweak-device.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/libevdev-tweak-device.c b/tools/libevdev-tweak-device.c
index 4be2d6f..bdc16e6 100644
--- a/tools/libevdev-tweak-device.c
+++ b/tools/libevdev-tweak-device.c
@@ -376,7 +376,8 @@ main(int argc, char **argv)
 	int led = -1;
 	int led_state = -1;
 	unsigned int changes = 0; /* bitmask of changes */
-	int xres, yres;
+	int xres = 0,
+	    yres =0;
 
 	mode = parse_options_mode(argc, argv, &path);
 	switch (mode) {
@@ -434,7 +435,8 @@ main(int argc, char **argv)
 
 out:
 	libevdev_free(dev);
-	close(fd);
+	if (fd != -1)
+		close(fd);
 
 	return rc;
 }
-- 
2.5.0



More information about the Input-tools mailing list