From 9c6449567d2dc6ce65b99fc1f9e94fc11cccc743 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 4 Aug 2009 22:01:28 +0000 Subject: [PATCH] Coding style. Fix a valgrind warning. Stop a close on a handle of -1. git-svn-id: svn://localhost/ardour2/branches/3.0@5493 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/surfaces/powermate/powermate.cc | 33 ++++++++++++++++------------ 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/libs/surfaces/powermate/powermate.cc b/libs/surfaces/powermate/powermate.cc index 96baf749b3..98dfcebae7 100644 --- a/libs/surfaces/powermate/powermate.cc +++ b/libs/surfaces/powermate/powermate.cc @@ -33,35 +33,41 @@ static const char *valid_prefix[NUM_VALID_PREFIXES] = { #define NUM_EVENT_DEVICES 16 -int open_powermate(const char *dev, int mode) +int open_powermate (const char *dev, int mode) { if (!Glib::file_test (dev, Glib::FILE_TEST_EXISTS)) { return -1; } + int fd = open(dev, mode); int i; char name[255]; - if(fd < 0){ + if (fd < 0) { if (errno != EACCES) { error << string_compose ("Unable to open \"%1\": %2", dev, strerror(errno)) << endmsg; } return -1; } - if(ioctl(fd, EVIOCGNAME(sizeof(name)), name) < 0){ - error << string_compose ("\"%1\": EVIOCGNAME failed: %2", dev, strerror(errno)) << endmsg; - close(fd); - return -1; - } + /* placate valgrind */ + name[0] = '\0'; - // it's the correct device if the prefix matches what we expect it to be: - for(i=0; i