Remove variables never used

This commit is contained in:
Micke Prag 2012-11-08 10:13:59 +01:00
parent c3bcd64246
commit fd8fdfcacd
3 changed files with 12 additions and 16 deletions

View file

@ -47,7 +47,6 @@ void ConnectionListener::run() {
SOCKET_T serverSocket; SOCKET_T serverSocket;
struct sockaddr_un name; struct sockaddr_un name;
socklen_t len;
serverSocket = socket(PF_LOCAL, SOCK_STREAM, 0); serverSocket = socket(PF_LOCAL, SOCK_STREAM, 0);
if (serverSocket < 0) { if (serverSocket < 0) {
return; return;
@ -62,7 +61,6 @@ void ConnectionListener::run() {
// Change permissions to allow everyone // Change permissions to allow everyone
chmod(d->name.c_str(), S_IRWXU | S_IRWXG | S_IRWXO); chmod(d->name.c_str(), S_IRWXU | S_IRWXG | S_IRWXO);
len = sizeof(struct sockaddr_un);
fd_set infds; fd_set infds;
FD_ZERO(&infds); FD_ZERO(&infds);

View file

@ -74,7 +74,6 @@ void ControllerListener::run() {
void ControllerListener::PrivateData::addUsbFilter(int vid, int pid) { void ControllerListener::PrivateData::addUsbFilter(int vid, int pid) {
CFNumberRef numberRef; CFNumberRef numberRef;
kern_return_t kr;
CFMutableDictionaryRef matchingDict; CFMutableDictionaryRef matchingDict;
matchingDict = IOServiceMatching(kIOUSBDeviceClassName); // Interested in instances of class matchingDict = IOServiceMatching(kIOUSBDeviceClassName); // Interested in instances of class
@ -94,19 +93,18 @@ void ControllerListener::PrivateData::addUsbFilter(int vid, int pid) {
CFRelease(numberRef); CFRelease(numberRef);
// Now set up a notification to be called when a device is first matched by I/O Kit. // Now set up a notification to be called when a device is first matched by I/O Kit.
kr = IOServiceAddMatchingNotification(gNotifyPort, // notifyPort IOServiceAddMatchingNotification(gNotifyPort, // notifyPort
kIOFirstMatchNotification, // notificationType kIOFirstMatchNotification, // notificationType
matchingDict, // matching matchingDict, // matching
PrivateData::DeviceAdded, // callback PrivateData::DeviceAdded, // callback
this, // refCon this, // refCon
&gAddedIter // notification &gAddedIter // notification
); );
// Iterate once to get already-present devices and arm the notification // Iterate once to get already-present devices and arm the notification
PrivateData::DeviceAdded(this, gAddedIter); PrivateData::DeviceAdded(this, gAddedIter);
} }
void ControllerListener::PrivateData::DeviceNotification(void *refCon, io_service_t service, natural_t messageType, void *messageArgument) { void ControllerListener::PrivateData::DeviceNotification(void *refCon, io_service_t service, natural_t messageType, void *messageArgument) {
kern_return_t kr;
if (messageType != kIOMessageServiceIsTerminated) { if (messageType != kIOMessageServiceIsTerminated) {
return; return;
@ -132,14 +130,13 @@ void ControllerListener::PrivateData::DeviceNotification(void *refCon, io_servic
// Free the data we're no longer using now that the device is going away // Free the data we're no longer using now that the device is going away
CFRelease(tsd->serialNumber); CFRelease(tsd->serialNumber);
kr = IOObjectRelease(tsd->notification); IOObjectRelease(tsd->notification);
delete tsd; delete tsd;
} }
void ControllerListener::PrivateData::DeviceAdded(void *refCon, io_iterator_t iterator) { void ControllerListener::PrivateData::DeviceAdded(void *refCon, io_iterator_t iterator) {
io_service_t usbDevice; io_service_t usbDevice;
kern_return_t kr;
PrivateData *pd = reinterpret_cast<PrivateData*> (refCon); PrivateData *pd = reinterpret_cast<PrivateData*> (refCon);
@ -172,7 +169,7 @@ void ControllerListener::PrivateData::DeviceAdded(void *refCon, io_iterator_t it
// Register for an interest notification of this device being removed. Use a reference to our // Register for an interest notification of this device being removed. Use a reference to our
// private data as the refCon which will be passed to the notification callback. // private data as the refCon which will be passed to the notification callback.
kr = IOServiceAddInterestNotification(pd->gNotifyPort, usbDevice, kIOGeneralInterest, DeviceNotification, tsd, &(tsd->notification)); IOServiceAddInterestNotification(pd->gNotifyPort, usbDevice, kIOGeneralInterest, DeviceNotification, tsd, &(tsd->notification));
CFIndex size = CFStringGetLength(serialNumberAsCFString); CFIndex size = CFStringGetLength(serialNumberAsCFString);
char *s = new char[size+1]; char *s = new char[size+1];
@ -180,7 +177,7 @@ void ControllerListener::PrivateData::DeviceAdded(void *refCon, io_iterator_t it
std::string serial(s); // Copy the string to the stack std::string serial(s); // Copy the string to the stack
delete[] s; delete[] s;
kr = IOObjectRelease(usbDevice); IOObjectRelease(usbDevice);
ControllerChangeEventData *data = new ControllerChangeEventData; ControllerChangeEventData *data = new ControllerChangeEventData;
data->vid = tsd->vid; data->vid = tsd->vid;

View file

@ -97,7 +97,8 @@ void Timer::run() {
pthread_mutex_unlock(&d->waitMutex); pthread_mutex_unlock(&d->waitMutex);
while(1) { while(1) {
int rc = gettimeofday(&tp, NULL); int rc = 0;
gettimeofday(&tp, NULL);
ts.tv_sec = tp.tv_sec; ts.tv_sec = tp.tv_sec;
ts.tv_nsec = tp.tv_usec * 1000; ts.tv_nsec = tp.tv_usec * 1000;