aboutsummaryrefslogtreecommitdiff
path: root/nxcomp
diff options
context:
space:
mode:
authorUlrich Sibiller <uli42@gmx.de>2017-12-27 13:09:25 +0100
committerUlrich Sibiller <uli42@gmx.de>2017-12-29 02:31:26 +0100
commit3066195d79f5f24f99483d29e2489a91c9251d73 (patch)
tree3b06657c1be02d35f0fad3396549ccdf4c4f0e5b /nxcomp
parentc31c54c1b65080b7e68942e8b50dc88b5ce1279b (diff)
downloadnx-libs-3066195d79f5f24f99483d29e2489a91c9251d73.tar.gz
nx-libs-3066195d79f5f24f99483d29e2489a91c9251d73.tar.bz2
nx-libs-3066195d79f5f24f99483d29e2489a91c9251d73.zip
Loop.cpp: some reformatting/simplification/FIXMEs
(partially) fixes ArcticaProject/nx-libs#612
Diffstat (limited to 'nxcomp')
-rw-r--r--nxcomp/src/Loop.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/nxcomp/src/Loop.cpp b/nxcomp/src/Loop.cpp
index e84896e36..e922b55a5 100644
--- a/nxcomp/src/Loop.cpp
+++ b/nxcomp/src/Loop.cpp
@@ -3861,7 +3861,8 @@ void SetupDisplaySocket(int &addr_family, sockaddr *&addr,
#ifdef __APPLE__
- if ((strncasecmp(display, "/tmp/launch", 11) == 0) || (strncasecmp(display, "/private/tmp/com.apple.launchd", 30) == 0))
+ if ((strncasecmp(display, "/tmp/launch", 11) == 0) ||
+ (strncasecmp(display, "/private/tmp/com.apple.launchd", 30) == 0))
{
nxinfo << "Loop: Using launchd service on socket '"
<< display << "'.\n" << std::flush;
@@ -3934,19 +3935,24 @@ void SetupDisplaySocket(int &addr_family, sockaddr *&addr,
// fall back to Unix domain socket file.
#ifdef __linux__
- int testSocketFD;
- testSocketFD = socket(addr_family, SOCK_STREAM, PF_UNSPEC);
+ int testSocketFD = socket(addr_family, SOCK_STREAM, PF_UNSPEC);
+ // this name cannot be changed as it is defined this way by the
+ // local X server
int len = sprintf(unixSocketName + 1, "/tmp/.X11-unix/X%d", xPort);
unixSocketName[0] = '\0';
sockaddr_un *xServerAddrABSTRACT = new sockaddr_un;
memset(xServerAddrABSTRACT, 0, sizeof(struct sockaddr_un));
xServerAddrABSTRACT -> sun_family = AF_UNIX;
+ // FIXME: ensure sun_path can hold len+1 bytes!
memcpy(xServerAddrABSTRACT -> sun_path, unixSocketName, len+1);
- addr_length = len +3;
+ // FIXME: comment why + 3?
+ addr_length = len + 3;
- int ret = connect(testSocketFD, (struct sockaddr *) xServerAddrABSTRACT, addr_length);
+ int ret = connect(testSocketFD,
+ (struct sockaddr *) xServerAddrABSTRACT,
+ addr_length);
close(testSocketFD);
if (ret == 0) {