From aac111dc76bb0c1a539bfb6632045c31da7ac861 Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Thu, 10 Mar 2011 08:21:44 +0000 Subject: [PATCH] Initialize ffd to -1 in the constructor otherwise many checks may fail afterwards, and BJoystick won't work. Also reset it to -1 in the destructor for symmetry. Found by Carwyn Jones. Thanks! git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40900 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/device/Joystick.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/kits/device/Joystick.cpp b/src/kits/device/Joystick.cpp index e9d338a73e..88d60cc6f4 100644 --- a/src/kits/device/Joystick.cpp +++ b/src/kits/device/Joystick.cpp @@ -49,6 +49,7 @@ LOG(const char *fmt, ...) BJoystick::BJoystick() : fBeBoxMode(false), + ffd(-1), fDevices(new BList), fJoystickInfo(new _joystick_info()) { @@ -61,8 +62,10 @@ BJoystick::BJoystick() BJoystick::~BJoystick() { - if (ffd >= 0) + if (ffd >= 0) { close(ffd); + ffd = -1; + } for (int32 count = fDevices->CountItems() - 1; count >= 0; count--) { free(fDevices->RemoveItem(count)); @@ -132,17 +135,18 @@ void BJoystick::Close(void) { CALLED(); - if (ffd >= 0) + if (ffd >= 0) { close(ffd); - ffd = -1; + ffd = -1; + } } void -BJoystick::ScanDevices(bool use_disabled) +BJoystick::ScanDevices(bool useDisabled) { CALLED(); - if (use_disabled) { + if (useDisabled) { _BJoystickTweaker temp(*this); temp.scan_including_disabled(); } @@ -228,6 +232,7 @@ BJoystick::CountButtons() return fJoystickInfo->num_buttons; } + status_t BJoystick::GetControllerModule(BString *out_name) {