From 9d3d7daaac986e13b8055f89cec80e81c347f972 Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Mon, 27 Aug 2018 11:09:17 +0300 Subject: [PATCH] fixed bug in proto_unix: the listening socket was initialized to 0 instead of -1, and a few conditions tested if it's 0 to determine if it has been opened, instead of testing it it's not -1. --- src/proto_unix.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/proto_unix.c b/src/proto_unix.c index 1c3ec15..66335d7 100644 --- a/src/proto_unix.c +++ b/src/proto_unix.c @@ -1,6 +1,6 @@ /* spacenavd - a free software replacement driver for 6dof space-mice. -Copyright (C) 2007-2010 John Tsiombikas +Copyright (C) 2007-2018 John Tsiombikas This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -34,7 +34,7 @@ enum { UEV_TYPE_RELEASE }; -static int lsock; +static int lsock = -1; int init_unix(void) { @@ -42,7 +42,7 @@ int init_unix(void) mode_t prev_umask; struct sockaddr_un addr; - if(lsock) return 0; + if(lsock >= 0) return 0; if((s = socket(PF_UNIX, SOCK_STREAM, 0)) == -1) { perror("failed to create socket"); @@ -93,7 +93,7 @@ void send_uevent(spnav_event *ev, struct client *c) int i, data[8] = {0}; float motion_mul; - if(!lsock) return; + if(lsock == -1) return; switch(ev->type) { case EVENT_MOTION: