aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2024-06-24 14:35:43 +0200
committerPierre Ossman <ossman@cendio.se>2024-06-24 14:35:43 +0200
commit1b6d5594e34bf3c96e225eab794943dc1ce6b1de (patch)
tree3088799b3e595f2e062e258c515d97970b00402b
parent0e9a00e87cf12087b253e0be214c7a7a045c94de (diff)
parent02c6a1bf7ec18701a0f1a44bec20fc383b8f3565 (diff)
downloadtigervnc-1b6d5594e34bf3c96e225eab794943dc1ce6b1de.tar.gz
tigervnc-1b6d5594e34bf3c96e225eab794943dc1ce6b1de.zip
Merge branch 'c++11' of github.com:CendioOssman/tigervnc
-rw-r--r--CMakeLists.txt14
-rw-r--r--common/network/Socket.cxx14
-rw-r--r--common/network/TcpSocket.cxx48
-rw-r--r--common/network/TcpSocket.h10
-rw-r--r--common/network/UnixSocket.cxx4
-rw-r--r--common/network/UnixSocket.h8
-rw-r--r--common/os/Mutex.cxx8
-rw-r--r--common/os/Thread.cxx16
-rw-r--r--common/os/os.cxx24
-rw-r--r--common/rdr/AESInStream.cxx12
-rw-r--r--common/rdr/AESInStream.h2
-rw-r--r--common/rdr/AESOutStream.h6
-rw-r--r--common/rdr/BufferedInStream.cxx8
-rw-r--r--common/rdr/BufferedInStream.h4
-rw-r--r--common/rdr/BufferedOutStream.cxx12
-rw-r--r--common/rdr/BufferedOutStream.h6
-rw-r--r--common/rdr/Exception.cxx10
-rw-r--r--common/rdr/Exception.h2
-rw-r--r--common/rdr/FdInStream.cxx2
-rw-r--r--common/rdr/FdInStream.h2
-rw-r--r--common/rdr/FdOutStream.cxx6
-rw-r--r--common/rdr/FdOutStream.h4
-rw-r--r--common/rdr/FileInStream.cxx2
-rw-r--r--common/rdr/FileInStream.h2
-rw-r--r--common/rdr/HexInStream.h2
-rw-r--r--common/rdr/HexOutStream.h6
-rw-r--r--common/rdr/InStream.h12
-rw-r--r--common/rdr/MemInStream.h4
-rw-r--r--common/rdr/MemOutStream.h4
-rw-r--r--common/rdr/OutStream.h2
-rw-r--r--common/rdr/RandomStream.cxx8
-rw-r--r--common/rdr/RandomStream.h2
-rw-r--r--common/rdr/TLSInStream.cxx6
-rw-r--r--common/rdr/TLSInStream.h2
-rw-r--r--common/rdr/TLSOutStream.cxx6
-rw-r--r--common/rdr/TLSOutStream.h6
-rw-r--r--common/rdr/ZlibInStream.cxx22
-rw-r--r--common/rdr/ZlibInStream.h2
-rw-r--r--common/rdr/ZlibOutStream.cxx12
-rw-r--r--common/rdr/ZlibOutStream.h8
-rw-r--r--common/rfb/Blacklist.cxx2
-rw-r--r--common/rfb/CConnection.cxx54
-rw-r--r--common/rfb/CConnection.h44
-rw-r--r--common/rfb/CMsgReader.cxx14
-rw-r--r--common/rfb/CMsgWriter.cxx7
-rw-r--r--common/rfb/CSecurityDH.cxx4
-rw-r--r--common/rfb/CSecurityDH.h6
-rw-r--r--common/rfb/CSecurityMSLogonII.cxx4
-rw-r--r--common/rfb/CSecurityMSLogonII.h6
-rw-r--r--common/rfb/CSecurityNone.h6
-rw-r--r--common/rfb/CSecurityPlain.h6
-rw-r--r--common/rfb/CSecurityRSAAES.cxx23
-rw-r--r--common/rfb/CSecurityRSAAES.h6
-rw-r--r--common/rfb/CSecurityStack.cxx4
-rw-r--r--common/rfb/CSecurityStack.h8
-rw-r--r--common/rfb/CSecurityTLS.cxx39
-rw-r--r--common/rfb/CSecurityTLS.h6
-rw-r--r--common/rfb/CSecurityVeNCrypt.cxx26
-rw-r--r--common/rfb/CSecurityVeNCrypt.h6
-rw-r--r--common/rfb/CSecurityVncAuth.cxx2
-rw-r--r--common/rfb/CSecurityVncAuth.h6
-rw-r--r--common/rfb/ClientParams.cxx2
-rw-r--r--common/rfb/Configuration.cxx23
-rw-r--r--common/rfb/Configuration.h47
-rw-r--r--common/rfb/Congestion.cxx22
-rw-r--r--common/rfb/CopyRectDecoder.h17
-rw-r--r--common/rfb/Cursor.cxx6
-rw-r--r--common/rfb/Cursor.h2
-rw-r--r--common/rfb/DecodeManager.cxx58
-rw-r--r--common/rfb/DecodeManager.h2
-rw-r--r--common/rfb/Decoder.cxx4
-rw-r--r--common/rfb/EncodeManager.cxx10
-rw-r--r--common/rfb/EncodeManager.h4
-rw-r--r--common/rfb/H264Decoder.cxx24
-rw-r--r--common/rfb/H264Decoder.h11
-rw-r--r--common/rfb/H264LibavDecoderContext.cxx14
-rw-r--r--common/rfb/H264LibavDecoderContext.h8
-rw-r--r--common/rfb/H264WinDecoderContext.cxx40
-rw-r--r--common/rfb/H264WinDecoderContext.h24
-rw-r--r--common/rfb/HextileDecoder.cxx4
-rw-r--r--common/rfb/HextileDecoder.h11
-rw-r--r--common/rfb/HextileEncoder.cxx6
-rw-r--r--common/rfb/HextileEncoder.h10
-rw-r--r--common/rfb/Hostname.h16
-rw-r--r--common/rfb/JpegCompressor.cxx4
-rw-r--r--common/rfb/JpegDecompressor.cxx4
-rw-r--r--common/rfb/KeyRemapper.cxx2
-rw-r--r--common/rfb/LogWriter.cxx7
-rw-r--r--common/rfb/LogWriter.h2
-rw-r--r--common/rfb/Logger.cxx8
-rw-r--r--common/rfb/Logger_file.cxx6
-rw-r--r--common/rfb/Logger_file.h2
-rw-r--r--common/rfb/Logger_syslog.cxx2
-rw-r--r--common/rfb/Logger_syslog.h2
-rw-r--r--common/rfb/Palette.h10
-rw-r--r--common/rfb/PixelBuffer.cxx10
-rw-r--r--common/rfb/PixelBuffer.h10
-rw-r--r--common/rfb/RREDecoder.h11
-rw-r--r--common/rfb/RREEncoder.cxx4
-rw-r--r--common/rfb/RREEncoder.h10
-rw-r--r--common/rfb/RawDecoder.h11
-rw-r--r--common/rfb/RawEncoder.cxx4
-rw-r--r--common/rfb/RawEncoder.h10
-rw-r--r--common/rfb/SConnection.cxx27
-rw-r--r--common/rfb/SConnection.h31
-rw-r--r--common/rfb/SDesktop.h16
-rw-r--r--common/rfb/SMsgReader.cxx2
-rw-r--r--common/rfb/SMsgWriter.cxx7
-rw-r--r--common/rfb/SSecurityNone.h8
-rw-r--r--common/rfb/SSecurityPlain.cxx4
-rw-r--r--common/rfb/SSecurityPlain.h6
-rw-r--r--common/rfb/SSecurityRSAAES.cxx17
-rw-r--r--common/rfb/SSecurityRSAAES.h8
-rw-r--r--common/rfb/SSecurityStack.cxx6
-rw-r--r--common/rfb/SSecurityStack.h10
-rw-r--r--common/rfb/SSecurityTLS.cxx32
-rw-r--r--common/rfb/SSecurityTLS.h8
-rw-r--r--common/rfb/SSecurityVeNCrypt.cxx15
-rw-r--r--common/rfb/SSecurityVeNCrypt.h8
-rw-r--r--common/rfb/SSecurityVncAuth.cxx14
-rw-r--r--common/rfb/SSecurityVncAuth.h10
-rw-r--r--common/rfb/Security.cxx60
-rw-r--r--common/rfb/SecurityClient.cxx8
-rw-r--r--common/rfb/ServerParams.cxx2
-rw-r--r--common/rfb/TightDecoder.cxx4
-rw-r--r--common/rfb/TightDecoder.h23
-rw-r--r--common/rfb/TightEncoder.cxx8
-rw-r--r--common/rfb/TightEncoder.h12
-rw-r--r--common/rfb/TightJPEGEncoder.cxx4
-rw-r--r--common/rfb/TightJPEGEncoder.h16
-rw-r--r--common/rfb/Timer.cxx20
-rw-r--r--common/rfb/Timer.h2
-rw-r--r--common/rfb/UnixPasswordValidator.h2
-rw-r--r--common/rfb/UpdateTracker.h10
-rw-r--r--common/rfb/VNCSConnectionST.cxx14
-rw-r--r--common/rfb/VNCSConnectionST.h50
-rw-r--r--common/rfb/VNCServer.h2
-rw-r--r--common/rfb/VNCServerST.cxx102
-rw-r--r--common/rfb/VNCServerST.h70
-rw-r--r--common/rfb/WinPasswdValidator.h2
-rw-r--r--common/rfb/ZRLEDecoder.cxx63
-rw-r--r--common/rfb/ZRLEDecoder.h12
-rw-r--r--common/rfb/ZRLEEncoder.cxx8
-rw-r--r--common/rfb/ZRLEEncoder.h12
-rw-r--r--common/rfb/obfuscate.cxx4
-rw-r--r--common/rfb/util.cxx8
-rw-r--r--release/CMakeLists.txt4
-rw-r--r--tests/perf/decperf.cxx28
-rw-r--r--tests/perf/encperf.cxx54
-rw-r--r--tests/perf/fbperf.cxx26
-rw-r--r--tests/perf/util.cxx8
-rw-r--r--tests/unit/emulatemb.cxx2
-rw-r--r--tests/unit/gesturehandler.cxx2
-rw-r--r--tests/unit/pixelformat.cxx2
-rw-r--r--tests/unit/unicode.cxx4
-rw-r--r--unix/common/randr.cxx62
-rw-r--r--unix/tx/TXButton.h9
-rw-r--r--unix/tx/TXCheckbox.h9
-rw-r--r--unix/tx/TXDialog.h8
-rw-r--r--unix/tx/TXLabel.h4
-rw-r--r--unix/tx/TXWindow.cxx18
-rw-r--r--unix/tx/TXWindow.h10
-rw-r--r--unix/vncconfig/QueryConnectDialog.cxx4
-rw-r--r--unix/vncconfig/QueryConnectDialog.h8
-rw-r--r--unix/vncconfig/vncconfig.cxx42
-rw-r--r--unix/vncpasswd/vncpasswd.cxx12
-rw-r--r--unix/x0vncserver/Geometry.cxx2
-rw-r--r--unix/x0vncserver/Image.cxx49
-rw-r--r--unix/x0vncserver/Image.h12
-rw-r--r--unix/x0vncserver/XDesktop.cxx58
-rw-r--r--unix/x0vncserver/XDesktop.h36
-rw-r--r--unix/x0vncserver/XPixelBuffer.cxx2
-rw-r--r--unix/x0vncserver/XPixelBuffer.h2
-rw-r--r--unix/x0vncserver/x0vncserver.cxx55
-rw-r--r--unix/xserver/hw/vnc/Makefile.am2
-rw-r--r--unix/xserver/hw/vnc/RFBGlue.cc36
-rw-r--r--unix/xserver/hw/vnc/XserverDesktop.cc13
-rw-r--r--unix/xserver/hw/vnc/XserverDesktop.h28
-rw-r--r--unix/xserver/hw/vnc/vncExtInit.cc6
-rw-r--r--vncviewer/BaseTouchHandler.cxx4
-rw-r--r--vncviewer/CConn.cxx12
-rw-r--r--vncviewer/CConn.h37
-rw-r--r--vncviewer/DesktopWindow.cxx40
-rw-r--r--vncviewer/DesktopWindow.h8
-rw-r--r--vncviewer/EmulateMB.h2
-rw-r--r--vncviewer/GestureHandler.cxx14
-rw-r--r--vncviewer/GestureHandler.h4
-rw-r--r--vncviewer/MonitorIndicesParameter.cxx20
-rw-r--r--vncviewer/MonitorIndicesParameter.h6
-rw-r--r--vncviewer/OptionsDialog.cxx40
-rw-r--r--vncviewer/OptionsDialog.h4
-rw-r--r--vncviewer/PlatformPixelBuffer.cxx30
-rw-r--r--vncviewer/PlatformPixelBuffer.h2
-rw-r--r--vncviewer/ServerDialog.cxx20
-rw-r--r--vncviewer/Surface.h12
-rw-r--r--vncviewer/Surface_OSX.cxx35
-rw-r--r--vncviewer/Surface_Win32.cxx30
-rw-r--r--vncviewer/Surface_X11.cxx32
-rw-r--r--vncviewer/UserDialog.cxx22
-rw-r--r--vncviewer/UserDialog.h4
-rw-r--r--vncviewer/Viewport.cxx94
-rw-r--r--vncviewer/Viewport.h8
-rw-r--r--vncviewer/Win32TouchHandler.cxx6
-rw-r--r--vncviewer/Win32TouchHandler.h10
-rw-r--r--vncviewer/XInputTouchHandler.cxx22
-rw-r--r--vncviewer/XInputTouchHandler.h12
-rw-r--r--vncviewer/cocoa.mm6
-rw-r--r--vncviewer/fltk/Fl_Monitor_Arrangement.cxx10
-rw-r--r--vncviewer/fltk/Fl_Monitor_Arrangement.h2
-rw-r--r--vncviewer/fltk/Fl_Navigation.cxx4
-rw-r--r--vncviewer/fltk/Fl_Navigation.h2
-rw-r--r--vncviewer/fltk/theme.cxx6
-rw-r--r--vncviewer/fltk/util.h2
-rw-r--r--vncviewer/gettext.h12
-rw-r--r--vncviewer/parameters.cxx87
-rw-r--r--vncviewer/parameters.h2
-rw-r--r--vncviewer/touch.cxx4
-rw-r--r--vncviewer/vncviewer.cxx110
-rw-r--r--win/rfb_win32/AboutDialog.cxx2
-rw-r--r--win/rfb_win32/AboutDialog.h2
-rw-r--r--win/rfb_win32/CleanDesktop.cxx24
-rw-r--r--win/rfb_win32/Clipboard.cxx16
-rw-r--r--win/rfb_win32/Clipboard.h2
-rw-r--r--win/rfb_win32/DIBSectionBuffer.cxx16
-rw-r--r--win/rfb_win32/DeviceContext.cxx6
-rw-r--r--win/rfb_win32/DeviceContext.h2
-rw-r--r--win/rfb_win32/DeviceFrameBuffer.cxx12
-rw-r--r--win/rfb_win32/DeviceFrameBuffer.h2
-rw-r--r--win/rfb_win32/Dialog.cxx42
-rw-r--r--win/rfb_win32/Dialog.h6
-rw-r--r--win/rfb_win32/Handle.h2
-rw-r--r--win/rfb_win32/IntervalTimer.h4
-rw-r--r--win/rfb_win32/LaunchProcess.cxx12
-rw-r--r--win/rfb_win32/LocalMem.h2
-rw-r--r--win/rfb_win32/ModuleFileName.h4
-rw-r--r--win/rfb_win32/MonitorInfo.cxx4
-rw-r--r--win/rfb_win32/MsgBox.h2
-rw-r--r--win/rfb_win32/MsgWindow.cxx16
-rw-r--r--win/rfb_win32/RegConfig.cxx7
-rw-r--r--win/rfb_win32/RegConfig.h4
-rw-r--r--win/rfb_win32/Registry.cxx40
-rw-r--r--win/rfb_win32/Registry.h2
-rw-r--r--win/rfb_win32/SDisplay.cxx46
-rw-r--r--win/rfb_win32/SDisplay.h28
-rw-r--r--win/rfb_win32/SDisplayCorePolling.h8
-rw-r--r--win/rfb_win32/SDisplayCoreWMHooks.h6
-rw-r--r--win/rfb_win32/Security.cxx14
-rw-r--r--win/rfb_win32/Security.h6
-rw-r--r--win/rfb_win32/SecurityPage.cxx12
-rw-r--r--win/rfb_win32/SecurityPage.h6
-rw-r--r--win/rfb_win32/Service.cxx64
-rw-r--r--win/rfb_win32/SocketManager.cxx12
-rw-r--r--win/rfb_win32/SocketManager.h6
-rw-r--r--win/rfb_win32/TrayIcon.h6
-rw-r--r--win/rfb_win32/WMCursor.cxx4
-rw-r--r--win/rfb_win32/WMCursor.h2
-rw-r--r--win/rfb_win32/WMHooks.cxx40
-rw-r--r--win/rfb_win32/WMNotifier.cxx2
-rw-r--r--win/rfb_win32/WMNotifier.h2
-rw-r--r--win/rfb_win32/WMPoller.h2
-rw-r--r--win/rfb_win32/WMWindowCopyRect.cxx6
-rw-r--r--win/rfb_win32/Win32Util.cxx8
-rw-r--r--win/rfb_win32/Win32Util.h2
-rw-r--r--win/vncconfig/Authentication.h26
-rw-r--r--win/vncconfig/Connections.h16
-rw-r--r--win/vncconfig/Desktop.h8
-rw-r--r--win/vncconfig/Hooking.h8
-rw-r--r--win/vncconfig/Inputs.h10
-rw-r--r--win/vncconfig/Legacy.cxx12
-rw-r--r--win/vncconfig/Legacy.h12
-rw-r--r--win/vncconfig/PasswordDialog.cxx6
-rw-r--r--win/vncconfig/PasswordDialog.h4
-rw-r--r--win/vncconfig/Sharing.h8
-rw-r--r--win/vncconfig/vncconfig.cxx13
-rw-r--r--win/winvnc/AddNewClientDialog.h6
-rw-r--r--win/winvnc/ControlPanel.cxx6
-rw-r--r--win/winvnc/ControlPanel.h6
-rw-r--r--win/winvnc/ManagedListener.cxx4
-rw-r--r--win/winvnc/QueryConnectDialog.cxx4
-rw-r--r--win/winvnc/QueryConnectDialog.h6
-rw-r--r--win/winvnc/STrayIcon.cxx18
-rw-r--r--win/winvnc/STrayIcon.h2
-rw-r--r--win/winvnc/VNCServerService.cxx30
-rw-r--r--win/winvnc/VNCServerService.h4
-rw-r--r--win/winvnc/VNCServerWin32.cxx25
-rw-r--r--win/winvnc/VNCServerWin32.h12
-rw-r--r--win/winvnc/winvnc.cxx12
-rw-r--r--win/wm_hooks/wm_hooks.cxx36
288 files changed, 2013 insertions, 2028 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 71d94e67..07a859ca 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -10,6 +10,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
include(CheckIncludeFiles)
include(CheckFunctionExists)
include(CheckLibraryExists)
+include(CheckVariableExists)
include(CheckTypeSize)
include(CheckCSourceCompiles)
include(CheckCXXSourceCompiles)
@@ -69,12 +70,16 @@ IF(CMAKE_BUILD_TYPE MATCHES Debug)
add_definitions(-D_DEBUG)
ENDIF()
-# Make sure we get a sane C version
+# Make sure we get a sane C and C++ version
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
# Tell the compiler to be stringent
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat=2 -Wvla")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wformat=2 -Wvla")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wzero-as-null-pointer-constant")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsuggest-override")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wshadow")
# Make sure we catch these issues whilst developing
IF(CMAKE_BUILD_TYPE MATCHES Debug)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
@@ -182,6 +187,13 @@ if(ENABLE_H264)
add_definitions("-DHAVE_H264")
set(H264_LIBS "WIN") # may be LIBAV in the future
set(H264_LIBRARIES ole32 mfplat mfuuid wmcodecdspuuid)
+
+ set(CMAKE_REQUIRED_LIBRARIES ${H264_LIBRARIES})
+ check_variable_exists(CLSID_VideoProcessorMFT HAVE_VIDEO_PROCESSOR_MFT)
+ set(CMAKE_REQUIRED_LIBRARIES)
+ if(HAVE_VIDEO_PROCESSOR_MFT)
+ add_definitions("-DHAVE_VIDEO_PROCESSOR_MFT")
+ endif()
else()
find_package(Ffmpeg)
if (AVCODEC_FOUND AND AVUTIL_FOUND AND SWSCALE_FOUND)
diff --git a/common/network/Socket.cxx b/common/network/Socket.cxx
index 78484f51..8da44366 100644
--- a/common/network/Socket.cxx
+++ b/common/network/Socket.cxx
@@ -71,7 +71,7 @@ bool network::isSocketListening(int sock)
}
Socket::Socket(int fd)
- : instream(0), outstream(0),
+ : instream(nullptr), outstream(nullptr),
isShutdown_(false), queryConnection(false)
{
initSockets();
@@ -79,7 +79,7 @@ Socket::Socket(int fd)
}
Socket::Socket()
- : instream(0), outstream(0),
+ : instream(nullptr), outstream(nullptr),
isShutdown_(false), queryConnection(false)
{
initSockets();
@@ -128,14 +128,14 @@ void Socket::setFd(int fd)
isShutdown_ = false;
}
-SocketListener::SocketListener(int fd)
- : fd(fd), filter(0)
+SocketListener::SocketListener(int fd_)
+ : fd(fd_), filter(nullptr)
{
initSockets();
}
SocketListener::SocketListener()
- : fd(-1), filter(0)
+ : fd(-1), filter(nullptr)
{
initSockets();
}
@@ -160,14 +160,14 @@ Socket* SocketListener::accept() {
int new_sock = -1;
// Accept an incoming connection
- if ((new_sock = ::accept(fd, 0, 0)) < 0)
+ if ((new_sock = ::accept(fd, nullptr, nullptr)) < 0)
throw SocketException("unable to accept new connection", errorNumber);
// Create the socket object & check connection is allowed
Socket* s = createSocket(new_sock);
if (filter && !filter->verifyConnection(s)) {
delete s;
- return NULL;
+ return nullptr;
}
return s;
diff --git a/common/network/TcpSocket.cxx b/common/network/TcpSocket.cxx
index 15730cfd..3f2f0f1f 100644
--- a/common/network/TcpSocket.cxx
+++ b/common/network/TcpSocket.cxx
@@ -129,17 +129,17 @@ TcpSocket::TcpSocket(const char *host, int port)
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
- hints.ai_canonname = NULL;
- hints.ai_addr = NULL;
- hints.ai_next = NULL;
+ hints.ai_canonname = nullptr;
+ hints.ai_addr = nullptr;
+ hints.ai_next = nullptr;
- if ((result = getaddrinfo(host, NULL, &hints, &ai)) != 0) {
+ if ((result = getaddrinfo(host, nullptr, &hints, &ai)) != 0) {
throw GAIException("unable to resolve host by name", result);
}
sock = -1;
err = 0;
- for (current = ai; current != NULL; current = current->ai_next) {
+ for (current = ai; current != nullptr; current = current->ai_next) {
int family;
vnc_sockaddr_t sa;
socklen_t salen;
@@ -168,7 +168,7 @@ TcpSocket::TcpSocket(const char *host, int port)
else
sa.u.sin6.sin6_port = htons(port);
- getnameinfo(&sa.u.sa, salen, ntop, sizeof(ntop), NULL, 0, NI_NUMERICHOST);
+ getnameinfo(&sa.u.sa, salen, ntop, sizeof(ntop), nullptr, 0, NI_NUMERICHOST);
vlog.debug("Connecting to %s [%s] port %d", host, ntop, port);
sock = socket (family, SOCK_STREAM, 0);
@@ -228,7 +228,7 @@ const char* TcpSocket::getPeerAddress() {
buffer[0] = '[';
ret = getnameinfo(&sa.u.sa, sizeof(sa.u.sin6),
- buffer + 1, sizeof(buffer) - 2, NULL, 0,
+ buffer + 1, sizeof(buffer) - 2, nullptr, 0,
NI_NUMERICHOST);
if (ret != 0) {
vlog.error("unable to convert peer name to a string");
@@ -244,7 +244,7 @@ const char* TcpSocket::getPeerAddress() {
char *name;
name = inet_ntoa(sa.u.sin.sin_addr);
- if (name == NULL) {
+ if (name == nullptr) {
vlog.error("unable to convert peer name to a string");
return "(N/A)";
}
@@ -338,8 +338,8 @@ TcpListener::TcpListener(const struct sockaddr *listenaddr,
listen(sock);
}
-Socket* TcpListener::createSocket(int fd) {
- return new TcpSocket(fd);
+Socket* TcpListener::createSocket(int fd_) {
+ return new TcpSocket(fd_);
}
std::list<std::string> TcpListener::getMyAddresses() {
@@ -352,15 +352,15 @@ std::list<std::string> TcpListener::getMyAddresses() {
hints.ai_flags = AI_PASSIVE | AI_NUMERICSERV;
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
- hints.ai_canonname = NULL;
- hints.ai_addr = NULL;
- hints.ai_next = NULL;
+ hints.ai_canonname = nullptr;
+ hints.ai_addr = nullptr;
+ hints.ai_next = nullptr;
// Windows doesn't like NULL for service, so specify something
- if ((getaddrinfo(NULL, "1", &hints, &ai)) != 0)
+ if ((getaddrinfo(nullptr, "1", &hints, &ai)) != 0)
return result;
- for (current= ai; current != NULL; current = current->ai_next) {
+ for (current= ai; current != nullptr; current = current->ai_next) {
char addr[INET6_ADDRSTRLEN];
switch (current->ai_family) {
@@ -377,7 +377,7 @@ std::list<std::string> TcpListener::getMyAddresses() {
}
getnameinfo(current->ai_addr, current->ai_addrlen, addr, INET6_ADDRSTRLEN,
- NULL, 0, NI_NUMERICHOST);
+ nullptr, 0, NI_NUMERICHOST);
result.push_back(addr);
}
@@ -417,7 +417,7 @@ void network::createLocalTcpListeners(std::list<SocketListener*> *listeners,
ai[1].ai_family = sa[1].u.sin6.sin6_family;
ai[1].ai_addr = &sa[1].u.sa;
ai[1].ai_addrlen = sizeof(sa[1].u.sin6);
- ai[1].ai_next = NULL;
+ ai[1].ai_next = nullptr;
createTcpListeners(listeners, ai);
}
@@ -436,9 +436,9 @@ void network::createTcpListeners(std::list<SocketListener*> *listeners,
hints.ai_flags = AI_PASSIVE | AI_NUMERICSERV;
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
- hints.ai_canonname = NULL;
- hints.ai_addr = NULL;
- hints.ai_next = NULL;
+ hints.ai_canonname = nullptr;
+ hints.ai_addr = nullptr;
+ hints.ai_next = nullptr;
snprintf (service, sizeof (service) - 1, "%d", port);
service[sizeof (service) - 1] = '\0';
@@ -463,7 +463,7 @@ void network::createTcpListeners(std::list<SocketListener*> *listeners,
initSockets();
- for (current = ai; current != NULL; current = current->ai_next) {
+ for (current = ai; current != nullptr; current = current->ai_next) {
switch (current->ai_family) {
case AF_INET:
if (!UseIPv4)
@@ -629,7 +629,7 @@ TcpFilter::Pattern TcpFilter::parsePattern(const char* p) {
parts[0].erase(parts.size()-1, 1);
}
- if ((result = getaddrinfo (parts[0].c_str(), NULL, &hints, &ai)) != 0) {
+ if ((result = getaddrinfo (parts[0].c_str(), nullptr, &hints, &ai)) != 0) {
throw GAIException("unable to resolve host by name", result);
}
@@ -711,11 +711,11 @@ std::string TcpFilter::patternToStr(const TcpFilter::Pattern& p) {
if (p.address.u.sa.sa_family == AF_INET) {
getnameinfo(&p.address.u.sa, sizeof(p.address.u.sin),
- addr, sizeof(addr), NULL, 0, NI_NUMERICHOST);
+ addr, sizeof(addr), nullptr, 0, NI_NUMERICHOST);
} else if (p.address.u.sa.sa_family == AF_INET6) {
addr[0] = '[';
getnameinfo(&p.address.u.sa, sizeof(p.address.u.sin6),
- addr + 1, sizeof(addr) - 2, NULL, 0, NI_NUMERICHOST);
+ addr + 1, sizeof(addr) - 2, nullptr, 0, NI_NUMERICHOST);
strcat(addr, "]");
} else
addr[0] = '\0';
diff --git a/common/network/TcpSocket.h b/common/network/TcpSocket.h
index c62dd78b..b029bff2 100644
--- a/common/network/TcpSocket.h
+++ b/common/network/TcpSocket.h
@@ -56,8 +56,8 @@ namespace network {
TcpSocket(int sock);
TcpSocket(const char *name, int port);
- virtual const char* getPeerAddress();
- virtual const char* getPeerEndpoint();
+ const char* getPeerAddress() override;
+ const char* getPeerEndpoint() override;
protected:
bool enableNagles(bool enable);
@@ -68,12 +68,12 @@ namespace network {
TcpListener(const struct sockaddr *listenaddr, socklen_t listenaddrlen);
TcpListener(int sock);
- virtual int getMyPort();
+ int getMyPort() override;
static std::list<std::string> getMyAddresses();
protected:
- virtual Socket* createSocket(int fd);
+ Socket* createSocket(int fd) override;
};
void createLocalTcpListeners(std::list<SocketListener*> *listeners,
@@ -97,7 +97,7 @@ namespace network {
TcpFilter(const char* filter);
virtual ~TcpFilter();
- virtual bool verifyConnection(Socket* s);
+ bool verifyConnection(Socket* s) override;
typedef enum {Accept, Reject, Query} Action;
struct Pattern {
diff --git a/common/network/UnixSocket.cxx b/common/network/UnixSocket.cxx
index e7793849..3a422b6c 100644
--- a/common/network/UnixSocket.cxx
+++ b/common/network/UnixSocket.cxx
@@ -157,8 +157,8 @@ UnixListener::~UnixListener()
unlink(addr.sun_path);
}
-Socket* UnixListener::createSocket(int fd) {
- return new UnixSocket(fd);
+Socket* UnixListener::createSocket(int fd_) {
+ return new UnixSocket(fd_);
}
int UnixListener::getMyPort() {
diff --git a/common/network/UnixSocket.h b/common/network/UnixSocket.h
index e66afcd1..3ecc6179 100644
--- a/common/network/UnixSocket.h
+++ b/common/network/UnixSocket.h
@@ -38,8 +38,8 @@ namespace network {
UnixSocket(int sock);
UnixSocket(const char *name);
- virtual const char* getPeerAddress();
- virtual const char* getPeerEndpoint();
+ const char* getPeerAddress() override;
+ const char* getPeerEndpoint() override;
};
class UnixListener : public SocketListener {
@@ -47,10 +47,10 @@ namespace network {
UnixListener(const char *listenaddr, int mode);
virtual ~UnixListener();
- int getMyPort();
+ int getMyPort() override;
protected:
- virtual Socket* createSocket(int fd);
+ Socket* createSocket(int fd) override;
};
}
diff --git a/common/os/Mutex.cxx b/common/os/Mutex.cxx
index e6532a7d..2a768b4c 100644
--- a/common/os/Mutex.cxx
+++ b/common/os/Mutex.cxx
@@ -41,7 +41,7 @@ Mutex::Mutex()
int ret;
systemMutex = new pthread_mutex_t;
- ret = pthread_mutex_init((pthread_mutex_t*)systemMutex, NULL);
+ ret = pthread_mutex_init((pthread_mutex_t*)systemMutex, nullptr);
if (ret != 0)
throw rdr::SystemException("Failed to create mutex", ret);
#endif
@@ -84,9 +84,9 @@ void Mutex::unlock()
#endif
}
-Condition::Condition(Mutex* mutex)
+Condition::Condition(Mutex* mutex_)
{
- this->mutex = mutex;
+ this->mutex = mutex_;
#ifdef WIN32
systemCondition = new CONDITION_VARIABLE;
@@ -95,7 +95,7 @@ Condition::Condition(Mutex* mutex)
int ret;
systemCondition = new pthread_cond_t;
- ret = pthread_cond_init((pthread_cond_t*)systemCondition, NULL);
+ ret = pthread_cond_init((pthread_cond_t*)systemCondition, nullptr);
if (ret != 0)
throw rdr::SystemException("Failed to create condition variable", ret);
#endif
diff --git a/common/os/Thread.cxx b/common/os/Thread.cxx
index 92cc68d5..91f7fd07 100644
--- a/common/os/Thread.cxx
+++ b/common/os/Thread.cxx
@@ -35,7 +35,7 @@
using namespace os;
-Thread::Thread() : running(false), threadId(NULL)
+Thread::Thread() : running(false), threadId(nullptr)
{
mutex = new Mutex;
@@ -64,8 +64,8 @@ void Thread::start()
AutoMutex a(mutex);
#ifdef WIN32
- *(HANDLE*)threadId = CreateThread(NULL, 0, startRoutine, this, 0, NULL);
- if (*(HANDLE*)threadId == NULL)
+ *(HANDLE*)threadId = CreateThread(nullptr, 0, startRoutine, this, 0, nullptr);
+ if (*(HANDLE*)threadId == nullptr)
throw rdr::SystemException("Failed to create thread", GetLastError());
#else
int ret;
@@ -78,9 +78,9 @@ void Thread::start()
if (ret != 0)
throw rdr::SystemException("Failed to mask signals", ret);
- ret = pthread_create((pthread_t*)threadId, NULL, startRoutine, this);
+ ret = pthread_create((pthread_t*)threadId, nullptr, startRoutine, this);
- pthread_sigmask(SIG_SETMASK, &old, NULL);
+ pthread_sigmask(SIG_SETMASK, &old, nullptr);
if (ret != 0)
throw rdr::SystemException("Failed to create thread", ret);
@@ -103,7 +103,7 @@ void Thread::wait()
#else
int ret;
- ret = pthread_join(*(pthread_t*)threadId, NULL);
+ ret = pthread_join(*(pthread_t*)threadId, nullptr);
if (ret != 0)
throw rdr::SystemException("Failed to join thread", ret);
#endif
@@ -165,5 +165,9 @@ void* Thread::startRoutine(void* data)
self->running = false;
self->mutex->unlock();
+#ifdef WIN32
return 0;
+#else
+ return nullptr;
+#endif
}
diff --git a/common/os/os.cxx b/common/os/os.cxx
index 83995d0d..2ac70550 100644
--- a/common/os/os.cxx
+++ b/common/os/os.cxx
@@ -58,12 +58,12 @@ static const char* getvncdir(bool userDir, const char *xdg_env, const char *xdg_
#ifndef WIN32
homedir = getenv("HOME");
- if (homedir == NULL) {
+ if (homedir == nullptr) {
uid = getuid();
passwd = getpwuid(uid);
- if (passwd == NULL) {
+ if (passwd == nullptr) {
/* Do we want emit error msg here? */
- return NULL;
+ return nullptr;
}
homedir = passwd->pw_dir;
}
@@ -72,7 +72,7 @@ static const char* getvncdir(bool userDir, const char *xdg_env, const char *xdg_
return homedir;
xdgdir = getenv(xdg_env);
- if (xdgdir != NULL && xdgdir[0] == '/')
+ if (xdgdir != nullptr && xdgdir[0] == '/')
snprintf(dir, sizeof(dir), "%s/tigervnc", xdgdir);
else
snprintf(dir, sizeof(dir), "%s/%s/tigervnc", homedir, xdg_def);
@@ -83,25 +83,25 @@ static const char* getvncdir(bool userDir, const char *xdg_env, const char *xdg_
(void) xdg_env;
if (userDir)
- ret = SHGetSpecialFolderPath(NULL, dir, CSIDL_PROFILE, FALSE);
+ ret = SHGetSpecialFolderPath(nullptr, dir, CSIDL_PROFILE, FALSE);
else
- ret = SHGetSpecialFolderPath(NULL, dir, CSIDL_APPDATA, FALSE);
+ ret = SHGetSpecialFolderPath(nullptr, dir, CSIDL_APPDATA, FALSE);
if (ret == FALSE)
- return NULL;
+ return nullptr;
if (userDir)
return dir;
- ret = SHGetSpecialFolderPath(NULL, legacy, CSIDL_APPDATA, FALSE);
+ ret = SHGetSpecialFolderPath(nullptr, legacy, CSIDL_APPDATA, FALSE);
if (ret == FALSE)
- return NULL;
+ return nullptr;
if (strlen(dir) + strlen("\\TigerVNC") >= sizeof(dir))
- return NULL;
+ return nullptr;
if (strlen(legacy) + strlen("\\vnc") >= sizeof(legacy))
- return NULL;
+ return nullptr;
strcat(dir, "\\TigerVNC");
strcat(legacy, "\\vnc");
@@ -111,7 +111,7 @@ static const char* getvncdir(bool userDir, const char *xdg_env, const char *xdg_
const char* os::getuserhomedir()
{
- return getvncdir(true, NULL, NULL);
+ return getvncdir(true, nullptr, nullptr);
}
const char* os::getvncconfigdir()
diff --git a/common/rdr/AESInStream.cxx b/common/rdr/AESInStream.cxx
index de91a3df..d6d944a3 100644
--- a/common/rdr/AESInStream.cxx
+++ b/common/rdr/AESInStream.cxx
@@ -45,15 +45,15 @@ bool AESInStream::fillBuffer()
{
if (!in->hasData(2))
return false;
- const uint8_t* ptr = in->getptr(2);
- size_t length = ((int)ptr[0] << 8) | (int)ptr[1];
+ const uint8_t* buf = in->getptr(2);
+ size_t length = ((int)buf[0] << 8) | (int)buf[1];
if (!in->hasData(2 + length + 16))
return false;
ensureSpace(length);
- ptr = in->getptr(2 + length + 16);
- const uint8_t* ad = ptr;
- const uint8_t* data = ptr + 2;
- const uint8_t* mac = ptr + 2 + length;
+ buf = in->getptr(2 + length + 16);
+ const uint8_t* ad = buf;
+ const uint8_t* data = buf + 2;
+ const uint8_t* mac = buf + 2 + length;
uint8_t macComputed[16];
if (keySize == 128) {
diff --git a/common/rdr/AESInStream.h b/common/rdr/AESInStream.h
index 6069bb71..f0e6de53 100644
--- a/common/rdr/AESInStream.h
+++ b/common/rdr/AESInStream.h
@@ -33,7 +33,7 @@ namespace rdr {
virtual ~AESInStream();
private:
- virtual bool fillBuffer();
+ bool fillBuffer() override;
int keySize;
InStream* in;
diff --git a/common/rdr/AESOutStream.h b/common/rdr/AESOutStream.h
index f9e4f4da..c84ee2b8 100644
--- a/common/rdr/AESOutStream.h
+++ b/common/rdr/AESOutStream.h
@@ -31,11 +31,11 @@ namespace rdr {
AESOutStream(OutStream* out, const uint8_t* key, int keySize);
virtual ~AESOutStream();
- virtual void flush();
- virtual void cork(bool enable);
+ void flush() override;
+ void cork(bool enable) override;
private:
- virtual bool flushBuffer();
+ bool flushBuffer() override;
void writeMessage(const uint8_t* data, size_t length);
int keySize;
diff --git a/common/rdr/BufferedInStream.cxx b/common/rdr/BufferedInStream.cxx
index 5978a8c9..3c04bafc 100644
--- a/common/rdr/BufferedInStream.cxx
+++ b/common/rdr/BufferedInStream.cxx
@@ -35,7 +35,7 @@ BufferedInStream::BufferedInStream()
: bufSize(DEFAULT_BUF_SIZE), offset(0)
{
ptr = end = start = new uint8_t[bufSize];
- gettimeofday(&lastSizeCheck, NULL);
+ gettimeofday(&lastSizeCheck, nullptr);
peakUsage = 0;
}
@@ -80,7 +80,7 @@ void BufferedInStream::ensureSpace(size_t needed)
end = newBuffer + (end - ptr);
ptr = start = newBuffer;
- gettimeofday(&lastSizeCheck, NULL);
+ gettimeofday(&lastSizeCheck, nullptr);
peakUsage = needed;
}
@@ -88,7 +88,7 @@ void BufferedInStream::ensureSpace(size_t needed)
peakUsage = needed;
// Time to shrink an excessive buffer?
- gettimeofday(&now, NULL);
+ gettimeofday(&now, nullptr);
if ((avail() == 0) && (bufSize > DEFAULT_BUF_SIZE) &&
((now.tv_sec < lastSizeCheck.tv_sec) ||
(now.tv_sec > (lastSizeCheck.tv_sec + 5)))) {
@@ -105,7 +105,7 @@ void BufferedInStream::ensureSpace(size_t needed)
bufSize = newSize;
}
- gettimeofday(&lastSizeCheck, NULL);
+ gettimeofday(&lastSizeCheck, nullptr);
peakUsage = needed;
}
diff --git a/common/rdr/BufferedInStream.h b/common/rdr/BufferedInStream.h
index 89b25ffb..b3d6115e 100644
--- a/common/rdr/BufferedInStream.h
+++ b/common/rdr/BufferedInStream.h
@@ -35,7 +35,7 @@ namespace rdr {
public:
virtual ~BufferedInStream();
- virtual size_t pos();
+ size_t pos() override;
protected:
size_t availSpace() { return start + bufSize - end; }
@@ -45,7 +45,7 @@ namespace rdr {
private:
virtual bool fillBuffer() = 0;
- virtual bool overrun(size_t needed);
+ bool overrun(size_t needed) override;
private:
size_t bufSize;
diff --git a/common/rdr/BufferedOutStream.cxx b/common/rdr/BufferedOutStream.cxx
index 640f6007..0d6a1eb6 100644
--- a/common/rdr/BufferedOutStream.cxx
+++ b/common/rdr/BufferedOutStream.cxx
@@ -31,12 +31,12 @@ using namespace rdr;
static const size_t DEFAULT_BUF_SIZE = 16384;
static const size_t MAX_BUF_SIZE = 32 * 1024 * 1024;
-BufferedOutStream::BufferedOutStream(bool emulateCork)
- : bufSize(DEFAULT_BUF_SIZE), offset(0), emulateCork(emulateCork)
+BufferedOutStream::BufferedOutStream(bool emulateCork_)
+ : bufSize(DEFAULT_BUF_SIZE), offset(0), emulateCork(emulateCork_)
{
ptr = start = sentUpTo = new uint8_t[bufSize];
end = start + bufSize;
- gettimeofday(&lastSizeCheck, NULL);
+ gettimeofday(&lastSizeCheck, nullptr);
peakUsage = 0;
}
@@ -75,7 +75,7 @@ void BufferedOutStream::flush()
ptr = sentUpTo = start;
// Time to shrink an excessive buffer?
- gettimeofday(&now, NULL);
+ gettimeofday(&now, nullptr);
if ((sentUpTo == ptr) && (bufSize > DEFAULT_BUF_SIZE) &&
((now.tv_sec < lastSizeCheck.tv_sec) ||
(now.tv_sec > (lastSizeCheck.tv_sec + 5)))) {
@@ -93,7 +93,7 @@ void BufferedOutStream::flush()
bufSize = newSize;
}
- gettimeofday(&lastSizeCheck, NULL);
+ gettimeofday(&lastSizeCheck, nullptr);
peakUsage = 0;
}
}
@@ -156,7 +156,7 @@ void BufferedOutStream::overrun(size_t needed)
sentUpTo = start = newBuffer;
end = newBuffer + newSize;
- gettimeofday(&lastSizeCheck, NULL);
+ gettimeofday(&lastSizeCheck, nullptr);
peakUsage = totalNeeded;
return;
diff --git a/common/rdr/BufferedOutStream.h b/common/rdr/BufferedOutStream.h
index 22693257..dd765dc9 100644
--- a/common/rdr/BufferedOutStream.h
+++ b/common/rdr/BufferedOutStream.h
@@ -35,8 +35,8 @@ namespace rdr {
public:
virtual ~BufferedOutStream();
- virtual size_t length();
- virtual void flush();
+ size_t length() override;
+ void flush() override;
// hasBufferedData() checks if there is any data yet to be flushed
@@ -49,7 +49,7 @@ namespace rdr {
virtual bool flushBuffer() = 0;
- virtual void overrun(size_t needed);
+ void overrun(size_t needed) override;
private:
size_t bufSize;
diff --git a/common/rdr/Exception.cxx b/common/rdr/Exception.cxx
index b1e0a841..d5546274 100644
--- a/common/rdr/Exception.cxx
+++ b/common/rdr/Exception.cxx
@@ -51,15 +51,15 @@ Exception::Exception(const char *format, ...) {
va_end(ap);
}
-GAIException::GAIException(const char* s, int err)
- : Exception("%s", s)
+GAIException::GAIException(const char* s, int err_)
+ : Exception("%s", s), err(err_)
{
strncat(str_, ": ", len-1-strlen(str_));
#ifdef _WIN32
wchar_t *currStr = new wchar_t[len-strlen(str_)];
wcsncpy(currStr, gai_strerrorW(err), len-1-strlen(str_));
WideCharToMultiByte(CP_UTF8, 0, currStr, -1, str_+strlen(str_),
- len-1-strlen(str_), 0, 0);
+ len-1-strlen(str_), nullptr, nullptr);
delete [] currStr;
#else
strncat(str_, gai_strerror(err), len-1-strlen(str_));
@@ -83,9 +83,9 @@ SystemException::SystemException(const char* s, int err_)
#ifdef _WIN32
wchar_t *currStr = new wchar_t[len-strlen(str_)];
FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
- 0, err, 0, currStr, len-1-strlen(str_), 0);
+ nullptr, err, 0, currStr, len-1-strlen(str_), nullptr);
WideCharToMultiByte(CP_UTF8, 0, currStr, -1, str_+strlen(str_),
- len-1-strlen(str_), 0, 0);
+ len-1-strlen(str_), nullptr, nullptr);
delete [] currStr;
int l = strlen(str_);
diff --git a/common/rdr/Exception.h b/common/rdr/Exception.h
index 2c66ffca..f1a167e5 100644
--- a/common/rdr/Exception.h
+++ b/common/rdr/Exception.h
@@ -26,7 +26,7 @@ namespace rdr {
struct Exception {
enum { len = 256 };
char str_[len];
- Exception(const char *format = 0, ...)
+ Exception(const char *format=nullptr, ...)
__attribute__((__format__ (__printf__, 2, 3)));
virtual ~Exception() {}
virtual const char* str() const { return str_; }
diff --git a/common/rdr/FdInStream.cxx b/common/rdr/FdInStream.cxx
index 8e12f3a4..491dc008 100644
--- a/common/rdr/FdInStream.cxx
+++ b/common/rdr/FdInStream.cxx
@@ -88,7 +88,7 @@ size_t FdInStream::readFd(uint8_t* buf, size_t len)
FD_ZERO(&fds);
FD_SET(fd, &fds);
- n = select(fd+1, &fds, 0, 0, &tv);
+ n = select(fd+1, &fds, nullptr, nullptr, &tv);
} while (n < 0 && errorNumber == EINTR);
if (n < 0)
diff --git a/common/rdr/FdInStream.h b/common/rdr/FdInStream.h
index 0f8373fe..0bd5bf19 100644
--- a/common/rdr/FdInStream.h
+++ b/common/rdr/FdInStream.h
@@ -37,7 +37,7 @@ namespace rdr {
int getFd() { return fd; }
private:
- virtual bool fillBuffer();
+ bool fillBuffer() override;
size_t readFd(uint8_t* buf, size_t len);
diff --git a/common/rdr/FdOutStream.cxx b/common/rdr/FdOutStream.cxx
index 6827655f..1f60d45b 100644
--- a/common/rdr/FdOutStream.cxx
+++ b/common/rdr/FdOutStream.cxx
@@ -59,7 +59,7 @@ FdOutStream::FdOutStream(int fd_)
#endif
fd(fd_)
{
- gettimeofday(&lastWrite, NULL);
+ gettimeofday(&lastWrite, nullptr);
}
FdOutStream::~FdOutStream()
@@ -113,7 +113,7 @@ size_t FdOutStream::writeFd(const uint8_t* data, size_t length)
FD_ZERO(&fds);
FD_SET(fd, &fds);
- n = select(fd+1, 0, &fds, 0, &tv);
+ n = select(fd+1, nullptr, &fds, nullptr, &tv);
} while (n < 0 && errorNumber == EINTR);
if (n < 0)
@@ -136,7 +136,7 @@ size_t FdOutStream::writeFd(const uint8_t* data, size_t length)
if (n < 0)
throw SystemException("write", errorNumber);
- gettimeofday(&lastWrite, NULL);
+ gettimeofday(&lastWrite, nullptr);
return n;
}
diff --git a/common/rdr/FdOutStream.h b/common/rdr/FdOutStream.h
index 05fc1fed..d9f16efb 100644
--- a/common/rdr/FdOutStream.h
+++ b/common/rdr/FdOutStream.h
@@ -41,10 +41,10 @@ namespace rdr {
unsigned getIdleTime();
- virtual void cork(bool enable);
+ void cork(bool enable) override;
private:
- virtual bool flushBuffer();
+ bool flushBuffer() override;
size_t writeFd(const uint8_t* data, size_t length);
int fd;
struct timeval lastWrite;
diff --git a/common/rdr/FileInStream.cxx b/common/rdr/FileInStream.cxx
index 6de1a5b2..4239a238 100644
--- a/common/rdr/FileInStream.cxx
+++ b/common/rdr/FileInStream.cxx
@@ -39,7 +39,7 @@ FileInStream::FileInStream(const char *fileName)
FileInStream::~FileInStream(void) {
if (file) {
fclose(file);
- file = NULL;
+ file = nullptr;
}
}
diff --git a/common/rdr/FileInStream.h b/common/rdr/FileInStream.h
index e13596ce..1b409e46 100644
--- a/common/rdr/FileInStream.h
+++ b/common/rdr/FileInStream.h
@@ -34,7 +34,7 @@ namespace rdr {
~FileInStream(void);
private:
- virtual bool fillBuffer();
+ bool fillBuffer() override;
private:
FILE *file;
diff --git a/common/rdr/HexInStream.h b/common/rdr/HexInStream.h
index 76f91c08..c69fcd68 100644
--- a/common/rdr/HexInStream.h
+++ b/common/rdr/HexInStream.h
@@ -30,7 +30,7 @@ namespace rdr {
virtual ~HexInStream();
private:
- virtual bool fillBuffer();
+ bool fillBuffer() override;
private:
InStream& in_stream;
diff --git a/common/rdr/HexOutStream.h b/common/rdr/HexOutStream.h
index 16596bf3..7c74f9de 100644
--- a/common/rdr/HexOutStream.h
+++ b/common/rdr/HexOutStream.h
@@ -29,11 +29,11 @@ namespace rdr {
HexOutStream(OutStream& os);
virtual ~HexOutStream();
- virtual void flush();
- virtual void cork(bool enable);
+ void flush() override;
+ void cork(bool enable) override;
private:
- virtual bool flushBuffer();
+ bool flushBuffer() override;
void writeBuffer();
OutStream& out_stream;
diff --git a/common/rdr/InStream.h b/common/rdr/InStream.h
index 019ca5a7..939439e1 100644
--- a/common/rdr/InStream.h
+++ b/common/rdr/InStream.h
@@ -64,7 +64,7 @@ namespace rdr {
#endif
if (length > (size_t)(end - ptr)) {
- if (restorePoint != NULL) {
+ if (restorePoint != nullptr) {
bool ret;
size_t restoreDiff;
@@ -100,21 +100,21 @@ namespace rdr {
inline void setRestorePoint() {
#ifdef RFB_INSTREAM_CHECK
- if (restorePoint != NULL)
+ if (restorePoint != nullptr)
throw Exception("Nested use of input stream restore point");
#endif
restorePoint = ptr;
}
inline void clearRestorePoint() {
#ifdef RFB_INSTREAM_CHECK
- if (restorePoint == NULL)
+ if (restorePoint == nullptr)
throw Exception("Incorrect clearing of input stream restore point");
#endif
- restorePoint = NULL;
+ restorePoint = nullptr;
}
inline void gotoRestorePoint() {
#ifdef RFB_INSTREAM_CHECK
- if (restorePoint == NULL)
+ if (restorePoint == nullptr)
throw Exception("Incorrect activation of input stream restore point");
#endif
ptr = restorePoint;
@@ -204,7 +204,7 @@ namespace rdr {
protected:
- InStream() : restorePoint(NULL)
+ InStream() : restorePoint(nullptr)
#ifdef RFB_INSTREAM_CHECK
,checkedBytes(0)
#endif
diff --git a/common/rdr/MemInStream.h b/common/rdr/MemInStream.h
index 61d08482..e10273b1 100644
--- a/common/rdr/MemInStream.h
+++ b/common/rdr/MemInStream.h
@@ -54,12 +54,12 @@ namespace rdr {
delete [] start;
}
- size_t pos() { return ptr - start; }
+ size_t pos() override { return ptr - start; }
void reposition(size_t pos) { ptr = start + pos; }
private:
- bool overrun(size_t /*needed*/) { throw EndOfStream(); }
+ bool overrun(size_t /*needed*/) override { throw EndOfStream(); }
const uint8_t* start;
bool deleteWhenDone;
};
diff --git a/common/rdr/MemOutStream.h b/common/rdr/MemOutStream.h
index 5ed1ccf7..9bf2b810 100644
--- a/common/rdr/MemOutStream.h
+++ b/common/rdr/MemOutStream.h
@@ -41,7 +41,7 @@ namespace rdr {
delete [] start;
}
- size_t length() { return ptr - start; }
+ size_t length() override { return ptr - start; }
void clear() { ptr = start; };
void clearAndZero() { memset(start, 0, ptr-start); clear(); }
void reposition(size_t pos) { ptr = start + pos; }
@@ -55,7 +55,7 @@ namespace rdr {
// overrun() either doubles the buffer or adds enough space for
// needed bytes.
- virtual void overrun(size_t needed) {
+ void overrun(size_t needed) override {
size_t len = ptr - start + needed;
if (len < (size_t)(end - start) * 2)
len = (end - start) * 2;
diff --git a/common/rdr/OutStream.h b/common/rdr/OutStream.h
index 8450efd0..2921b232 100644
--- a/common/rdr/OutStream.h
+++ b/common/rdr/OutStream.h
@@ -36,7 +36,7 @@ namespace rdr {
protected:
- OutStream() : ptr(NULL), end(NULL), corked(false) {}
+ OutStream() : ptr(nullptr), end(nullptr), corked(false) {}
public:
diff --git a/common/rdr/RandomStream.cxx b/common/rdr/RandomStream.cxx
index 79a1a0f7..9813abdd 100644
--- a/common/rdr/RandomStream.cxx
+++ b/common/rdr/RandomStream.cxx
@@ -45,9 +45,11 @@ RandomStream::RandomStream()
{
#ifdef RFB_HAVE_WINCRYPT
provider = 0;
- if (!CryptAcquireContext(&provider, 0, 0, PROV_RSA_FULL, 0)) {
+ if (!CryptAcquireContext(&provider, nullptr, nullptr,
+ PROV_RSA_FULL, 0)) {
if (GetLastError() == (DWORD)NTE_BAD_KEYSET) {
- if (!CryptAcquireContext(&provider, 0, 0, PROV_RSA_FULL, CRYPT_NEWKEYSET)) {
+ if (!CryptAcquireContext(&provider, nullptr, nullptr,
+ PROV_RSA_FULL, CRYPT_NEWKEYSET)) {
vlog.error("unable to create keyset");
provider = 0;
}
@@ -68,7 +70,7 @@ RandomStream::RandomStream()
#endif
#endif
vlog.error("no OS supplied random source - using rand()");
- seed += (unsigned int) time(0) + getpid() + getpid() * 987654 + rand();
+ seed += (unsigned int) time(nullptr) + getpid() + getpid() * 987654 + rand();
srand(seed);
}
}
diff --git a/common/rdr/RandomStream.h b/common/rdr/RandomStream.h
index 521012e0..48f373c1 100644
--- a/common/rdr/RandomStream.h
+++ b/common/rdr/RandomStream.h
@@ -40,7 +40,7 @@ namespace rdr {
virtual ~RandomStream();
private:
- virtual bool fillBuffer();
+ bool fillBuffer() override;
private:
static unsigned int seed;
diff --git a/common/rdr/TLSInStream.cxx b/common/rdr/TLSInStream.cxx
index 7ba98155..d13cee1f 100644
--- a/common/rdr/TLSInStream.cxx
+++ b/common/rdr/TLSInStream.cxx
@@ -41,7 +41,7 @@ ssize_t TLSInStream::pull(gnutls_transport_ptr_t str, void* data, size_t size)
self->streamEmpty = false;
delete self->saved_exception;
- self->saved_exception = NULL;
+ self->saved_exception = nullptr;
try {
if (!in->hasData(1)) {
@@ -72,7 +72,7 @@ ssize_t TLSInStream::pull(gnutls_transport_ptr_t str, void* data, size_t size)
}
TLSInStream::TLSInStream(InStream* _in, gnutls_session_t _session)
- : session(_session), in(_in), saved_exception(NULL)
+ : session(_session), in(_in), saved_exception(nullptr)
{
gnutls_transport_ptr_t recv, send;
@@ -83,7 +83,7 @@ TLSInStream::TLSInStream(InStream* _in, gnutls_session_t _session)
TLSInStream::~TLSInStream()
{
- gnutls_transport_set_pull_function(session, NULL);
+ gnutls_transport_set_pull_function(session, nullptr);
delete saved_exception;
}
diff --git a/common/rdr/TLSInStream.h b/common/rdr/TLSInStream.h
index 5b1b716f..ca69ddde 100644
--- a/common/rdr/TLSInStream.h
+++ b/common/rdr/TLSInStream.h
@@ -33,7 +33,7 @@ namespace rdr {
virtual ~TLSInStream();
private:
- virtual bool fillBuffer();
+ bool fillBuffer() override;
size_t readTLS(uint8_t* buf, size_t len);
static ssize_t pull(gnutls_transport_ptr_t str, void* data, size_t size);
diff --git a/common/rdr/TLSOutStream.cxx b/common/rdr/TLSOutStream.cxx
index a06dd285..c2f69310 100644
--- a/common/rdr/TLSOutStream.cxx
+++ b/common/rdr/TLSOutStream.cxx
@@ -41,7 +41,7 @@ ssize_t TLSOutStream::push(gnutls_transport_ptr_t str, const void* data,
OutStream *out = self->out;
delete self->saved_exception;
- self->saved_exception = NULL;
+ self->saved_exception = nullptr;
try {
out->writeBytes((const uint8_t*)data, size);
@@ -62,7 +62,7 @@ ssize_t TLSOutStream::push(gnutls_transport_ptr_t str, const void* data,
}
TLSOutStream::TLSOutStream(OutStream* _out, gnutls_session_t _session)
- : session(_session), out(_out), saved_exception(NULL)
+ : session(_session), out(_out), saved_exception(nullptr)
{
gnutls_transport_ptr_t recv, send;
@@ -79,7 +79,7 @@ TLSOutStream::~TLSOutStream()
} catch (Exception&) {
}
#endif
- gnutls_transport_set_push_function(session, NULL);
+ gnutls_transport_set_push_function(session, nullptr);
delete saved_exception;
}
diff --git a/common/rdr/TLSOutStream.h b/common/rdr/TLSOutStream.h
index 2d365f36..35714238 100644
--- a/common/rdr/TLSOutStream.h
+++ b/common/rdr/TLSOutStream.h
@@ -31,11 +31,11 @@ namespace rdr {
TLSOutStream(OutStream* out, gnutls_session_t session);
virtual ~TLSOutStream();
- virtual void flush();
- virtual void cork(bool enable);
+ void flush() override;
+ void cork(bool enable) override;
private:
- virtual bool flushBuffer();
+ bool flushBuffer() override;
size_t writeTLS(const uint8_t* data, size_t length);
static ssize_t push(gnutls_transport_ptr_t str, const void* data, size_t size);
diff --git a/common/rdr/ZlibInStream.cxx b/common/rdr/ZlibInStream.cxx
index 6441f0a1..a90d50f7 100644
--- a/common/rdr/ZlibInStream.cxx
+++ b/common/rdr/ZlibInStream.cxx
@@ -29,7 +29,7 @@
using namespace rdr;
ZlibInStream::ZlibInStream()
- : underlying(0), zs(NULL), bytesIn(0)
+ : underlying(nullptr), zs(nullptr), bytesIn(0)
{
init();
}
@@ -54,7 +54,7 @@ void ZlibInStream::flushUnderlying()
skip(avail());
}
- setUnderlying(NULL, 0);
+ setUnderlying(nullptr, 0);
}
void ZlibInStream::reset()
@@ -65,28 +65,28 @@ void ZlibInStream::reset()
void ZlibInStream::init()
{
- assert(zs == NULL);
+ assert(zs == nullptr);
zs = new z_stream;
- zs->zalloc = Z_NULL;
- zs->zfree = Z_NULL;
- zs->opaque = Z_NULL;
- zs->next_in = Z_NULL;
+ zs->zalloc = nullptr;
+ zs->zfree = nullptr;
+ zs->opaque = nullptr;
+ zs->next_in = nullptr;
zs->avail_in = 0;
if (inflateInit(zs) != Z_OK) {
delete zs;
- zs = NULL;
+ zs = nullptr;
throw Exception("ZlibInStream: inflateInit failed");
}
}
void ZlibInStream::deinit()
{
- assert(zs != NULL);
- setUnderlying(NULL, 0);
+ assert(zs != nullptr);
+ setUnderlying(nullptr, 0);
inflateEnd(zs);
delete zs;
- zs = NULL;
+ zs = nullptr;
}
bool ZlibInStream::fillBuffer()
diff --git a/common/rdr/ZlibInStream.h b/common/rdr/ZlibInStream.h
index cce6a6e0..a0c31161 100644
--- a/common/rdr/ZlibInStream.h
+++ b/common/rdr/ZlibInStream.h
@@ -44,7 +44,7 @@ namespace rdr {
void init();
void deinit();
- virtual bool fillBuffer();
+ bool fillBuffer() override;
private:
InStream* underlying;
diff --git a/common/rdr/ZlibOutStream.cxx b/common/rdr/ZlibOutStream.cxx
index 63820b8e..0b167711 100644
--- a/common/rdr/ZlibOutStream.cxx
+++ b/common/rdr/ZlibOutStream.cxx
@@ -39,10 +39,10 @@ ZlibOutStream::ZlibOutStream(OutStream* os, int compressLevel)
: underlying(os), compressionLevel(compressLevel), newLevel(compressLevel)
{
zs = new z_stream;
- zs->zalloc = Z_NULL;
- zs->zfree = Z_NULL;
- zs->opaque = Z_NULL;
- zs->next_in = Z_NULL;
+ zs->zalloc = nullptr;
+ zs->zfree = nullptr;
+ zs->opaque = nullptr;
+ zs->next_in = nullptr;
zs->avail_in = 0;
if (deflateInit(zs, compressLevel) != Z_OK) {
delete zs;
@@ -78,14 +78,14 @@ void ZlibOutStream::setCompressionLevel(int level)
void ZlibOutStream::flush()
{
BufferedOutStream::flush();
- if (underlying != NULL)
+ if (underlying != nullptr)
underlying->flush();
}
void ZlibOutStream::cork(bool enable)
{
BufferedOutStream::cork(enable);
- if (underlying != NULL)
+ if (underlying != nullptr)
underlying->cork(enable);
}
diff --git a/common/rdr/ZlibOutStream.h b/common/rdr/ZlibOutStream.h
index 8061a58c..14df2a84 100644
--- a/common/rdr/ZlibOutStream.h
+++ b/common/rdr/ZlibOutStream.h
@@ -35,16 +35,16 @@ namespace rdr {
public:
- ZlibOutStream(OutStream* os=0, int compressionLevel=-1);
+ ZlibOutStream(OutStream* os=nullptr, int compressionLevel=-1);
virtual ~ZlibOutStream();
void setUnderlying(OutStream* os);
void setCompressionLevel(int level=-1);
- virtual void flush();
- virtual void cork(bool enable);
+ void flush() override;
+ void cork(bool enable) override;
private:
- virtual bool flushBuffer();
+ bool flushBuffer() override;
void deflate(int flush);
void checkCompressionLevel();
diff --git a/common/rfb/Blacklist.cxx b/common/rfb/Blacklist.cxx
index 12a54c45..68420ae2 100644
--- a/common/rfb/Blacklist.cxx
+++ b/common/rfb/Blacklist.cxx
@@ -67,7 +67,7 @@ bool Blacklist::isBlackmarked(const char* name) {
// Entry exists - has it reached the threshold yet?
if ((*i).second.marks >= threshold) {
// Yes - entry is blocked - has the timeout expired?
- time_t now = time(0);
+ time_t now = time(nullptr);
if (now >= (*i).second.blockUntil) {
// Timeout has expired. Reset timeout and allow
// a re-try.
diff --git a/common/rfb/CConnection.cxx b/common/rfb/CConnection.cxx
index 0f4fc4f8..0db5f4c8 100644
--- a/common/rfb/CConnection.cxx
+++ b/common/rfb/CConnection.cxx
@@ -25,6 +25,8 @@
#include <stdio.h>
#include <string.h>
+#include <algorithm>
+
#include <rfb/Exception.h>
#include <rfb/clipboardTypes.h>
#include <rfb/fenceTypes.h>
@@ -48,10 +50,10 @@ using namespace rfb;
static LogWriter vlog("CConnection");
CConnection::CConnection()
- : csecurity(0),
+ : csecurity(nullptr),
supportsLocalCursor(false), supportsCursorPosition(false),
supportsDesktopResize(false), supportsLEDState(false),
- is(0), os(0), reader_(0), writer_(0),
+ is(nullptr), os(nullptr), reader_(nullptr), writer_(nullptr),
shared(false),
state_(RFBSTATE_UNINITIALISED),
pendingPFChange(false), preferredEncoding(encodingTight),
@@ -59,7 +61,7 @@ CConnection::CConnection()
formatChange(false), encodingChange(false),
firstUpdate(true), pendingUpdate(false), continuousUpdates(false),
forceNonincremental(true),
- framebuffer(NULL), decoder(this),
+ framebuffer(nullptr), decoder(this),
hasRemoteClipboard(false), hasLocalClipboard(false)
{
}
@@ -71,7 +73,7 @@ CConnection::~CConnection()
void CConnection::setServerName(const char* name_)
{
- if (name_ == NULL)
+ if (name_ == nullptr)
name_ = "";
serverName = name_;
}
@@ -91,7 +93,7 @@ void CConnection::setFramebuffer(ModifiablePixelBuffer* fb)
assert(fb->height() == server.height());
}
- if ((framebuffer != NULL) && (fb != NULL)) {
+ if ((framebuffer != nullptr) && (fb != nullptr)) {
Rect rect;
const uint8_t* data;
@@ -226,14 +228,8 @@ bool CConnection::processSecurityTypesMsg()
state_ = RFBSTATE_SECURITY_REASON;
return true;
} else if (secType == secTypeNone || secType == secTypeVncAuth) {
- std::list<uint8_t>::iterator i;
- for (i = secTypes.begin(); i != secTypes.end(); i++)
- if (*i == secType) {
- secType = *i;
- break;
- }
-
- if (i == secTypes.end())
+ if (std::find(secTypes.begin(), secTypes.end(),
+ secType) == secTypes.end())
secType = secTypeInvalid;
} else {
vlog.error("Unknown 3.3 security type %d", secType);
@@ -260,8 +256,6 @@ bool CConnection::processSecurityTypesMsg()
return true;
}
- std::list<uint8_t>::iterator j;
-
for (int i = 0; i < nServerSecTypes; i++) {
uint8_t serverSecType = is->readU8();
vlog.debug("Server offers security type %s(%d)",
@@ -272,12 +266,10 @@ bool CConnection::processSecurityTypesMsg()
* It means server's order specifies priority.
*/
if (secType == secTypeInvalid) {
- for (j = secTypes.begin(); j != secTypes.end(); j++)
- if (*j == serverSecType) {
- secType = *j;
- break;
- }
- }
+ if (std::find(secTypes.begin(), secTypes.end(),
+ serverSecType) != secTypes.end())
+ secType = serverSecType;
+ }
}
// Inform the server of our decision
@@ -399,13 +391,13 @@ void CConnection::close()
vlog.error("%s", e.str());
}
- setFramebuffer(NULL);
+ setFramebuffer(nullptr);
delete csecurity;
- csecurity = NULL;
+ csecurity = nullptr;
delete reader_;
- reader_ = NULL;
+ reader_ = nullptr;
delete writer_;
- writer_ = NULL;
+ writer_ = nullptr;
}
void CConnection::setDesktopSize(int w, int h)
@@ -420,7 +412,7 @@ void CConnection::setDesktopSize(int w, int h)
server.height());
resizeFramebuffer();
- assert(framebuffer != NULL);
+ assert(framebuffer != nullptr);
assert(framebuffer->width() == server.width());
assert(framebuffer->height() == server.height());
}
@@ -440,7 +432,7 @@ void CConnection::setExtendedDesktopSize(unsigned reason,
server.height());
resizeFramebuffer();
- assert(framebuffer != NULL);
+ assert(framebuffer != nullptr);
assert(framebuffer->width() == server.width());
assert(framebuffer->height() == server.height());
}
@@ -471,7 +463,7 @@ void CConnection::serverInit(int width, int height,
vlog.debug("initialisation done");
initDone();
- assert(framebuffer != NULL);
+ assert(framebuffer != nullptr);
assert(framebuffer->width() == server.width());
assert(framebuffer->height() == server.height());
@@ -501,7 +493,7 @@ void CConnection::framebufferUpdateStart()
{
CMsgHandler::framebufferUpdateStart();
- assert(framebuffer != NULL);
+ assert(framebuffer != nullptr);
// Note: This might not be true if continuous updates are supported
pendingUpdate = false;
@@ -683,7 +675,7 @@ void CConnection::sendClipboardData(const char* data)
// FIXME: This conversion magic should be in CMsgWriter
std::string filtered(convertCRLF(data));
size_t sizes[1] = { filtered.size() + 1 };
- const uint8_t* data[1] = { (const uint8_t*)filtered.c_str() };
+ const uint8_t* datas[1] = { (const uint8_t*)filtered.c_str() };
if (unsolicitedClipboardAttempt) {
unsolicitedClipboardAttempt = false;
@@ -695,7 +687,7 @@ void CConnection::sendClipboardData(const char* data)
}
}
- writer()->writeClipboardProvide(rfb::clipboardUTF8, sizes, data);
+ writer()->writeClipboardProvide(rfb::clipboardUTF8, sizes, datas);
} else {
writer()->writeClientCutText(data);
}
diff --git a/common/rfb/CConnection.h b/common/rfb/CConnection.h
index df0fbb14..dca98a92 100644
--- a/common/rfb/CConnection.h
+++ b/common/rfb/CConnection.h
@@ -97,34 +97,32 @@ namespace rfb {
// Note: These must be called by any deriving classes
- virtual void setDesktopSize(int w, int h);
- virtual void setExtendedDesktopSize(unsigned reason, unsigned result,
- int w, int h,
- const ScreenSet& layout);
+ void setDesktopSize(int w, int h) override;
+ void setExtendedDesktopSize(unsigned reason, unsigned result,
+ int w, int h,
+ const ScreenSet& layout) override;
- virtual void endOfContinuousUpdates();
+ void endOfContinuousUpdates() override;
- virtual void serverInit(int width, int height,
- const PixelFormat& pf,
- const char* name);
+ void serverInit(int width, int height, const PixelFormat& pf,
+ const char* name) override;
- virtual bool readAndDecodeRect(const Rect& r, int encoding,
- ModifiablePixelBuffer* pb);
+ bool readAndDecodeRect(const Rect& r, int encoding,
+ ModifiablePixelBuffer* pb) override;
- virtual void framebufferUpdateStart();
- virtual void framebufferUpdateEnd();
- virtual bool dataRect(const Rect& r, int encoding);
+ void framebufferUpdateStart() override;
+ void framebufferUpdateEnd() override;
+ bool dataRect(const Rect& r, int encoding) override;
- virtual void serverCutText(const char* str);
+ void serverCutText(const char* str) override;
- virtual void handleClipboardCaps(uint32_t flags,
- const uint32_t* lengths);
- virtual void handleClipboardRequest(uint32_t flags);
- virtual void handleClipboardPeek();
- virtual void handleClipboardNotify(uint32_t flags);
- virtual void handleClipboardProvide(uint32_t flags,
- const size_t* lengths,
- const uint8_t* const* data);
+ void handleClipboardCaps(uint32_t flags,
+ const uint32_t* lengths) override;
+ void handleClipboardRequest(uint32_t flags) override;
+ void handleClipboardPeek() override;
+ void handleClipboardNotify(uint32_t flags) override;
+ void handleClipboardProvide(uint32_t flags, const size_t* lengths,
+ const uint8_t* const* data) override;
// Methods to be overridden in a derived class
@@ -249,7 +247,7 @@ namespace rfb {
// responds to requests, stating no support for synchronisation.
// When overriding, call CMsgHandler::fence() directly in order to
// state correct support for fence flags.
- virtual void fence(uint32_t flags, unsigned len, const uint8_t data[]);
+ void fence(uint32_t flags, unsigned len, const uint8_t data[]) override;
private:
bool processVersionMsg();
diff --git a/common/rfb/CMsgReader.cxx b/common/rfb/CMsgReader.cxx
index 006645df..8bcdbfd0 100644
--- a/common/rfb/CMsgReader.cxx
+++ b/common/rfb/CMsgReader.cxx
@@ -385,7 +385,7 @@ bool CMsgReader::readExtendedClipboard(int32_t len)
}
zis.flushUnderlying();
- zis.setUnderlying(NULL, 0);
+ zis.setUnderlying(nullptr, 0);
handler->handleClipboardProvide(flags, lengths, buffers);
@@ -827,31 +827,31 @@ bool CMsgReader::readExtendedDesktopSize(int x, int y, int w, int h)
bool CMsgReader::readLEDState()
{
- uint8_t state;
+ uint8_t ledState;
if (!is->hasData(1))
return false;
- state = is->readU8();
+ ledState = is->readU8();
- handler->setLEDState(state);
+ handler->setLEDState(ledState);
return true;
}
bool CMsgReader::readVMwareLEDState()
{
- uint32_t state;
+ uint32_t ledState;
if (!is->hasData(4))
return false;
- state = is->readU32();
+ ledState = is->readU32();
// As luck has it, this extension uses the same bit definitions,
// so no conversion required
- handler->setLEDState(state);
+ handler->setLEDState(ledState);
return true;
}
diff --git a/common/rfb/CMsgWriter.cxx b/common/rfb/CMsgWriter.cxx
index e941aaa7..7d757968 100644
--- a/common/rfb/CMsgWriter.cxx
+++ b/common/rfb/CMsgWriter.cxx
@@ -65,12 +65,11 @@ void CMsgWriter::writeSetPixelFormat(const PixelFormat& pf)
void CMsgWriter::writeSetEncodings(const std::list<uint32_t> encodings)
{
- std::list<uint32_t>::const_iterator iter;
startMsg(msgTypeSetEncodings);
os->pad(1);
os->writeU16(encodings.size());
- for (iter = encodings.begin(); iter != encodings.end(); ++iter)
- os->writeU32(*iter);
+ for (uint32_t encoding : encodings)
+ os->writeU32(encoding);
endMsg();
}
@@ -192,7 +191,7 @@ void CMsgWriter::writePointerEvent(const Point& pos, int buttonMask)
void CMsgWriter::writeClientCutText(const char* str)
{
- if (strchr(str, '\r') != NULL)
+ if (strchr(str, '\r') != nullptr)
throw Exception("Invalid carriage return in clipboard data");
std::string latin1(utf8ToLatin1(str));
diff --git a/common/rfb/CSecurityDH.cxx b/common/rfb/CSecurityDH.cxx
index f6e5ded4..6d9650bd 100644
--- a/common/rfb/CSecurityDH.cxx
+++ b/common/rfb/CSecurityDH.cxx
@@ -47,8 +47,8 @@ using namespace rfb;
const int MinKeyLength = 128;
const int MaxKeyLength = 1024;
-CSecurityDH::CSecurityDH(CConnection* cc)
- : CSecurity(cc), keyLength(0)
+CSecurityDH::CSecurityDH(CConnection* cc_)
+ : CSecurity(cc_), keyLength(0)
{
mpz_init(g);
mpz_init(p);
diff --git a/common/rfb/CSecurityDH.h b/common/rfb/CSecurityDH.h
index d0e5e894..df33d29b 100644
--- a/common/rfb/CSecurityDH.h
+++ b/common/rfb/CSecurityDH.h
@@ -33,9 +33,9 @@ namespace rfb {
public:
CSecurityDH(CConnection* cc);
virtual ~CSecurityDH();
- virtual bool processMsg();
- virtual int getType() const { return secTypeDH; }
- virtual bool isSecure() const { return false; }
+ bool processMsg() override;
+ int getType() const override { return secTypeDH; }
+ bool isSecure() const override { return false; }
private:
bool readKey();
diff --git a/common/rfb/CSecurityMSLogonII.cxx b/common/rfb/CSecurityMSLogonII.cxx
index d7e23715..e721cdfc 100644
--- a/common/rfb/CSecurityMSLogonII.cxx
+++ b/common/rfb/CSecurityMSLogonII.cxx
@@ -44,8 +44,8 @@
using namespace rfb;
-CSecurityMSLogonII::CSecurityMSLogonII(CConnection* cc)
- : CSecurity(cc)
+CSecurityMSLogonII::CSecurityMSLogonII(CConnection* cc_)
+ : CSecurity(cc_)
{
mpz_init(g);
mpz_init(p);
diff --git a/common/rfb/CSecurityMSLogonII.h b/common/rfb/CSecurityMSLogonII.h
index f7c83a3e..71600c85 100644
--- a/common/rfb/CSecurityMSLogonII.h
+++ b/common/rfb/CSecurityMSLogonII.h
@@ -33,9 +33,9 @@ namespace rfb {
public:
CSecurityMSLogonII(CConnection* cc);
virtual ~CSecurityMSLogonII();
- virtual bool processMsg();
- virtual int getType() const { return secTypeMSLogonII; }
- virtual bool isSecure() const { return false; }
+ bool processMsg() override;
+ int getType() const override { return secTypeMSLogonII; }
+ bool isSecure() const override { return false; }
private:
bool readKey();
diff --git a/common/rfb/CSecurityNone.h b/common/rfb/CSecurityNone.h
index cb887914..df685d0d 100644
--- a/common/rfb/CSecurityNone.h
+++ b/common/rfb/CSecurityNone.h
@@ -29,9 +29,9 @@ namespace rfb {
class CSecurityNone : public CSecurity {
public:
- CSecurityNone(CConnection* cc) : CSecurity(cc) {}
- virtual bool processMsg() { return true; }
- virtual int getType() const {return secTypeNone;}
+ CSecurityNone(CConnection* cc_) : CSecurity(cc_) {}
+ bool processMsg() override { return true; }
+ int getType() const override {return secTypeNone;}
};
}
#endif
diff --git a/common/rfb/CSecurityPlain.h b/common/rfb/CSecurityPlain.h
index add7e776..0dbf4064 100644
--- a/common/rfb/CSecurityPlain.h
+++ b/common/rfb/CSecurityPlain.h
@@ -26,9 +26,9 @@ namespace rfb {
class CSecurityPlain : public CSecurity {
public:
- CSecurityPlain(CConnection* cc) : CSecurity(cc) {}
- virtual bool processMsg();
- virtual int getType() const { return secTypePlain; }
+ CSecurityPlain(CConnection* cc_) : CSecurity(cc_) {}
+ bool processMsg() override;
+ int getType() const override { return secTypePlain; }
};
}
#endif
diff --git a/common/rfb/CSecurityRSAAES.cxx b/common/rfb/CSecurityRSAAES.cxx
index 5a4bc9c9..96d96b01 100644
--- a/common/rfb/CSecurityRSAAES.cxx
+++ b/common/rfb/CSecurityRSAAES.cxx
@@ -56,14 +56,14 @@ const int MaxKeyLength = 8192;
using namespace rfb;
-CSecurityRSAAES::CSecurityRSAAES(CConnection* cc, uint32_t _secType,
+CSecurityRSAAES::CSecurityRSAAES(CConnection* cc_, uint32_t _secType,
int _keySize, bool _isAllEncrypted)
- : CSecurity(cc), state(ReadPublicKey),
+ : CSecurity(cc_), state(ReadPublicKey),
keySize(_keySize), isAllEncrypted(_isAllEncrypted), secType(_secType),
clientKey(), clientPublicKey(), serverKey(),
- serverKeyN(NULL), serverKeyE(NULL),
- clientKeyN(NULL), clientKeyE(NULL),
- rais(NULL), raos(NULL), rawis(NULL), rawos(NULL)
+ serverKeyN(nullptr), serverKeyE(nullptr),
+ clientKeyN(nullptr), clientKeyE(nullptr),
+ rais(nullptr), raos(nullptr), rawis(nullptr), rawos(nullptr)
{
assert(keySize == 128 || keySize == 256);
}
@@ -154,7 +154,8 @@ void CSecurityRSAAES::writePublicKey()
// set e = 65537
mpz_set_ui(clientPublicKey.e, 65537);
if (!rsa_generate_keypair(&clientPublicKey, &clientKey,
- &rs, random_func, NULL, NULL, clientKeyLength, 0))
+ &rs, random_func, nullptr, nullptr,
+ clientKeyLength, 0))
throw AuthFailureException("failed to generate key");
clientKeyN = new uint8_t[rsaKeySize];
clientKeyE = new uint8_t[rsaKeySize];
@@ -413,10 +414,10 @@ void CSecurityRSAAES::clearSecrets()
delete[] serverKeyE;
delete[] clientKeyN;
delete[] clientKeyE;
- serverKeyN = NULL;
- serverKeyE = NULL;
- clientKeyN = NULL;
- clientKeyE = NULL;
+ serverKeyN = nullptr;
+ serverKeyE = nullptr;
+ clientKeyN = nullptr;
+ clientKeyE = nullptr;
memset(serverRandom, 0, sizeof(serverRandom));
memset(clientRandom, 0, sizeof(clientRandom));
}
@@ -439,7 +440,7 @@ void CSecurityRSAAES::writeCredentials()
if (subtype == secTypeRA2UserPass)
(CSecurity::upg)->getUserPasswd(isSecure(), &username, &password);
else
- (CSecurity::upg)->getUserPasswd(isSecure(), NULL, &password);
+ (CSecurity::upg)->getUserPasswd(isSecure(), nullptr, &password);
if (subtype == secTypeRA2UserPass) {
if (username.size() > 255)
diff --git a/common/rfb/CSecurityRSAAES.h b/common/rfb/CSecurityRSAAES.h
index 543b0152..29bfd575 100644
--- a/common/rfb/CSecurityRSAAES.h
+++ b/common/rfb/CSecurityRSAAES.h
@@ -39,9 +39,9 @@ namespace rfb {
CSecurityRSAAES(CConnection* cc, uint32_t secType,
int keySize, bool isAllEncrypted);
virtual ~CSecurityRSAAES();
- virtual bool processMsg();
- virtual int getType() const { return secType; }
- virtual bool isSecure() const { return secType == secTypeRA256; }
+ bool processMsg() override;
+ int getType() const override { return secType; }
+ bool isSecure() const override { return secType == secTypeRA256; }
static IntParameter RSAKeyLength;
diff --git a/common/rfb/CSecurityStack.cxx b/common/rfb/CSecurityStack.cxx
index 6b8da8dd..838d68ac 100644
--- a/common/rfb/CSecurityStack.cxx
+++ b/common/rfb/CSecurityStack.cxx
@@ -25,9 +25,9 @@
using namespace rfb;
-CSecurityStack::CSecurityStack(CConnection* cc, int Type,
+CSecurityStack::CSecurityStack(CConnection* cc_, int Type,
CSecurity* s0, CSecurity* s1)
- : CSecurity(cc), type(Type)
+ : CSecurity(cc_), type(Type)
{
state = 0;
state0 = s0;
diff --git a/common/rfb/CSecurityStack.h b/common/rfb/CSecurityStack.h
index 56ac3fea..521597ec 100644
--- a/common/rfb/CSecurityStack.h
+++ b/common/rfb/CSecurityStack.h
@@ -28,11 +28,11 @@ namespace rfb {
class CSecurityStack : public CSecurity {
public:
CSecurityStack(CConnection* cc, int Type,
- CSecurity* s0 = NULL, CSecurity* s1 = NULL);
+ CSecurity* s0 = nullptr, CSecurity* s1 = nullptr);
~CSecurityStack();
- virtual bool processMsg();
- virtual int getType() const {return type;};
- virtual bool isSecure() const;
+ bool processMsg() override;
+ int getType() const override {return type;};
+ bool isSecure() const override;
protected:
int state;
CSecurity* state0;
diff --git a/common/rfb/CSecurityTLS.cxx b/common/rfb/CSecurityTLS.cxx
index 11e6dfe3..8d8b58fd 100644
--- a/common/rfb/CSecurityTLS.cxx
+++ b/common/rfb/CSecurityTLS.cxx
@@ -75,16 +75,18 @@ static const char* configdirfn(const char* fn)
const char* configdir;
configdir = os::getvncconfigdir();
- if (configdir == NULL)
+ if (configdir == nullptr)
return "";
snprintf(full_path, sizeof(full_path), "%s/%s", configdir, fn);
return full_path;
}
-CSecurityTLS::CSecurityTLS(CConnection* cc, bool _anon)
- : CSecurity(cc), session(NULL), anon_cred(NULL), cert_cred(NULL),
- anon(_anon), tlsis(NULL), tlsos(NULL), rawis(NULL), rawos(NULL)
+CSecurityTLS::CSecurityTLS(CConnection* cc_, bool _anon)
+ : CSecurity(cc_), session(nullptr),
+ anon_cred(nullptr), cert_cred(nullptr),
+ anon(_anon), tlsis(nullptr), tlsos(nullptr),
+ rawis(nullptr), rawos(nullptr)
{
if (gnutls_global_init() != GNUTLS_E_SUCCESS)
throw AuthFailureException("gnutls_global_init failed");
@@ -103,32 +105,32 @@ void CSecurityTLS::shutdown()
if (anon_cred) {
gnutls_anon_free_client_credentials(anon_cred);
- anon_cred = 0;
+ anon_cred = nullptr;
}
if (cert_cred) {
gnutls_certificate_free_credentials(cert_cred);
- cert_cred = 0;
+ cert_cred = nullptr;
}
if (rawis && rawos) {
cc->setStreams(rawis, rawos);
- rawis = NULL;
- rawos = NULL;
+ rawis = nullptr;
+ rawos = nullptr;
}
if (tlsis) {
delete tlsis;
- tlsis = NULL;
+ tlsis = nullptr;
}
if (tlsos) {
delete tlsos;
- tlsos = NULL;
+ tlsos = nullptr;
}
if (session) {
gnutls_deinit(session);
- session = 0;
+ session = nullptr;
}
}
@@ -206,7 +208,7 @@ void CSecurityTLS::setParam()
prio = (char*)malloc(strlen(Security::GnuTLSPriority) +
strlen(kx_anon_priority) + 1);
- if (prio == NULL)
+ if (prio == nullptr)
throw AuthFailureException("Not enough memory for GnuTLS priority string");
strcpy(prio, Security::GnuTLSPriority);
@@ -242,7 +244,7 @@ void CSecurityTLS::setParam()
prio = (char*)malloc(strlen(gnutls_default_priority) +
strlen(kx_anon_priority) + 1);
- if (prio == NULL)
+ if (prio == nullptr)
throw AuthFailureException("Not enough memory for GnuTLS priority string");
strcpy(prio, gnutls_default_priority);
@@ -385,7 +387,7 @@ void CSecurityTLS::checkSession()
/* Certificate has some user overridable problems, so TOFU time */
hostsDir = os::getvncstatedir();
- if (hostsDir == NULL) {
+ if (hostsDir == nullptr) {
throw AuthFailureException("Could not obtain VNC state directory "
"path for known hosts storage");
}
@@ -393,8 +395,8 @@ void CSecurityTLS::checkSession()
std::string dbPath;
dbPath = (std::string)hostsDir + "/x509_known_hosts";
- err = gnutls_verify_stored_pubkey(dbPath.c_str(), NULL,
- client->getServerName(), NULL,
+ err = gnutls_verify_stored_pubkey(dbPath.c_str(), nullptr,
+ client->getServerName(), nullptr,
GNUTLS_CRT_X509, &cert_list[0], 0);
/* Previously known? */
@@ -648,8 +650,9 @@ void CSecurityTLS::checkSession()
}
}
- if (gnutls_store_pubkey(dbPath.c_str(), NULL, client->getServerName(),
- NULL, GNUTLS_CRT_X509, &cert_list[0], 0, 0))
+ if (gnutls_store_pubkey(dbPath.c_str(), nullptr,
+ client->getServerName(), nullptr,
+ GNUTLS_CRT_X509, &cert_list[0], 0, 0))
vlog.error("Failed to store server certificate to known hosts database");
vlog.info("Exception added for server host");
diff --git a/common/rfb/CSecurityTLS.h b/common/rfb/CSecurityTLS.h
index b9c345cf..8688b742 100644
--- a/common/rfb/CSecurityTLS.h
+++ b/common/rfb/CSecurityTLS.h
@@ -38,9 +38,9 @@ namespace rfb {
public:
CSecurityTLS(CConnection* cc, bool _anon);
virtual ~CSecurityTLS();
- virtual bool processMsg();
- virtual int getType() const { return anon ? secTypeTLSNone : secTypeX509None; }
- virtual bool isSecure() const { return !anon; }
+ bool processMsg() override;
+ int getType() const override { return anon ? secTypeTLSNone : secTypeX509None; }
+ bool isSecure() const override { return !anon; }
static StringParameter X509CA;
static StringParameter X509CRL;
diff --git a/common/rfb/CSecurityVeNCrypt.cxx b/common/rfb/CSecurityVeNCrypt.cxx
index 3c8e91ba..19dcabc3 100644
--- a/common/rfb/CSecurityVeNCrypt.cxx
+++ b/common/rfb/CSecurityVeNCrypt.cxx
@@ -26,13 +26,15 @@
#include <config.h>
#endif
+#include <algorithm>
+#include <list>
+
#include <rfb/Exception.h>
#include <rdr/InStream.h>
#include <rdr/OutStream.h>
#include <rfb/CConnection.h>
#include <rfb/CSecurityVeNCrypt.h>
#include <rfb/LogWriter.h>
-#include <list>
using namespace rfb;
using namespace rdr;
@@ -40,8 +42,9 @@ using namespace std;
static LogWriter vlog("CVeNCrypt");
-CSecurityVeNCrypt::CSecurityVeNCrypt(CConnection* cc, SecurityClient* sec)
- : CSecurity(cc), csecurity(NULL), security(sec)
+CSecurityVeNCrypt::CSecurityVeNCrypt(CConnection* cc_,
+ SecurityClient* sec)
+ : CSecurity(cc_), csecurity(nullptr), security(sec)
{
haveRecvdMajorVersion = false;
haveRecvdMinorVersion = false;
@@ -54,7 +57,7 @@ CSecurityVeNCrypt::CSecurityVeNCrypt(CConnection* cc, SecurityClient* sec)
minorVersion = 0;
chosenType = secTypeVeNCrypt;
nAvailableTypes = 0;
- availableTypes = NULL;
+ availableTypes = nullptr;
}
CSecurityVeNCrypt::~CSecurityVeNCrypt()
@@ -156,22 +159,17 @@ bool CSecurityVeNCrypt::processMsg()
if (!haveChosenType) {
chosenType = secTypeInvalid;
uint8_t i;
- list<uint32_t>::iterator j;
list<uint32_t> secTypes;
secTypes = security->GetEnabledExtSecTypes();
/* Honor server's security type order */
for (i = 0; i < nAvailableTypes; i++) {
- for (j = secTypes.begin(); j != secTypes.end(); j++) {
- if (*j == availableTypes[i]) {
- chosenType = *j;
- break;
- }
- }
-
- if (chosenType != secTypeInvalid)
- break;
+ if (std::find(secTypes.begin(), secTypes.end(),
+ availableTypes[i]) != secTypes.end()) {
+ chosenType = availableTypes[i];
+ break;
+ }
}
/* Set up the stack according to the chosen type: */
diff --git a/common/rfb/CSecurityVeNCrypt.h b/common/rfb/CSecurityVeNCrypt.h
index 476bf813..f73e7927 100644
--- a/common/rfb/CSecurityVeNCrypt.h
+++ b/common/rfb/CSecurityVeNCrypt.h
@@ -37,9 +37,9 @@ namespace rfb {
CSecurityVeNCrypt(CConnection* cc, SecurityClient* sec);
~CSecurityVeNCrypt();
- virtual bool processMsg();
- int getType() const {return chosenType;}
- virtual bool isSecure() const;
+ bool processMsg() override;
+ int getType() const override {return chosenType;}
+ bool isSecure() const override;
protected:
CSecurity *csecurity;
diff --git a/common/rfb/CSecurityVncAuth.cxx b/common/rfb/CSecurityVncAuth.cxx
index f6a5e07a..e5f842ba 100644
--- a/common/rfb/CSecurityVncAuth.cxx
+++ b/common/rfb/CSecurityVncAuth.cxx
@@ -54,7 +54,7 @@ bool CSecurityVncAuth::processMsg()
uint8_t challenge[vncAuthChallengeSize];
is->readBytes(challenge, vncAuthChallengeSize);
std::string passwd;
- (CSecurity::upg)->getUserPasswd(cc->isSecure(), 0, &passwd);
+ (CSecurity::upg)->getUserPasswd(cc->isSecure(), nullptr, &passwd);
// Calculate the correct response
uint8_t key[8];
diff --git a/common/rfb/CSecurityVncAuth.h b/common/rfb/CSecurityVncAuth.h
index 3f1f315b..9a9cf6e0 100644
--- a/common/rfb/CSecurityVncAuth.h
+++ b/common/rfb/CSecurityVncAuth.h
@@ -25,10 +25,10 @@ namespace rfb {
class CSecurityVncAuth : public CSecurity {
public:
- CSecurityVncAuth(CConnection* cc) : CSecurity(cc) {}
+ CSecurityVncAuth(CConnection* cc_) : CSecurity(cc_) {}
virtual ~CSecurityVncAuth() {}
- virtual bool processMsg();
- virtual int getType() const {return secTypeVncAuth;};
+ bool processMsg() override;
+ int getType() const override {return secTypeVncAuth;};
};
}
#endif
diff --git a/common/rfb/ClientParams.cxx b/common/rfb/ClientParams.cxx
index ade99018..bc20c3d7 100644
--- a/common/rfb/ClientParams.cxx
+++ b/common/rfb/ClientParams.cxx
@@ -39,7 +39,7 @@ ClientParams::ClientParams()
{
setName("");
- cursor_ = new Cursor(0, 0, Point(), NULL);
+ cursor_ = new Cursor(0, 0, Point(), nullptr);
clipFlags = clipboardUTF8 | clipboardRTF | clipboardHTML |
clipboardRequest | clipboardNotify | clipboardProvide;
diff --git a/common/rfb/Configuration.cxx b/common/rfb/Configuration.cxx
index 1c215c7f..f58a9c2f 100644
--- a/common/rfb/Configuration.cxx
+++ b/common/rfb/Configuration.cxx
@@ -48,9 +48,9 @@ static LogWriter vlog("Config");
// -=- The Global/server/viewer Configuration objects
-Configuration* Configuration::global_ = 0;
-Configuration* Configuration::server_ = 0;
-Configuration* Configuration::viewer_ = 0;
+Configuration* Configuration::global_ = nullptr;
+Configuration* Configuration::server_ = nullptr;
+Configuration* Configuration::viewer_ = nullptr;
Configuration* Configuration::global() {
if (!global_)
@@ -76,13 +76,13 @@ bool Configuration::set(const char* n, const char* v, bool immutable) {
return set(n, strlen(n), v, immutable);
}
-bool Configuration::set(const char* name, int len,
+bool Configuration::set(const char* paramName, int len,
const char* val, bool immutable)
{
VoidParameter* current = head;
while (current) {
if ((int)strlen(current->getName()) == len &&
- strncasecmp(current->getName(), name, len) == 0)
+ strncasecmp(current->getName(), paramName, len) == 0)
{
bool b = current->setParam(val);
if (b && immutable)
@@ -91,7 +91,7 @@ bool Configuration::set(const char* name, int len,
}
current = current->_next;
}
- return _next ? _next->set(name, len, val, immutable) : false;
+ return _next ? _next->set(paramName, len, val, immutable) : false;
}
bool Configuration::set(const char* config, bool immutable) {
@@ -127,7 +127,7 @@ VoidParameter* Configuration::get(const char* param)
return current;
current = current->_next;
}
- return _next ? _next->get(param) : 0;
+ return _next ? _next->get(param) : nullptr;
}
void Configuration::list(int width, int nameWidth) {
@@ -195,7 +195,7 @@ VoidParameter::VoidParameter(const char* name_, const char* desc_,
ConfigurationObject co)
: immutable(false), name(name_), description(desc_)
{
- Configuration *conf = NULL;
+ Configuration *conf = nullptr;
switch (co) {
case ConfGlobal: conf = Configuration::global();
@@ -339,7 +339,7 @@ IntParameter::IntParameter(const char* name_, const char* desc_, int v,
bool
IntParameter::setParam(const char* v) {
if (immutable) return true;
- return setParam(strtol(v, NULL, 0));
+ return setParam(strtol(v, nullptr, 0));
}
bool
@@ -410,7 +410,8 @@ StringParameter::operator const char *() const {
BinaryParameter::BinaryParameter(const char* name_, const char* desc_,
const uint8_t* v, size_t l, ConfigurationObject co)
-: VoidParameter(name_, desc_, co), value(0), length(0), def_value(0), def_length(0) {
+: VoidParameter(name_, desc_, co),
+ value(nullptr), length(0), def_value(nullptr), def_length(0) {
if (l) {
assert(v);
value = new uint8_t[l];
@@ -440,7 +441,7 @@ void BinaryParameter::setParam(const uint8_t* v, size_t len) {
if (immutable) return;
vlog.debug("set %s(Binary)", getName());
delete [] value;
- value = NULL;
+ value = nullptr;
length = 0;
if (len) {
assert(v);
diff --git a/common/rfb/Configuration.h b/common/rfb/Configuration.h
index d73d8005..ec8d789a 100644
--- a/common/rfb/Configuration.h
+++ b/common/rfb/Configuration.h
@@ -64,7 +64,8 @@ namespace rfb {
class Configuration {
public:
// - Create a new Configuration object
- Configuration(const char* name_) : name(name_), head(0), _next(0) {}
+ Configuration(const char* name_)
+ : name(name_), head(nullptr), _next(nullptr) {}
// - Return the buffer containing the Configuration's name
const char* getName() const { return name.c_str(); }
@@ -195,12 +196,12 @@ namespace rfb {
public:
AliasParameter(const char* name_, const char* desc_,VoidParameter* param_,
ConfigurationObject co=ConfGlobal);
- virtual bool setParam(const char* value);
- virtual bool setParam();
- virtual std::string getDefaultStr() const;
- virtual std::string getValueStr() const;
- virtual bool isBool() const;
- virtual void setImmutable();
+ bool setParam(const char* value) override;
+ bool setParam() override;
+ std::string getDefaultStr() const override;
+ std::string getValueStr() const override;
+ bool isBool() const override;
+ void setImmutable() override;
private:
VoidParameter* param;
};
@@ -209,12 +210,12 @@ namespace rfb {
public:
BoolParameter(const char* name_, const char* desc_, bool v,
ConfigurationObject co=ConfGlobal);
- virtual bool setParam(const char* value);
- virtual bool setParam();
+ bool setParam(const char* value) override;
+ bool setParam() override;
virtual void setParam(bool b);
- virtual std::string getDefaultStr() const;
- virtual std::string getValueStr() const;
- virtual bool isBool() const;
+ std::string getDefaultStr() const override;
+ std::string getValueStr() const override;
+ bool isBool() const override;
operator bool() const;
protected:
bool value;
@@ -227,10 +228,10 @@ namespace rfb {
int minValue=INT_MIN, int maxValue=INT_MAX,
ConfigurationObject co=ConfGlobal);
using VoidParameter::setParam;
- virtual bool setParam(const char* value);
+ bool setParam(const char* value) override;
virtual bool setParam(int v);
- virtual std::string getDefaultStr() const;
- virtual std::string getValueStr() const;
+ std::string getDefaultStr() const override;
+ std::string getValueStr() const override;
operator int() const;
protected:
int value;
@@ -244,10 +245,10 @@ namespace rfb {
// be Null, and so neither can the default value!
StringParameter(const char* name_, const char* desc_, const char* v,
ConfigurationObject co=ConfGlobal);
- virtual ~StringParameter();
- virtual bool setParam(const char* value);
- virtual std::string getDefaultStr() const;
- virtual std::string getValueStr() const;
+ ~StringParameter() override;
+ bool setParam(const char* value) override;
+ std::string getDefaultStr() const override;
+ std::string getValueStr() const override;
operator const char*() const;
protected:
std::string value;
@@ -260,11 +261,11 @@ namespace rfb {
const uint8_t* v, size_t l,
ConfigurationObject co=ConfGlobal);
using VoidParameter::setParam;
- virtual ~BinaryParameter();
- virtual bool setParam(const char* value);
+ ~BinaryParameter() override;
+ bool setParam(const char* value) override;
virtual void setParam(const uint8_t* v, size_t l);
- virtual std::string getDefaultStr() const;
- virtual std::string getValueStr() const;
+ std::string getDefaultStr() const override;
+ std::string getValueStr() const override;
std::vector<uint8_t> getData() const;
diff --git a/common/rfb/Congestion.cxx b/common/rfb/Congestion.cxx
index 1e252165..94f07055 100644
--- a/common/rfb/Congestion.cxx
+++ b/common/rfb/Congestion.cxx
@@ -85,11 +85,11 @@ Congestion::Congestion() :
baseRTT(-1), congWindow(INITIAL_WINDOW), inSlowStart(true),
safeBaseRTT(-1), measurements(0), minRTT(-1), minCongestedRTT(-1)
{
- gettimeofday(&lastUpdate, NULL);
- gettimeofday(&lastSent, NULL);
+ gettimeofday(&lastUpdate, nullptr);
+ gettimeofday(&lastSent, nullptr);
memset(&lastPong, 0, sizeof(lastPong));
- gettimeofday(&lastPongArrival, NULL);
- gettimeofday(&lastAdjustment, NULL);
+ gettimeofday(&lastPongArrival, nullptr);
+ gettimeofday(&lastAdjustment, nullptr);
}
Congestion::~Congestion()
@@ -101,7 +101,7 @@ void Congestion::updatePosition(unsigned pos)
struct timeval now;
unsigned delta, consumed;
- gettimeofday(&now, NULL);
+ gettimeofday(&now, nullptr);
delta = pos - lastPosition;
if ((delta > 0) || (extraBuffer > 0))
@@ -121,7 +121,7 @@ void Congestion::updatePosition(unsigned pos)
congWindow = __rfbmin(INITIAL_WINDOW, congWindow);
baseRTT = -1;
measurements = 0;
- gettimeofday(&lastAdjustment, NULL);
+ gettimeofday(&lastAdjustment, nullptr);
minRTT = minCongestedRTT = -1;
inSlowStart = true;
}
@@ -149,7 +149,7 @@ void Congestion::sentPing()
memset(&rttInfo, 0, sizeof(struct RTTInfo));
- gettimeofday(&rttInfo.tv, NULL);
+ gettimeofday(&rttInfo.tv, nullptr);
rttInfo.pos = lastPosition;
rttInfo.extra = getExtraBuffer();
rttInfo.congested = isCongested();
@@ -166,7 +166,7 @@ void Congestion::gotPong()
if (pings.empty())
return;
- gettimeofday(&now, NULL);
+ gettimeofday(&now, nullptr);
rttInfo = pings.front();
pings.pop_front();
@@ -320,7 +320,7 @@ void Congestion::debugTrace(const char* filename, int fd)
#ifdef __linux__
FILE *f;
f = fopen(filename, "ab");
- if (f != NULL) {
+ if (f != nullptr) {
struct tcp_info info;
int buffered;
socklen_t len;
@@ -329,7 +329,7 @@ void Congestion::debugTrace(const char* filename, int fd)
TCP_INFO, &info, &len) == 0) &&
(ioctl(fd, SIOCOUTQ, &buffered) == 0)) {
struct timeval now;
- gettimeofday(&now, NULL);
+ gettimeofday(&now, nullptr);
fprintf(f, "%u.%06u,%u,%u,%u,%u\n",
(unsigned)now.tv_sec, (unsigned)now.tv_usec,
congWindow, info.tcpi_snd_cwnd * info.tcpi_snd_mss,
@@ -494,7 +494,7 @@ void Congestion::updateCongestion()
#endif
measurements = 0;
- gettimeofday(&lastAdjustment, NULL);
+ gettimeofday(&lastAdjustment, nullptr);
minRTT = minCongestedRTT = -1;
}
diff --git a/common/rfb/CopyRectDecoder.h b/common/rfb/CopyRectDecoder.h
index c9f9c890..51651196 100644
--- a/common/rfb/CopyRectDecoder.h
+++ b/common/rfb/CopyRectDecoder.h
@@ -26,14 +26,15 @@ namespace rfb {
public:
CopyRectDecoder();
virtual ~CopyRectDecoder();
- virtual bool readRect(const Rect& r, rdr::InStream* is,
- const ServerParams& server, rdr::OutStream* os);
- virtual void getAffectedRegion(const Rect& rect, const uint8_t* buffer,
- size_t buflen, const ServerParams& server,
- Region* region);
- virtual void decodeRect(const Rect& r, const uint8_t* buffer,
- size_t buflen, const ServerParams& server,
- ModifiablePixelBuffer* pb);
+ bool readRect(const Rect& r, rdr::InStream* is,
+ const ServerParams& server,
+ rdr::OutStream* os) override;
+ void getAffectedRegion(const Rect& rect, const uint8_t* buffer,
+ size_t buflen, const ServerParams& server,
+ Region* region) override;
+ void decodeRect(const Rect& r, const uint8_t* buffer,
+ size_t buflen, const ServerParams& server,
+ ModifiablePixelBuffer* pb) override;
};
}
#endif
diff --git a/common/rfb/Cursor.cxx b/common/rfb/Cursor.cxx
index f0c72eed..fa596bc5 100644
--- a/common/rfb/Cursor.cxx
+++ b/common/rfb/Cursor.cxx
@@ -33,11 +33,11 @@ using namespace rfb;
static LogWriter vlog("Cursor");
Cursor::Cursor(int width, int height, const Point& hotspot,
- const uint8_t* data) :
+ const uint8_t* data_) :
width_(width), height_(height), hotspot_(hotspot)
{
- this->data = new uint8_t[width_*height_*4];
- memcpy(this->data, data, width_*height_*4);
+ data = new uint8_t[width_*height_*4];
+ memcpy(data, data_, width_*height_*4);
}
Cursor::Cursor(const Cursor& other) :
diff --git a/common/rfb/Cursor.h b/common/rfb/Cursor.h
index 31d6fda9..c71f5a77 100644
--- a/common/rfb/Cursor.h
+++ b/common/rfb/Cursor.h
@@ -62,7 +62,7 @@ namespace rfb {
Rect getEffectiveRect() const { return buffer.getRect(offset); }
- virtual const uint8_t* getBuffer(const Rect& r, int* stride) const;
+ const uint8_t* getBuffer(const Rect& r, int* stride) const override;
void update(PixelBuffer* framebuffer, Cursor* cursor, const Point& pos);
diff --git a/common/rfb/DecodeManager.cxx b/common/rfb/DecodeManager.cxx
index e39a3943..ef415886 100644
--- a/common/rfb/DecodeManager.cxx
+++ b/common/rfb/DecodeManager.cxx
@@ -40,8 +40,8 @@ using namespace rfb;
static LogWriter vlog("DecodeManager");
-DecodeManager::DecodeManager(CConnection *conn) :
- conn(conn), threadException(NULL)
+DecodeManager::DecodeManager(CConnection *conn_) :
+ conn(conn_), threadException(nullptr)
{
size_t cpuCount;
@@ -97,8 +97,8 @@ DecodeManager::~DecodeManager()
delete producerCond;
delete queueMutex;
- for (size_t i = 0; i < sizeof(decoders)/sizeof(decoders[0]); i++)
- delete decoders[i];
+ for (Decoder* decoder : decoders)
+ delete decoder;
}
bool DecodeManager::decodeRect(const Rect& r, int encoding,
@@ -110,7 +110,7 @@ bool DecodeManager::decodeRect(const Rect& r, int encoding,
QueueEntry *entry;
- assert(pb != NULL);
+ assert(pb != nullptr);
if (!Decoder::supported(encoding)) {
vlog.error("Unknown encoding %d", encoding);
@@ -247,7 +247,7 @@ void DecodeManager::setThreadException(const rdr::Exception& e)
{
os::AutoMutex a(queueMutex);
- if (threadException != NULL)
+ if (threadException != nullptr)
return;
threadException = new rdr::Exception("Exception on worker thread: %s", e.str());
@@ -257,23 +257,20 @@ void DecodeManager::throwThreadException()
{
os::AutoMutex a(queueMutex);
- if (threadException == NULL)
+ if (threadException == nullptr)
return;
rdr::Exception e(*threadException);
delete threadException;
- threadException = NULL;
+ threadException = nullptr;
throw e;
}
-DecodeManager::DecodeThread::DecodeThread(DecodeManager* manager)
+DecodeManager::DecodeThread::DecodeThread(DecodeManager* manager_)
+ : manager(manager_), stopRequested(false)
{
- this->manager = manager;
-
- stopRequested = false;
-
start();
}
@@ -305,7 +302,7 @@ void DecodeManager::DecodeThread::worker()
// Look for an available entry in the work queue
entry = findEntry();
- if (entry == NULL) {
+ if (entry == nullptr) {
// Wait and try again
manager->consumerCond->wait();
continue;
@@ -347,24 +344,15 @@ void DecodeManager::DecodeThread::worker()
DecodeManager::QueueEntry* DecodeManager::DecodeThread::findEntry()
{
- std::list<DecodeManager::QueueEntry*>::iterator iter;
Region lockedRegion;
if (manager->workQueue.empty())
- return NULL;
+ return nullptr;
if (!manager->workQueue.front()->active)
return manager->workQueue.front();
- for (iter = manager->workQueue.begin();
- iter != manager->workQueue.end();
- ++iter) {
- DecodeManager::QueueEntry* entry;
-
- std::list<DecodeManager::QueueEntry*>::iterator iter2;
-
- entry = *iter;
-
+ for (DecodeManager::QueueEntry* entry : manager->workQueue) {
// Another thread working on this?
if (entry->active)
goto next;
@@ -372,8 +360,10 @@ DecodeManager::QueueEntry* DecodeManager::DecodeThread::findEntry()
// If this is an ordered decoder then make sure this is the first
// rectangle in the queue for that decoder
if (entry->decoder->flags & DecoderOrdered) {
- for (iter2 = manager->workQueue.begin(); iter2 != iter; ++iter2) {
- if (entry->encoding == (*iter2)->encoding)
+ for (DecodeManager::QueueEntry* entry2 : manager->workQueue) {
+ if (entry2 == entry)
+ break;
+ if (entry->encoding == entry2->encoding)
goto next;
}
}
@@ -381,15 +371,17 @@ DecodeManager::QueueEntry* DecodeManager::DecodeThread::findEntry()
// For a partially ordered decoder we must ask the decoder for each
// pair of rectangles.
if (entry->decoder->flags & DecoderPartiallyOrdered) {
- for (iter2 = manager->workQueue.begin(); iter2 != iter; ++iter2) {
- if (entry->encoding != (*iter2)->encoding)
+ for (DecodeManager::QueueEntry* entry2 : manager->workQueue) {
+ if (entry2 == entry)
+ break;
+ if (entry->encoding != entry2->encoding)
continue;
if (entry->decoder->doRectsConflict(entry->rect,
entry->bufferStream->data(),
entry->bufferStream->length(),
- (*iter2)->rect,
- (*iter2)->bufferStream->data(),
- (*iter2)->bufferStream->length(),
+ entry2->rect,
+ entry2->bufferStream->data(),
+ entry2->bufferStream->length(),
*entry->server))
goto next;
}
@@ -405,5 +397,5 @@ next:
lockedRegion.assign_union(entry->affectedRegion);
}
- return NULL;
+ return nullptr;
}
diff --git a/common/rfb/DecodeManager.h b/common/rfb/DecodeManager.h
index a8e0cac9..5435bfc1 100644
--- a/common/rfb/DecodeManager.h
+++ b/common/rfb/DecodeManager.h
@@ -98,7 +98,7 @@ namespace rfb {
void stop();
protected:
- void worker();
+ void worker() override;
DecodeManager::QueueEntry* findEntry();
private:
diff --git a/common/rfb/Decoder.cxx b/common/rfb/Decoder.cxx
index 78c54ec3..e9bc9a4f 100644
--- a/common/rfb/Decoder.cxx
+++ b/common/rfb/Decoder.cxx
@@ -37,7 +37,7 @@
using namespace rfb;
-Decoder::Decoder(enum DecoderFlags flags) : flags(flags)
+Decoder::Decoder(enum DecoderFlags flags_) : flags(flags_)
{
}
@@ -103,6 +103,6 @@ Decoder* Decoder::createDecoder(int encoding)
return new H264Decoder();
#endif
default:
- return NULL;
+ return nullptr;
}
}
diff --git a/common/rfb/EncodeManager.cxx b/common/rfb/EncodeManager.cxx
index c2658a70..5c1429d2 100644
--- a/common/rfb/EncodeManager.cxx
+++ b/common/rfb/EncodeManager.cxx
@@ -138,7 +138,7 @@ EncodeManager::EncodeManager(SConnection* conn_)
{
StatsVector::iterator iter;
- encoders.resize(encoderClassMax, NULL);
+ encoders.resize(encoderClassMax, nullptr);
activeEncoders.resize(encoderTypeMax, encoderRaw);
encoders[encoderRaw] = new RawEncoder(conn);
@@ -161,12 +161,10 @@ EncodeManager::EncodeManager(SConnection* conn_)
EncodeManager::~EncodeManager()
{
- std::vector<Encoder*>::iterator iter;
-
logStats();
- for (iter = encoders.begin();iter != encoders.end();iter++)
- delete *iter;
+ for (Encoder* encoder : encoders)
+ delete encoder;
}
void EncodeManager::logStats()
@@ -332,7 +330,7 @@ void EncodeManager::doUpdate(bool allowLossy, const Region& changed_,
* We need to render the cursor seperately as it has its own
* magical pixel buffer, so split it out from the changed region.
*/
- if (renderedCursor != NULL) {
+ if (renderedCursor != nullptr) {
cursorRegion = changed.intersect(renderedCursor->getEffectiveRect());
changed.assign_subtract(renderedCursor->getEffectiveRect());
}
diff --git a/common/rfb/EncodeManager.h b/common/rfb/EncodeManager.h
index 33484db8..a01a1614 100644
--- a/common/rfb/EncodeManager.h
+++ b/common/rfb/EncodeManager.h
@@ -61,7 +61,7 @@ namespace rfb {
size_t maxUpdateSize);
protected:
- virtual void handleTimeout(Timer* t);
+ void handleTimeout(Timer* t) override;
void doUpdate(bool allowLossy, const Region& changed,
const Region& copied, const Point& copy_delta,
@@ -142,7 +142,7 @@ namespace rfb {
const uint8_t* data_, int stride);
private:
- virtual uint8_t* getBufferRW(const Rect& r, int* stride);
+ uint8_t* getBufferRW(const Rect& r, int* stride) override;
};
OffsetPixelBuffer offsetPixelBuffer;
diff --git a/common/rfb/H264Decoder.cxx b/common/rfb/H264Decoder.cxx
index f18554ef..53b223db 100644
--- a/common/rfb/H264Decoder.cxx
+++ b/common/rfb/H264Decoder.cxx
@@ -51,18 +51,18 @@ H264Decoder::~H264Decoder()
void H264Decoder::resetContexts()
{
os::AutoMutex lock(&mutex);
- for (std::deque<H264DecoderContext*>::iterator it = contexts.begin(); it != contexts.end(); it++)
- delete *it;
+ for (H264DecoderContext* context : contexts)
+ delete context;
contexts.clear();
}
H264DecoderContext* H264Decoder::findContext(const Rect& r)
{
os::AutoMutex m(&mutex);
- for (std::deque<H264DecoderContext*>::iterator it = contexts.begin(); it != contexts.end(); it++)
- if ((*it)->isEqualRect(r))
- return *it;
- return NULL;
+ for (H264DecoderContext* context : contexts)
+ if (context->isEqualRect(r))
+ return context;
+ return nullptr;
}
bool H264Decoder::readRect(const Rect& /*r*/,
@@ -79,9 +79,9 @@ bool H264Decoder::readRect(const Rect& /*r*/,
len = is->readU32();
os->writeU32(len);
- uint32_t flags = is->readU32();
+ uint32_t reset = is->readU32();
- os->writeU32(flags);
+ os->writeU32(reset);
if (!is->hasDataOrRestore(len))
return false;
@@ -100,15 +100,15 @@ void H264Decoder::decodeRect(const Rect& r, const uint8_t* buffer,
{
rdr::MemInStream is(buffer, buflen);
uint32_t len = is.readU32();
- uint32_t flags = is.readU32();
+ uint32_t reset = is.readU32();
- H264DecoderContext* ctx = NULL;
- if (flags & resetAllContexts)
+ H264DecoderContext* ctx = nullptr;
+ if (reset & resetAllContexts)
{
resetContexts();
if (!len)
return;
- flags &= ~(resetContext | resetAllContexts);
+ reset &= ~(resetContext | resetAllContexts);
} else {
ctx = findContext(r);
}
diff --git a/common/rfb/H264Decoder.h b/common/rfb/H264Decoder.h
index b4f5553e..8ba47799 100644
--- a/common/rfb/H264Decoder.h
+++ b/common/rfb/H264Decoder.h
@@ -33,11 +33,12 @@ namespace rfb {
public:
H264Decoder();
virtual ~H264Decoder();
- virtual bool readRect(const Rect& r, rdr::InStream* is,
- const ServerParams& server, rdr::OutStream* os);
- virtual void decodeRect(const Rect& r, const uint8_t* buffer,
- size_t buflen, const ServerParams& server,
- ModifiablePixelBuffer* pb);
+ bool readRect(const Rect& r, rdr::InStream* is,
+ const ServerParams& server,
+ rdr::OutStream* os) override;
+ void decodeRect(const Rect& r, const uint8_t* buffer,
+ size_t buflen, const ServerParams& server,
+ ModifiablePixelBuffer* pb) override;
private:
void resetContexts();
diff --git a/common/rfb/H264LibavDecoderContext.cxx b/common/rfb/H264LibavDecoderContext.cxx
index 8697a5a5..5bd1dbbf 100644
--- a/common/rfb/H264LibavDecoderContext.cxx
+++ b/common/rfb/H264LibavDecoderContext.cxx
@@ -42,9 +42,9 @@ static LogWriter vlog("H264LibavDecoderContext");
bool H264LibavDecoderContext::initCodec() {
os::AutoMutex lock(&mutex);
- sws = NULL;
- swsBuffer = NULL;
- h264WorkBuffer = NULL;
+ sws = nullptr;
+ swsBuffer = nullptr;
+ h264WorkBuffer = nullptr;
h264WorkBufferLength = 0;
const AVCodec *codec = avcodec_find_decoder(AV_CODEC_ID_H264);
@@ -78,7 +78,7 @@ bool H264LibavDecoderContext::initCodec() {
return false;
}
- if (avcodec_open2(avctx, codec, NULL) < 0)
+ if (avcodec_open2(avctx, codec, nullptr) < 0)
{
av_parser_close(parser);
avcodec_free_context(&avctx);
@@ -117,7 +117,7 @@ uint8_t* H264LibavDecoderContext::makeH264WorkBuffer(const uint8_t* buffer, uint
if (!h264WorkBuffer || reserve_len > h264WorkBufferLength)
{
h264WorkBuffer = (uint8_t*)realloc(h264WorkBuffer, reserve_len);
- if (h264WorkBuffer == NULL) {
+ if (h264WorkBuffer == nullptr) {
throw Exception("H264LibavDecoderContext: Unable to allocate memory");
}
h264WorkBufferLength = reserve_len;
@@ -204,7 +204,7 @@ void H264LibavDecoderContext::decode(const uint8_t* h264_in_buffer,
#ifdef FFMPEG_INIT_PACKET_DEPRECATED
packet->size = 0;
- packet->data = NULL;
+ packet->data = nullptr;
av_packet_free(&packet);
#else
delete packet;
@@ -218,7 +218,7 @@ void H264LibavDecoderContext::decode(const uint8_t* h264_in_buffer,
sws = sws_getCachedContext(sws, frame->width, frame->height, avctx->pix_fmt,
frame->width, frame->height, AV_PIX_FMT_RGB32,
- 0, NULL, NULL, NULL);
+ 0, nullptr, nullptr, nullptr);
int stride;
pb->getBuffer(rect, &stride);
diff --git a/common/rfb/H264LibavDecoderContext.h b/common/rfb/H264LibavDecoderContext.h
index 148ba1ad..f399b3cc 100644
--- a/common/rfb/H264LibavDecoderContext.h
+++ b/common/rfb/H264LibavDecoderContext.h
@@ -34,12 +34,12 @@ namespace rfb {
H264LibavDecoderContext(const Rect &r) : H264DecoderContext(r) {}
~H264LibavDecoderContext() { freeCodec(); }
- virtual void decode(const uint8_t* h264_buffer, uint32_t len,
- ModifiablePixelBuffer* pb);
+ void decode(const uint8_t* h264_buffer, uint32_t len,
+ ModifiablePixelBuffer* pb) override;
protected:
- virtual bool initCodec();
- virtual void freeCodec();
+ bool initCodec() override;
+ void freeCodec() override;
private:
uint8_t* makeH264WorkBuffer(const uint8_t* buffer, uint32_t len);
diff --git a/common/rfb/H264WinDecoderContext.cxx b/common/rfb/H264WinDecoderContext.cxx
index bb29edb6..8422b5c4 100644
--- a/common/rfb/H264WinDecoderContext.cxx
+++ b/common/rfb/H264WinDecoderContext.cxx
@@ -21,7 +21,7 @@
#include <mfapi.h>
#include <mferror.h>
#include <wmcodecdsp.h>
-#define SAFE_RELEASE(obj) if (obj) { obj->Release(); obj = NULL; }
+#define SAFE_RELEASE(obj) if (obj) { obj->Release(); obj = nullptr; }
#include <os/Mutex.h>
#include <rfb/LogWriter.h>
@@ -32,6 +32,11 @@ using namespace rfb;
static LogWriter vlog("H264WinDecoderContext");
+// Older MinGW lacks this definition
+#ifndef HAVE_VIDEO_PROCESSOR_MFT
+static GUID CLSID_VideoProcessorMFT = { 0x88753b26, 0x5b24, 0x49bd, { 0xb2, 0xe7, 0xc, 0x44, 0x5c, 0x78, 0xc9, 0x82 } };
+#endif
+
bool H264WinDecoderContext::initCodec() {
os::AutoMutex lock(&mutex);
@@ -41,17 +46,16 @@ bool H264WinDecoderContext::initCodec() {
return false;
}
- if (FAILED(CoCreateInstance(CLSID_CMSH264DecoderMFT, NULL, CLSCTX_INPROC_SERVER, IID_IMFTransform, (LPVOID*)&decoder)))
+ if (FAILED(CoCreateInstance(CLSID_CMSH264DecoderMFT, nullptr, CLSCTX_INPROC_SERVER, IID_IMFTransform, (LPVOID*)&decoder)))
{
vlog.error("MediaFoundation H264 codec not found");
return false;
}
- GUID CLSID_VideoProcessorMFT = { 0x88753b26, 0x5b24, 0x49bd, { 0xb2, 0xe7, 0xc, 0x44, 0x5c, 0x78, 0xc9, 0x82 } };
- if (FAILED(CoCreateInstance(CLSID_VideoProcessorMFT, NULL, CLSCTX_INPROC_SERVER, IID_IMFTransform, (LPVOID*)&converter)))
+ if (FAILED(CoCreateInstance(CLSID_VideoProcessorMFT, nullptr, CLSCTX_INPROC_SERVER, IID_IMFTransform, (LPVOID*)&converter)))
{
vlog.error("Cannot create MediaFoundation Video Processor (available only on Windows 8+). Trying ColorConvert DMO.");
- if (FAILED(CoCreateInstance(CLSID_CColorConvertDMO, NULL, CLSCTX_INPROC_SERVER, IID_IMFTransform, (LPVOID*)&converter)))
+ if (FAILED(CoCreateInstance(CLSID_CColorConvertDMO, nullptr, CLSCTX_INPROC_SERVER, IID_IMFTransform, (LPVOID*)&converter)))
{
decoder->Release();
vlog.error("ColorConvert DMO not found");
@@ -87,7 +91,7 @@ bool H264WinDecoderContext::initCodec() {
// set decoder output type (NV12)
DWORD output_index = 0;
- IMFMediaType* output_type = NULL;
+ IMFMediaType* output_type = nullptr;
while (SUCCEEDED(decoder->GetOutputAvailableType(0, output_index++, &output_type)))
{
GUID subtype;
@@ -175,7 +179,7 @@ void H264WinDecoderContext::decode(const uint8_t* h264_buffer,
}
BYTE* locked;
- input_buffer->Lock(&locked, NULL, NULL);
+ input_buffer->Lock(&locked, nullptr, nullptr);
memcpy(locked, h264_buffer, len);
input_buffer->Unlock();
@@ -203,7 +207,7 @@ void H264WinDecoderContext::decode(const uint8_t* h264_buffer,
decoded_data.dwStreamID = 0;
decoded_data.pSample = decoded_sample;
decoded_data.dwStatus = 0;
- decoded_data.pEvents = NULL;
+ decoded_data.pEvents = nullptr;
DWORD status;
HRESULT hr = decoder->ProcessOutput(0, 1, &decoded_data, &status);
@@ -232,7 +236,7 @@ void H264WinDecoderContext::decode(const uint8_t* h264_buffer,
// need to setup output type and try decoding again
DWORD output_index = 0;
- IMFMediaType* output_type = NULL;
+ IMFMediaType* output_type = nullptr;
while (SUCCEEDED(decoder->GetOutputAvailableType(0, output_index++, &output_type)))
{
GUID subtype;
@@ -242,7 +246,7 @@ void H264WinDecoderContext::decode(const uint8_t* h264_buffer,
break;
}
output_type->Release();
- output_type = NULL;
+ output_type = nullptr;
}
// reinitialize output type (NV12) that now has correct properties (width/height/framerate)
@@ -327,7 +331,7 @@ void H264WinDecoderContext::decode(const uint8_t* h264_buffer,
converted_data.dwStreamID = 0;
converted_data.pSample = converted_sample;
converted_data.dwStatus = 0;
- converted_data.pEvents = NULL;
+ converted_data.pEvents = nullptr;
DWORD status;
HRESULT hr = converter->ProcessOutput(0, 1, &converted_data, &status);
@@ -342,8 +346,8 @@ void H264WinDecoderContext::decode(const uint8_t* h264_buffer,
vlog.debug("Frame converted to RGB");
BYTE* out;
- DWORD len;
- converted_buffer->Lock(&out, NULL, &len);
+ DWORD buflen;
+ converted_buffer->Lock(&out, nullptr, &buflen);
pb->imageRect(rect, out + offset_y * stride + offset_x * 4, (int)stride / 4);
converted_buffer->Unlock();
}
@@ -359,20 +363,20 @@ void H264WinDecoderContext::ParseSPS(const uint8_t* buffer, int length)
if (available == 0) \
{ \
if (length == 0) return; \
- byte = *buffer++; \
+ byte_ = *buffer++; \
length--; \
available = 8; \
} \
- bit = (byte >> --available) & 1; \
+ bit = (byte_ >> --available) & 1; \
} while (0)
#define GET_BITS(n, var) do { \
var = 0; \
- for (int i = n-1; i >= 0; i--) \
+ for (int b = n-1; b >= 0; b--) \
{ \
unsigned bit; \
GET_BIT(bit); \
- var |= bit << i; \
+ var |= bit << b; \
} \
} while (0)
@@ -411,7 +415,7 @@ void H264WinDecoderContext::ParseSPS(const uint8_t* buffer, int length)
length--;
int available = 0;
- uint8_t byte = 0;
+ uint8_t byte_ = 0;
unsigned profile_idc;
unsigned seq_parameter_set_id;
diff --git a/common/rfb/H264WinDecoderContext.h b/common/rfb/H264WinDecoderContext.h
index de51576c..92041781 100644
--- a/common/rfb/H264WinDecoderContext.h
+++ b/common/rfb/H264WinDecoderContext.h
@@ -33,12 +33,12 @@ namespace rfb {
H264WinDecoderContext(const Rect &r) : H264DecoderContext(r) {};
~H264WinDecoderContext() { freeCodec(); }
- virtual void decode(const uint8_t* h264_buffer, uint32_t len,
- ModifiablePixelBuffer* pb);
+ void decode(const uint8_t* h264_buffer, uint32_t len,
+ ModifiablePixelBuffer* pb) override;
protected:
- virtual bool initCodec();
- virtual void freeCodec();
+ bool initCodec() override;
+ void freeCodec() override;
private:
LONG stride;
@@ -48,14 +48,14 @@ namespace rfb {
uint32_t crop_height = 0;
uint32_t offset_x = 0;
uint32_t offset_y = 0;
- IMFTransform *decoder = NULL;
- IMFTransform *converter = NULL;
- IMFSample *input_sample = NULL;
- IMFSample *decoded_sample = NULL;
- IMFSample *converted_sample = NULL;
- IMFMediaBuffer *input_buffer = NULL;
- IMFMediaBuffer *decoded_buffer = NULL;
- IMFMediaBuffer *converted_buffer = NULL;
+ IMFTransform *decoder = nullptr;
+ IMFTransform *converter = nullptr;
+ IMFSample *input_sample = nullptr;
+ IMFSample *decoded_sample = nullptr;
+ IMFSample *converted_sample = nullptr;
+ IMFMediaBuffer *input_buffer = nullptr;
+ IMFMediaBuffer *decoded_buffer = nullptr;
+ IMFMediaBuffer *converted_buffer = nullptr;
void ParseSPS(const uint8_t* buffer, int length);
};
diff --git a/common/rfb/HextileDecoder.cxx b/common/rfb/HextileDecoder.cxx
index 2243d67f..dc9b9be7 100644
--- a/common/rfb/HextileDecoder.cxx
+++ b/common/rfb/HextileDecoder.cxx
@@ -191,10 +191,10 @@ void HextileDecoder::hextileDecode(const Rect& r, rdr::InStream* is,
if (x + w > 16 || y + h > 16) {
throw rfb::Exception("HEXTILE_DECODE: Hextile out of bounds");
}
- T* ptr = buf + y * t.width() + x;
+ ptr = buf + y * t.width() + x;
int rowAdd = t.width() - w;
while (h-- > 0) {
- int len = w;
+ len = w;
while (len-- > 0) *ptr++ = fg;
ptr += rowAdd;
}
diff --git a/common/rfb/HextileDecoder.h b/common/rfb/HextileDecoder.h
index 9163b5bb..38e8b776 100644
--- a/common/rfb/HextileDecoder.h
+++ b/common/rfb/HextileDecoder.h
@@ -29,11 +29,12 @@ namespace rfb {
public:
HextileDecoder();
virtual ~HextileDecoder();
- virtual bool readRect(const Rect& r, rdr::InStream* is,
- const ServerParams& server, rdr::OutStream* os);
- virtual void decodeRect(const Rect& r, const uint8_t* buffer,
- size_t buflen, const ServerParams& server,
- ModifiablePixelBuffer* pb);
+ bool readRect(const Rect& r, rdr::InStream* is,
+ const ServerParams& server,
+ rdr::OutStream* os) override;
+ void decodeRect(const Rect& r, const uint8_t* buffer,
+ size_t buflen, const ServerParams& server,
+ ModifiablePixelBuffer* pb) override;
private:
template<class T>
inline T readPixel(rdr::InStream* is);
diff --git a/common/rfb/HextileEncoder.cxx b/common/rfb/HextileEncoder.cxx
index a63cf1fb..0666d02d 100644
--- a/common/rfb/HextileEncoder.cxx
+++ b/common/rfb/HextileEncoder.cxx
@@ -38,8 +38,8 @@ BoolParameter improvedHextile("ImprovedHextile",
"ratios by the cost of using more CPU time",
true);
-HextileEncoder::HextileEncoder(SConnection* conn) :
- Encoder(conn, encodingHextile, EncoderPlain)
+HextileEncoder::HextileEncoder(SConnection* conn_) :
+ Encoder(conn_, encodingHextile, EncoderPlain)
{
}
@@ -365,7 +365,7 @@ class HextileTile {
template<class T>
HextileTile<T>::HextileTile()
- : m_tile(NULL), m_width(0), m_height(0),
+ : m_tile(nullptr), m_width(0), m_height(0),
m_size(0), m_flags(0), m_background(0), m_foreground(0),
m_numSubrects(0)
{
diff --git a/common/rfb/HextileEncoder.h b/common/rfb/HextileEncoder.h
index 20721b7c..55f0508d 100644
--- a/common/rfb/HextileEncoder.h
+++ b/common/rfb/HextileEncoder.h
@@ -27,11 +27,11 @@ namespace rfb {
public:
HextileEncoder(SConnection* conn);
virtual ~HextileEncoder();
- virtual bool isSupported();
- virtual void writeRect(const PixelBuffer* pb, const Palette& palette);
- virtual void writeSolidRect(int width, int height,
- const PixelFormat& pf,
- const uint8_t* colour);
+ bool isSupported() override;
+ void writeRect(const PixelBuffer* pb,
+ const Palette& palette) override;
+ void writeSolidRect(int width, int height, const PixelFormat& pf,
+ const uint8_t* colour) override;
private:
template<class T>
inline void writePixel(rdr::OutStream* os, T pixel);
diff --git a/common/rfb/Hostname.h b/common/rfb/Hostname.h
index 1971e343..a09cca3f 100644
--- a/common/rfb/Hostname.h
+++ b/common/rfb/Hostname.h
@@ -29,7 +29,7 @@
namespace rfb {
static bool isAllSpace(const char *string) {
- if (string == NULL)
+ if (string == nullptr)
return false;
while(*string != '\0') {
if (! isspace(*string))
@@ -46,7 +46,7 @@ namespace rfb {
const char* hostEnd;
const char* portStart;
- if (hi == NULL)
+ if (hi == nullptr)
throw rdr::Exception("NULL host specified");
// Trim leading whitespace
@@ -59,19 +59,19 @@ namespace rfb {
if (hi[0] == '[') {
hostStart = &hi[1];
hostEnd = strchr(hostStart, ']');
- if (hostEnd == NULL)
+ if (hostEnd == nullptr)
throw rdr::Exception("unmatched [ in host");
portStart = hostEnd + 1;
if (isAllSpace(portStart))
- portStart = NULL;
+ portStart = nullptr;
} else {
hostStart = &hi[0];
hostEnd = strrchr(hostStart, ':');
- if (hostEnd == NULL) {
+ if (hostEnd == nullptr) {
hostEnd = hostStart + strlen(hostStart);
- portStart = NULL;
+ portStart = nullptr;
} else {
if ((hostEnd > hostStart) && (hostEnd[-1] == ':'))
hostEnd--;
@@ -79,7 +79,7 @@ namespace rfb {
if (portStart != hostEnd) {
// We found more : in the host. This is probably an IPv6 address
hostEnd = hostStart + strlen(hostStart);
- portStart = NULL;
+ portStart = nullptr;
}
}
}
@@ -93,7 +93,7 @@ namespace rfb {
else
*host = std::string(hostStart, hostEnd - hostStart);
- if (portStart == NULL)
+ if (portStart == nullptr)
*port = basePort;
else {
char* end;
diff --git a/common/rfb/JpegCompressor.cxx b/common/rfb/JpegCompressor.cxx
index a4dd5f39..42d5c475 100644
--- a/common/rfb/JpegCompressor.cxx
+++ b/common/rfb/JpegCompressor.cxx
@@ -162,9 +162,9 @@ void JpegCompressor::compress(const uint8_t *buf, volatile int stride,
int w = r.width();
int h = r.height();
int pixelsize;
- uint8_t * volatile srcBuf = NULL;
+ uint8_t * volatile srcBuf = nullptr;
volatile bool srcBufIsTemp = false;
- JSAMPROW * volatile rowPointer = NULL;
+ JSAMPROW * volatile rowPointer = nullptr;
if(setjmp(err->jmpBuffer)) {
// this will execute if libjpeg has an error
diff --git a/common/rfb/JpegDecompressor.cxx b/common/rfb/JpegDecompressor.cxx
index 44c54fb2..92ef014f 100644
--- a/common/rfb/JpegDecompressor.cxx
+++ b/common/rfb/JpegDecompressor.cxx
@@ -159,9 +159,9 @@ void JpegDecompressor::decompress(const uint8_t *jpegBuf,
int h = r.height();
int pixelsize;
int dstBufStride;
- uint8_t * volatile dstBuf = NULL;
+ uint8_t * volatile dstBuf = nullptr;
volatile bool dstBufIsTemp = false;
- JSAMPROW * volatile rowPointer = NULL;
+ JSAMPROW * volatile rowPointer = nullptr;
if(setjmp(err->jmpBuffer)) {
// this will execute if libjpeg has an error
diff --git a/common/rfb/KeyRemapper.cxx b/common/rfb/KeyRemapper.cxx
index 762eb413..328955d7 100644
--- a/common/rfb/KeyRemapper.cxx
+++ b/common/rfb/KeyRemapper.cxx
@@ -89,7 +89,7 @@ public:
: StringParameter("RemapKeys", "Comma-separated list of incoming keysyms to remap. Mappings are expressed as two hex values, prefixed by 0x, and separated by ->", "") {
KeyRemapper::defInstance.setMapping("");
}
- bool setParam(const char* v) {
+ bool setParam(const char* v) override {
KeyRemapper::defInstance.setMapping(v);
return StringParameter::setParam(v);
}
diff --git a/common/rfb/LogWriter.cxx b/common/rfb/LogWriter.cxx
index dc9db9d1..b222d268 100644
--- a/common/rfb/LogWriter.cxx
+++ b/common/rfb/LogWriter.cxx
@@ -34,7 +34,8 @@ rfb::LogParameter rfb::logParams;
using namespace rfb;
-LogWriter::LogWriter(const char* name) : m_name(name), m_level(0), m_log(0), m_next(log_writers) {
+LogWriter::LogWriter(const char* name)
+ : m_name(name), m_level(0), m_log(nullptr), m_next(log_writers) {
log_writers = this;
}
@@ -72,7 +73,7 @@ LogWriter::getLogWriter(const char* name) {
if (strcasecmp(name, current->m_name) == 0) return current;
current = current->m_next;
}
- return 0;
+ return nullptr;
}
bool LogWriter::setLogParams(const char* params) {
@@ -83,7 +84,7 @@ bool LogWriter::setLogParams(const char* params) {
return false;
}
int level = atoi(parts[2].c_str());
- Logger* logger = 0;
+ Logger* logger = nullptr;
if (!parts[1].empty()) {
logger = Logger::getLogger(parts[1].c_str());
if (!logger)
diff --git a/common/rfb/LogWriter.h b/common/rfb/LogWriter.h
index 6eff6da1..d1fd4990 100644
--- a/common/rfb/LogWriter.h
+++ b/common/rfb/LogWriter.h
@@ -104,7 +104,7 @@ namespace rfb {
class LogParameter : public StringParameter {
public:
LogParameter();
- virtual bool setParam(const char* v);
+ bool setParam(const char* v) override;
};
extern LogParameter logParams;
diff --git a/common/rfb/Logger.cxx b/common/rfb/Logger.cxx
index 7e0895e4..25f7ccb7 100644
--- a/common/rfb/Logger.cxx
+++ b/common/rfb/Logger.cxx
@@ -31,9 +31,11 @@
using namespace rfb;
-Logger* Logger::loggers = 0;
+Logger* Logger::loggers = nullptr;
-Logger::Logger(const char* name) : registered(false), m_name(name), m_next(0) {
+Logger::Logger(const char* name)
+ : registered(false), m_name(name), m_next(nullptr)
+{
}
Logger::~Logger() {
@@ -78,7 +80,7 @@ Logger::getLogger(const char* name) {
if (strcasecmp(name, current->m_name) == 0) return current;
current = current->m_next;
}
- return 0;
+ return nullptr;
}
void
diff --git a/common/rfb/Logger_file.cxx b/common/rfb/Logger_file.cxx
index 099a3501..eabe420a 100644
--- a/common/rfb/Logger_file.cxx
+++ b/common/rfb/Logger_file.cxx
@@ -33,7 +33,7 @@
using namespace rfb;
Logger_File::Logger_File(const char* loggerName)
- : Logger(loggerName), indent(13), width(79), m_file(0),
+ : Logger(loggerName), indent(13), width(79), m_file(nullptr),
m_lastLogTime(0)
{
m_filename[0] = '\0';
@@ -65,7 +65,7 @@ void Logger_File::write(int /*level*/, const char *logname, const char *message)
if (!m_file) return;
}
- time_t current = time(0);
+ time_t current = time(nullptr);
if (current != m_lastLogTime) {
m_lastLogTime = current;
fprintf(m_file, "\n%s", ctime(&m_lastLogTime));
@@ -115,7 +115,7 @@ void Logger_File::closeFile()
{
if (m_file) {
fclose(m_file);
- m_file = 0;
+ m_file = nullptr;
}
}
diff --git a/common/rfb/Logger_file.h b/common/rfb/Logger_file.h
index 4542d23c..6f2a4ef6 100644
--- a/common/rfb/Logger_file.h
+++ b/common/rfb/Logger_file.h
@@ -35,7 +35,7 @@ namespace rfb {
Logger_File(const char* loggerName);
~Logger_File();
- virtual void write(int level, const char *logname, const char *message);
+ void write(int level, const char *logname, const char *message) override;
void setFilename(const char* filename);
void setFile(FILE* file);
diff --git a/common/rfb/Logger_syslog.cxx b/common/rfb/Logger_syslog.cxx
index 320ab4b0..de9e425e 100644
--- a/common/rfb/Logger_syslog.cxx
+++ b/common/rfb/Logger_syslog.cxx
@@ -35,7 +35,7 @@ using namespace rfb;
Logger_Syslog::Logger_Syslog(const char* loggerName)
: Logger(loggerName)
{
- openlog(0, LOG_CONS | LOG_PID, LOG_USER);
+ openlog(nullptr, LOG_CONS | LOG_PID, LOG_USER);
}
Logger_Syslog::~Logger_Syslog()
diff --git a/common/rfb/Logger_syslog.h b/common/rfb/Logger_syslog.h
index cf987281..20c46a5f 100644
--- a/common/rfb/Logger_syslog.h
+++ b/common/rfb/Logger_syslog.h
@@ -31,7 +31,7 @@ namespace rfb {
Logger_Syslog(const char* loggerName);
virtual ~Logger_Syslog();
- virtual void write(int level, const char *logname, const char *message);
+ void write(int level, const char *logname, const char *message) override;
};
void initSyslogLogger();
diff --git a/common/rfb/Palette.h b/common/rfb/Palette.h
index 6b8cc57e..d22af0dc 100644
--- a/common/rfb/Palette.h
+++ b/common/rfb/Palette.h
@@ -75,10 +75,10 @@ inline bool rfb::Palette::insert(uint32_t colour, int numPixels)
hash_key = genHash(colour);
pnode = hash[hash_key];
- prev_pnode = NULL;
+ prev_pnode = nullptr;
// Do we already have an entry for this colour?
- while (pnode != NULL) {
+ while (pnode != nullptr) {
if (pnode->colour == colour) {
// Yup
@@ -114,12 +114,12 @@ inline bool rfb::Palette::insert(uint32_t colour, int numPixels)
// Create a new colour entry
pnode = &list[numColours];
- pnode->next = NULL;
+ pnode->next = nullptr;
pnode->idx = 0;
pnode->colour = colour;
// Add it to the hash table
- if (prev_pnode != NULL)
+ if (prev_pnode != nullptr)
prev_pnode->next = pnode;
else
hash[hash_key] = pnode;
@@ -152,7 +152,7 @@ inline unsigned char rfb::Palette::lookup(uint32_t colour) const
hash_key = genHash(colour);
pnode = hash[hash_key];
- while (pnode != NULL) {
+ while (pnode != nullptr) {
if (pnode->colour == colour)
return pnode->idx;
pnode = pnode->next;
diff --git a/common/rfb/PixelBuffer.cxx b/common/rfb/PixelBuffer.cxx
index c8b5f3d7..f1354a43 100644
--- a/common/rfb/PixelBuffer.cxx
+++ b/common/rfb/PixelBuffer.cxx
@@ -326,7 +326,7 @@ FullFramePixelBuffer::FullFramePixelBuffer(const PixelFormat& pf, int w, int h,
{
}
-FullFramePixelBuffer::FullFramePixelBuffer() : data(0) {}
+FullFramePixelBuffer::FullFramePixelBuffer() : data(nullptr) {}
FullFramePixelBuffer::~FullFramePixelBuffer() {}
@@ -365,7 +365,7 @@ void FullFramePixelBuffer::setBuffer(int width, int height,
throw rfb::Exception("Invalid PixelBuffer height of %d pixels requested", height);
if ((stride_ < 0) || (stride_ > maxPixelBufferStride) || (stride_ < width))
throw rfb::Exception("Invalid PixelBuffer stride of %d pixels requested", stride_);
- if ((width != 0) && (height != 0) && (data_ == NULL))
+ if ((width != 0) && (height != 0) && (data_ == nullptr))
throw rfb::Exception("PixelBuffer requested without a valid memory area");
ModifiablePixelBuffer::setSize(width, height);
@@ -383,12 +383,12 @@ void FullFramePixelBuffer::setSize(int /*w*/, int /*h*/)
// Automatically allocates enough space for the specified format & area
ManagedPixelBuffer::ManagedPixelBuffer()
- : data_(NULL), datasize(0)
+ : data_(nullptr), datasize(0)
{
}
ManagedPixelBuffer::ManagedPixelBuffer(const PixelFormat& pf, int w, int h)
- : FullFramePixelBuffer(pf, 0, 0, NULL, 0), data_(NULL), datasize(0)
+ : FullFramePixelBuffer(pf, 0, 0, nullptr, 0), data_(nullptr), datasize(0)
{
setSize(w, h);
}
@@ -413,7 +413,7 @@ void ManagedPixelBuffer::setSize(int w, int h)
if (datasize < new_datasize) {
if (data_) {
delete [] data_;
- data_ = NULL;
+ data_ = nullptr;
datasize = 0;
}
if (new_datasize) {
diff --git a/common/rfb/PixelBuffer.h b/common/rfb/PixelBuffer.h
index 33a9c7ae..963fbbf6 100644
--- a/common/rfb/PixelBuffer.h
+++ b/common/rfb/PixelBuffer.h
@@ -151,16 +151,16 @@ namespace rfb {
virtual ~FullFramePixelBuffer();
public:
- virtual const uint8_t* getBuffer(const Rect& r, int* stride) const;
- virtual uint8_t* getBufferRW(const Rect& r, int* stride);
- virtual void commitBufferRW(const Rect& r);
+ const uint8_t* getBuffer(const Rect& r, int* stride) const override;
+ uint8_t* getBufferRW(const Rect& r, int* stride) override;
+ void commitBufferRW(const Rect& r) override;
protected:
FullFramePixelBuffer();
virtual void setBuffer(int width, int height, uint8_t* data, int stride);
private:
- virtual void setSize(int w, int h);
+ void setSize(int w, int h) override;
private:
uint8_t* data;
@@ -178,7 +178,7 @@ namespace rfb {
// Manage the pixel buffer layout
virtual void setPF(const PixelFormat &pf);
- virtual void setSize(int w, int h);
+ void setSize(int w, int h) override;
private:
uint8_t* data_; // Mirrors FullFramePixelBuffer::data
diff --git a/common/rfb/RREDecoder.h b/common/rfb/RREDecoder.h
index a1d7f9b8..8490146c 100644
--- a/common/rfb/RREDecoder.h
+++ b/common/rfb/RREDecoder.h
@@ -29,11 +29,12 @@ namespace rfb {
public:
RREDecoder();
virtual ~RREDecoder();
- virtual bool readRect(const Rect& r, rdr::InStream* is,
- const ServerParams& server, rdr::OutStream* os);
- virtual void decodeRect(const Rect& r, const uint8_t* buffer,
- size_t buflen, const ServerParams& server,
- ModifiablePixelBuffer* pb);
+ bool readRect(const Rect& r, rdr::InStream* is,
+ const ServerParams& server,
+ rdr::OutStream* os) override;
+ void decodeRect(const Rect& r, const uint8_t* buffer,
+ size_t buflen, const ServerParams& server,
+ ModifiablePixelBuffer* pb) override;
private:
template<class T>
inline T readPixel(rdr::InStream* is);
diff --git a/common/rfb/RREEncoder.cxx b/common/rfb/RREEncoder.cxx
index e73a23bf..f3e3b68a 100644
--- a/common/rfb/RREEncoder.cxx
+++ b/common/rfb/RREEncoder.cxx
@@ -31,8 +31,8 @@
using namespace rfb;
-RREEncoder::RREEncoder(SConnection* conn) :
- Encoder(conn, encodingRRE, EncoderPlain)
+RREEncoder::RREEncoder(SConnection* conn_) :
+ Encoder(conn_, encodingRRE, EncoderPlain)
{
}
diff --git a/common/rfb/RREEncoder.h b/common/rfb/RREEncoder.h
index b13135b4..e21586ec 100644
--- a/common/rfb/RREEncoder.h
+++ b/common/rfb/RREEncoder.h
@@ -29,11 +29,11 @@ namespace rfb {
public:
RREEncoder(SConnection* conn);
virtual ~RREEncoder();
- virtual bool isSupported();
- virtual void writeRect(const PixelBuffer* pb, const Palette& palette);
- virtual void writeSolidRect(int width, int height,
- const PixelFormat& pf,
- const uint8_t* colour);
+ bool isSupported() override;
+ void writeRect(const PixelBuffer* pb,
+ const Palette& palette) override;
+ void writeSolidRect(int width, int height, const PixelFormat& pf,
+ const uint8_t* colour) override;
private:
template<class T>
inline void writePixel(rdr::OutStream* os, T pixel);
diff --git a/common/rfb/RawDecoder.h b/common/rfb/RawDecoder.h
index 33948ced..2ac8b0bd 100644
--- a/common/rfb/RawDecoder.h
+++ b/common/rfb/RawDecoder.h
@@ -25,11 +25,12 @@ namespace rfb {
public:
RawDecoder();
virtual ~RawDecoder();
- virtual bool readRect(const Rect& r, rdr::InStream* is,
- const ServerParams& server, rdr::OutStream* os);
- virtual void decodeRect(const Rect& r, const uint8_t* buffer,
- size_t buflen, const ServerParams& server,
- ModifiablePixelBuffer* pb);
+ bool readRect(const Rect& r, rdr::InStream* is,
+ const ServerParams& server,
+ rdr::OutStream* os) override;
+ void decodeRect(const Rect& r, const uint8_t* buffer,
+ size_t buflen, const ServerParams& server,
+ ModifiablePixelBuffer* pb) override;
};
}
#endif
diff --git a/common/rfb/RawEncoder.cxx b/common/rfb/RawEncoder.cxx
index 2fa1af36..eff8999d 100644
--- a/common/rfb/RawEncoder.cxx
+++ b/common/rfb/RawEncoder.cxx
@@ -29,8 +29,8 @@
using namespace rfb;
-RawEncoder::RawEncoder(SConnection* conn) :
- Encoder(conn, encodingRaw, EncoderPlain)
+RawEncoder::RawEncoder(SConnection* conn_) :
+ Encoder(conn_, encodingRaw, EncoderPlain)
{
}
diff --git a/common/rfb/RawEncoder.h b/common/rfb/RawEncoder.h
index 76da4c5b..e191645c 100644
--- a/common/rfb/RawEncoder.h
+++ b/common/rfb/RawEncoder.h
@@ -27,11 +27,11 @@ namespace rfb {
public:
RawEncoder(SConnection* conn);
virtual ~RawEncoder();
- virtual bool isSupported();
- virtual void writeRect(const PixelBuffer* pb, const Palette& palette);
- virtual void writeSolidRect(int width, int height,
- const PixelFormat& pf,
- const uint8_t* colour);
+ bool isSupported() override;
+ void writeRect(const PixelBuffer* pb,
+ const Palette& palette) override;
+ void writeSolidRect(int width, int height, const PixelFormat& pf,
+ const uint8_t* colour) override;
};
}
#endif
diff --git a/common/rfb/SConnection.cxx b/common/rfb/SConnection.cxx
index 12ba0f1a..866d19a2 100644
--- a/common/rfb/SConnection.cxx
+++ b/common/rfb/SConnection.cxx
@@ -23,6 +23,9 @@
#include <stdio.h>
#include <string.h>
+
+#include <algorithm>
+
#include <rfb/Exception.h>
#include <rfb/Security.h>
#include <rfb/clipboardTypes.h>
@@ -43,12 +46,12 @@ using namespace rfb;
static LogWriter vlog("SConnection");
-SConnection::SConnection(AccessRights accessRights)
- : readyForSetColourMapEntries(false),
- is(0), os(0), reader_(0), writer_(0), ssecurity(0),
+SConnection::SConnection(AccessRights accessRights_)
+ : readyForSetColourMapEntries(false), is(nullptr), os(nullptr),
+ reader_(nullptr), writer_(nullptr), ssecurity(nullptr),
authFailureTimer(this, &SConnection::handleAuthFailureTimeout),
state_(RFBSTATE_UNINITIALISED), preferredEncoding(encodingRaw),
- accessRights(accessRights), hasRemoteClipboard(false),
+ accessRights(accessRights_), hasRemoteClipboard(false),
hasLocalClipboard(false),
unsolicitedClipboardAttempt(false)
{
@@ -206,12 +209,10 @@ void SConnection::processSecurityType(int secType)
{
// Verify that the requested security type should be offered
std::list<uint8_t> secTypes;
- std::list<uint8_t>::iterator i;
secTypes = security.GetEnabledSecTypes();
- for (i=secTypes.begin(); i!=secTypes.end(); i++)
- if (*i == secType) break;
- if (i == secTypes.end())
+ if (std::find(secTypes.begin(), secTypes.end(),
+ secType) == secTypes.end())
throw Exception("Requested security type not available");
vlog.info("Client requests security type %s(%d)",
@@ -586,7 +587,7 @@ void SConnection::sendClipboardData(const char* data)
// FIXME: This conversion magic should be in SMsgWriter
std::string filtered(convertCRLF(data));
size_t sizes[1] = { filtered.size() + 1 };
- const uint8_t* data[1] = { (const uint8_t*)filtered.c_str() };
+ const uint8_t* datas[1] = { (const uint8_t*)filtered.c_str() };
if (unsolicitedClipboardAttempt) {
unsolicitedClipboardAttempt = false;
@@ -598,7 +599,7 @@ void SConnection::sendClipboardData(const char* data)
}
}
- writer()->writeClipboardProvide(rfb::clipboardUTF8, sizes, data);
+ writer()->writeClipboardProvide(rfb::clipboardUTF8, sizes, datas);
} else {
writer()->writeServerCutText(data);
}
@@ -607,11 +608,11 @@ void SConnection::sendClipboardData(const char* data)
void SConnection::cleanup()
{
delete ssecurity;
- ssecurity = NULL;
+ ssecurity = nullptr;
delete reader_;
- reader_ = NULL;
+ reader_ = nullptr;
delete writer_;
- writer_ = NULL;
+ writer_ = nullptr;
}
void SConnection::writeFakeColourMap(void)
diff --git a/common/rfb/SConnection.h b/common/rfb/SConnection.h
index 5bc61677..2ac53269 100644
--- a/common/rfb/SConnection.h
+++ b/common/rfb/SConnection.h
@@ -71,7 +71,7 @@ namespace rfb {
// later, after queryConnection() has returned. It can only be called when
// in state RFBSTATE_QUERYING. On rejection, an AuthFailureException is
// thrown, so this must be handled appropriately by the caller.
- void approveConnection(bool accept, const char* reason=0);
+ void approveConnection(bool accept, const char* reason=nullptr);
// Methods to terminate the connection
@@ -83,18 +83,17 @@ namespace rfb {
// Overridden from SMsgHandler
- virtual void setEncodings(int nEncodings, const int32_t* encodings);
+ void setEncodings(int nEncodings, const int32_t* encodings) override;
- virtual void clientCutText(const char* str);
+ void clientCutText(const char* str) override;
- virtual void handleClipboardRequest(uint32_t flags);
- virtual void handleClipboardPeek();
- virtual void handleClipboardNotify(uint32_t flags);
- virtual void handleClipboardProvide(uint32_t flags,
- const size_t* lengths,
- const uint8_t* const* data);
+ void handleClipboardRequest(uint32_t flags) override;
+ void handleClipboardPeek() override;
+ void handleClipboardNotify(uint32_t flags) override;
+ void handleClipboardProvide(uint32_t flags, const size_t* lengths,
+ const uint8_t* const* data) override;
- virtual void supportsQEMUKeyEvent();
+ void supportsQEMUKeyEvent() override;
// Methods to be overridden in a derived class
@@ -118,27 +117,27 @@ namespace rfb {
// clientInit() is called when the ClientInit message is received. The
// derived class must call on to SConnection::clientInit().
- virtual void clientInit(bool shared);
+ void clientInit(bool shared) override;
// setPixelFormat() is called when a SetPixelFormat message is received.
// The derived class must call on to SConnection::setPixelFormat().
- virtual void setPixelFormat(const PixelFormat& pf);
+ void setPixelFormat(const PixelFormat& pf) override;
// framebufferUpdateRequest() is called when a FramebufferUpdateRequest
// message is received. The derived class must call on to
// SConnection::framebufferUpdateRequest().
- virtual void framebufferUpdateRequest(const Rect& r, bool incremental);
+ void framebufferUpdateRequest(const Rect& r, bool incremental) override;
// fence() is called when we get a fence request or response. By default
// it responds directly to requests (stating it doesn't support any
// synchronisation) and drops responses. Override to implement more proper
// support.
- virtual void fence(uint32_t flags, unsigned len, const uint8_t data[]);
+ void fence(uint32_t flags, unsigned len, const uint8_t data[]) override;
// enableContinuousUpdates() is called when the client wants to enable
// or disable continuous updates, or change the active area.
- virtual void enableContinuousUpdates(bool enable,
- int x, int y, int w, int h);
+ void enableContinuousUpdates(bool enable,
+ int x, int y, int w, int h) override;
// handleClipboardRequest() is called whenever the client requests
// the server to send over its clipboard data. It will only be
diff --git a/common/rfb/SDesktop.h b/common/rfb/SDesktop.h
index 94e4b028..94fcaa28 100644
--- a/common/rfb/SDesktop.h
+++ b/common/rfb/SDesktop.h
@@ -124,14 +124,18 @@ namespace rfb {
// a plain black desktop of the specified format.
class SStaticDesktop : public SDesktop {
public:
- SStaticDesktop(const Point& size) : server(0), buffer(0) {
+ SStaticDesktop(const Point& size)
+ : server(nullptr), buffer(nullptr)
+ {
PixelFormat pf;
const uint8_t black[4] = { 0, 0, 0, 0 };
buffer = new ManagedPixelBuffer(pf, size.x, size.y);
if (buffer)
buffer->fillRect(buffer->getRect(), black);
}
- SStaticDesktop(const Point& size, const PixelFormat& pf) : buffer(0) {
+ SStaticDesktop(const Point& size, const PixelFormat& pf)
+ : buffer(nullptr)
+ {
const uint8_t black[4] = { 0, 0, 0, 0 };
buffer = new ManagedPixelBuffer(pf, size.x, size.y);
if (buffer)
@@ -141,13 +145,13 @@ namespace rfb {
if (buffer) delete buffer;
}
- virtual void init(VNCServer* vs) {
+ void init(VNCServer* vs) override {
server = vs;
server->setPixelBuffer(buffer);
}
- virtual void queryConnection(network::Socket* sock,
- const char* /*userName*/) {
- server->approveConnection(sock, true, NULL);
+ void queryConnection(network::Socket* sock,
+ const char* /*userName*/) override {
+ server->approveConnection(sock, true, nullptr);
}
protected:
diff --git a/common/rfb/SMsgReader.cxx b/common/rfb/SMsgReader.cxx
index 0792639a..9ddea53d 100644
--- a/common/rfb/SMsgReader.cxx
+++ b/common/rfb/SMsgReader.cxx
@@ -418,7 +418,7 @@ bool SMsgReader::readExtendedClipboard(int32_t len)
}
zis.flushUnderlying();
- zis.setUnderlying(NULL, 0);
+ zis.setUnderlying(nullptr, 0);
handler->handleClipboardProvide(flags, lengths, buffers);
diff --git a/common/rfb/SMsgWriter.cxx b/common/rfb/SMsgWriter.cxx
index 8592e6f4..0c03b51d 100644
--- a/common/rfb/SMsgWriter.cxx
+++ b/common/rfb/SMsgWriter.cxx
@@ -93,7 +93,7 @@ void SMsgWriter::writeBell()
void SMsgWriter::writeServerCutText(const char* str)
{
- if (strchr(str, '\r') != NULL)
+ if (strchr(str, '\r') != nullptr)
throw Exception("Invalid carriage return in clipboard data");
std::string latin1(utf8ToLatin1(str));
@@ -508,10 +508,9 @@ void SMsgWriter::writeNoDataRects()
{
if (!extendedDesktopSizeMsgs.empty()) {
if (client->supportsEncoding(pseudoEncodingExtendedDesktopSize)) {
- std::list<ExtendedDesktopSizeMsg>::const_iterator ri;
- for (ri = extendedDesktopSizeMsgs.begin();ri != extendedDesktopSizeMsgs.end();++ri) {
+ for (ExtendedDesktopSizeMsg msg : extendedDesktopSizeMsgs) {
// FIXME: We can probably skip multiple reasonServer entries
- writeExtendedDesktopSizeRect(ri->reason, ri->result,
+ writeExtendedDesktopSizeRect(msg.reason, msg.result,
client->width(), client->height(),
client->screenLayout());
}
diff --git a/common/rfb/SSecurityNone.h b/common/rfb/SSecurityNone.h
index f14d83a4..a10b4369 100644
--- a/common/rfb/SSecurityNone.h
+++ b/common/rfb/SSecurityNone.h
@@ -28,10 +28,10 @@ namespace rfb {
class SSecurityNone : public SSecurity {
public:
- SSecurityNone(SConnection* sc) : SSecurity(sc) {}
- virtual bool processMsg() { return true; }
- virtual int getType() const {return secTypeNone;}
- virtual const char* getUserName() const {return 0;}
+ SSecurityNone(SConnection* sc_) : SSecurity(sc_) {}
+ bool processMsg() override { return true; }
+ int getType() const override {return secTypeNone;}
+ const char* getUserName() const override {return nullptr;}
};
}
#endif
diff --git a/common/rfb/SSecurityPlain.cxx b/common/rfb/SSecurityPlain.cxx
index a100a757..73a21335 100644
--- a/common/rfb/SSecurityPlain.cxx
+++ b/common/rfb/SSecurityPlain.cxx
@@ -68,14 +68,14 @@ bool PasswordValidator::validUser(const char* username)
return false;
}
-SSecurityPlain::SSecurityPlain(SConnection* sc) : SSecurity(sc)
+SSecurityPlain::SSecurityPlain(SConnection* sc_) : SSecurity(sc_)
{
#ifdef WIN32
valid = new WinPasswdValidator();
#elif !defined(__APPLE__)
valid = new UnixPasswordValidator();
#else
- valid = NULL;
+ valid = nullptr;
#endif
state = 0;
diff --git a/common/rfb/SSecurityPlain.h b/common/rfb/SSecurityPlain.h
index 4ca72781..c0ac049b 100644
--- a/common/rfb/SSecurityPlain.h
+++ b/common/rfb/SSecurityPlain.h
@@ -43,9 +43,9 @@ namespace rfb {
class SSecurityPlain : public SSecurity {
public:
SSecurityPlain(SConnection* sc);
- virtual bool processMsg();
- virtual int getType() const { return secTypePlain; };
- virtual const char* getUserName() const { return username; }
+ bool processMsg() override;
+ int getType() const override { return secTypePlain; };
+ const char* getUserName() const override { return username; }
virtual ~SSecurityPlain() { }
diff --git a/common/rfb/SSecurityRSAAES.cxx b/common/rfb/SSecurityRSAAES.cxx
index cea62644..13e03b22 100644
--- a/common/rfb/SSecurityRSAAES.cxx
+++ b/common/rfb/SSecurityRSAAES.cxx
@@ -70,14 +70,15 @@ BoolParameter SSecurityRSAAES::requireUsername
("RequireUsername", "Require username for the RSA-AES security types",
false, ConfServer);
-SSecurityRSAAES::SSecurityRSAAES(SConnection* sc, uint32_t _secType,
+SSecurityRSAAES::SSecurityRSAAES(SConnection* sc_, uint32_t _secType,
int _keySize, bool _isAllEncrypted)
- : SSecurity(sc), state(SendPublicKey),
+ : SSecurity(sc_), state(SendPublicKey),
keySize(_keySize), isAllEncrypted(_isAllEncrypted), secType(_secType),
serverKey(), clientKey(),
- serverKeyN(NULL), serverKeyE(NULL), clientKeyN(NULL), clientKeyE(NULL),
+ serverKeyN(nullptr), serverKeyE(nullptr),
+ clientKeyN(nullptr), clientKeyE(nullptr),
accessRights(AccessDefault),
- rais(NULL), raos(NULL), rawis(NULL), rawos(NULL)
+ rais(nullptr), raos(nullptr), rawis(nullptr), rawos(nullptr)
{
assert(keySize == 128 || keySize == 256);
}
@@ -514,10 +515,10 @@ void SSecurityRSAAES::clearSecrets()
delete[] serverKeyE;
delete[] clientKeyN;
delete[] clientKeyE;
- serverKeyN = NULL;
- serverKeyE = NULL;
- clientKeyN = NULL;
- clientKeyE = NULL;
+ serverKeyN = nullptr;
+ serverKeyE = nullptr;
+ clientKeyN = nullptr;
+ clientKeyE = nullptr;
memset(serverRandom, 0, sizeof(serverRandom));
memset(clientRandom, 0, sizeof(clientRandom));
}
diff --git a/common/rfb/SSecurityRSAAES.h b/common/rfb/SSecurityRSAAES.h
index 0c4fc852..edac35c6 100644
--- a/common/rfb/SSecurityRSAAES.h
+++ b/common/rfb/SSecurityRSAAES.h
@@ -36,10 +36,10 @@ namespace rfb {
SSecurityRSAAES(SConnection* sc, uint32_t secType,
int keySize, bool isAllEncrypted);
virtual ~SSecurityRSAAES();
- virtual bool processMsg();
- virtual const char* getUserName() const;
- virtual int getType() const { return secType; }
- virtual AccessRights getAccessRights() const
+ bool processMsg() override;
+ const char* getUserName() const override;
+ int getType() const override {return secType;}
+ AccessRights getAccessRights() const override
{
return accessRights;
}
diff --git a/common/rfb/SSecurityStack.cxx b/common/rfb/SSecurityStack.cxx
index 9c0321d4..0ce6d754 100644
--- a/common/rfb/SSecurityStack.cxx
+++ b/common/rfb/SSecurityStack.cxx
@@ -24,9 +24,9 @@
using namespace rfb;
-SSecurityStack::SSecurityStack(SConnection* sc, int Type,
+SSecurityStack::SSecurityStack(SConnection* sc_, int Type,
SSecurity* s0, SSecurity* s1)
- : SSecurity(sc), state(0), state0(s0), state1(s1), type(Type)
+ : SSecurity(sc_), state(0), state0(s0), state1(s1), type(Type)
{
}
@@ -61,7 +61,7 @@ bool SSecurityStack::processMsg()
const char* SSecurityStack::getUserName() const
{
- const char* c = 0;
+ const char* c = nullptr;
if (state1 && !c)
c = state1->getUserName();
diff --git a/common/rfb/SSecurityStack.h b/common/rfb/SSecurityStack.h
index cf7b10d0..d2949a21 100644
--- a/common/rfb/SSecurityStack.h
+++ b/common/rfb/SSecurityStack.h
@@ -27,12 +27,12 @@ namespace rfb {
class SSecurityStack : public SSecurity {
public:
SSecurityStack(SConnection* sc, int Type,
- SSecurity* s0 = NULL, SSecurity* s1 = NULL);
+ SSecurity* s0 = nullptr, SSecurity* s1 = nullptr);
~SSecurityStack();
- virtual bool processMsg();
- virtual int getType() const { return type; };
- virtual const char* getUserName() const;
- virtual AccessRights getAccessRights() const;
+ bool processMsg() override;
+ int getType() const override { return type; };
+ const char* getUserName() const override;
+ AccessRights getAccessRights() const override;
protected:
short state;
SSecurity* state0;
diff --git a/common/rfb/SSecurityTLS.cxx b/common/rfb/SSecurityTLS.cxx
index 1abfd774..e2b82f89 100644
--- a/common/rfb/SSecurityTLS.cxx
+++ b/common/rfb/SSecurityTLS.cxx
@@ -66,13 +66,13 @@ StringParameter SSecurityTLS::X509_KeyFile
static LogWriter vlog("TLS");
-SSecurityTLS::SSecurityTLS(SConnection* sc, bool _anon)
- : SSecurity(sc), session(NULL), anon_cred(NULL),
- cert_cred(NULL), anon(_anon), tlsis(NULL), tlsos(NULL),
- rawis(NULL), rawos(NULL)
+SSecurityTLS::SSecurityTLS(SConnection* sc_, bool _anon)
+ : SSecurity(sc_), session(nullptr), anon_cred(nullptr),
+ cert_cred(nullptr), anon(_anon), tlsis(nullptr), tlsos(nullptr),
+ rawis(nullptr), rawos(nullptr)
{
#if defined (SSECURITYTLS__USE_DEPRECATED_DH)
- dh_params = NULL;
+ dh_params = nullptr;
#endif
if (gnutls_global_init() != GNUTLS_E_SUCCESS)
@@ -99,32 +99,32 @@ void SSecurityTLS::shutdown()
if (anon_cred) {
gnutls_anon_free_server_credentials(anon_cred);
- anon_cred = 0;
+ anon_cred = nullptr;
}
if (cert_cred) {
gnutls_certificate_free_credentials(cert_cred);
- cert_cred = 0;
+ cert_cred = nullptr;
}
if (rawis && rawos) {
sc->setStreams(rawis, rawos);
- rawis = NULL;
- rawos = NULL;
+ rawis = nullptr;
+ rawos = nullptr;
}
if (tlsis) {
delete tlsis;
- tlsis = NULL;
+ tlsis = nullptr;
}
if (tlsos) {
delete tlsos;
- tlsos = NULL;
+ tlsos = nullptr;
}
if (session) {
gnutls_deinit(session);
- session = 0;
+ session = nullptr;
}
}
@@ -151,7 +151,7 @@ bool SSecurityTLS::processMsg()
throw AuthFailureException("gnutls_set_default_priority failed");
try {
- setParams(session);
+ setParams();
}
catch(...) {
os->writeU8(0);
@@ -190,7 +190,7 @@ bool SSecurityTLS::processMsg()
return true;
}
-void SSecurityTLS::setParams(gnutls_session_t session)
+void SSecurityTLS::setParams()
{
static const char kx_anon_priority[] = ":+ANON-ECDH:+ANON-DH";
@@ -203,7 +203,7 @@ void SSecurityTLS::setParams(gnutls_session_t session)
prio = (char*)malloc(strlen(Security::GnuTLSPriority) +
strlen(kx_anon_priority) + 1);
- if (prio == NULL)
+ if (prio == nullptr)
throw AuthFailureException("Not enough memory for GnuTLS priority string");
strcpy(prio, Security::GnuTLSPriority);
@@ -239,7 +239,7 @@ void SSecurityTLS::setParams(gnutls_session_t session)
prio = (char*)malloc(strlen(gnutls_default_priority) +
strlen(kx_anon_priority) + 1);
- if (prio == NULL)
+ if (prio == nullptr)
throw AuthFailureException("Not enough memory for GnuTLS priority string");
strcpy(prio, gnutls_default_priority);
diff --git a/common/rfb/SSecurityTLS.h b/common/rfb/SSecurityTLS.h
index d0f735fe..c29ee474 100644
--- a/common/rfb/SSecurityTLS.h
+++ b/common/rfb/SSecurityTLS.h
@@ -45,16 +45,16 @@ namespace rfb {
public:
SSecurityTLS(SConnection* sc, bool _anon);
virtual ~SSecurityTLS();
- virtual bool processMsg();
- virtual const char* getUserName() const {return 0;}
- virtual int getType() const { return anon ? secTypeTLSNone : secTypeX509None;}
+ bool processMsg() override;
+ const char* getUserName() const override {return nullptr;}
+ int getType() const override { return anon ? secTypeTLSNone : secTypeX509None;}
static StringParameter X509_CertFile;
static StringParameter X509_KeyFile;
protected:
void shutdown();
- void setParams(gnutls_session_t session);
+ void setParams();
private:
gnutls_session_t session;
diff --git a/common/rfb/SSecurityVeNCrypt.cxx b/common/rfb/SSecurityVeNCrypt.cxx
index 2813f299..ce160503 100644
--- a/common/rfb/SSecurityVeNCrypt.cxx
+++ b/common/rfb/SSecurityVeNCrypt.cxx
@@ -38,10 +38,11 @@ using namespace std;
static LogWriter vlog("SVeNCrypt");
-SSecurityVeNCrypt::SSecurityVeNCrypt(SConnection* sc, SecurityServer *sec)
- : SSecurity(sc), security(sec)
+SSecurityVeNCrypt::SSecurityVeNCrypt(SConnection* sc_,
+ SecurityServer *sec)
+ : SSecurity(sc_), security(sec)
{
- ssecurity = NULL;
+ ssecurity = nullptr;
haveSentVersion = false;
haveRecvdMajorVersion = false;
haveRecvdMinorVersion = false;
@@ -51,7 +52,7 @@ SSecurityVeNCrypt::SSecurityVeNCrypt(SConnection* sc, SecurityServer *sec)
haveChosenType = false;
chosenType = secTypeVeNCrypt;
numTypes = 0;
- subTypes = NULL;
+ subTypes = nullptr;
}
SSecurityVeNCrypt::~SSecurityVeNCrypt()
@@ -175,14 +176,14 @@ bool SSecurityVeNCrypt::processMsg()
const char* SSecurityVeNCrypt::getUserName() const
{
- if (ssecurity == NULL)
- return NULL;
+ if (ssecurity == nullptr)
+ return nullptr;
return ssecurity->getUserName();
}
AccessRights SSecurityVeNCrypt::getAccessRights() const
{
- if (ssecurity == NULL)
+ if (ssecurity == nullptr)
return SSecurity::getAccessRights();
return ssecurity->getAccessRights();
}
diff --git a/common/rfb/SSecurityVeNCrypt.h b/common/rfb/SSecurityVeNCrypt.h
index 91713f89..ea2bb6fb 100644
--- a/common/rfb/SSecurityVeNCrypt.h
+++ b/common/rfb/SSecurityVeNCrypt.h
@@ -34,10 +34,10 @@ namespace rfb {
public:
SSecurityVeNCrypt(SConnection* sc, SecurityServer *sec);
~SSecurityVeNCrypt();
- virtual bool processMsg();
- virtual int getType() const { return chosenType; }
- virtual const char* getUserName() const;
- virtual AccessRights getAccessRights() const;
+ bool processMsg() override;
+ int getType() const override { return chosenType; }
+ const char* getUserName() const override;
+ AccessRights getAccessRights() const override;
protected:
SSecurity *ssecurity;
diff --git a/common/rfb/SSecurityVncAuth.cxx b/common/rfb/SSecurityVncAuth.cxx
index c1ef1f1c..1276f68a 100644
--- a/common/rfb/SSecurityVncAuth.cxx
+++ b/common/rfb/SSecurityVncAuth.cxx
@@ -52,8 +52,8 @@ VncAuthPasswdParameter SSecurityVncAuth::vncAuthPasswd
("Password", "Obfuscated binary encoding of the password which clients must supply to "
"access the server", &SSecurityVncAuth::vncAuthPasswdFile);
-SSecurityVncAuth::SSecurityVncAuth(SConnection* sc)
- : SSecurity(sc), sentChallenge(false),
+SSecurityVncAuth::SSecurityVncAuth(SConnection* sc_)
+ : SSecurity(sc_), sentChallenge(false),
pg(&vncAuthPasswd), accessRights(AccessNone)
{
}
@@ -116,10 +116,12 @@ bool SSecurityVncAuth::processMsg()
throw AuthFailureException();
}
-VncAuthPasswdParameter::VncAuthPasswdParameter(const char* name,
+VncAuthPasswdParameter::VncAuthPasswdParameter(const char* name_,
const char* desc,
StringParameter* passwdFile_)
-: BinaryParameter(name, desc, 0, 0, ConfServer), passwdFile(passwdFile_) {
+: BinaryParameter(name_, desc, nullptr, 0, ConfServer),
+ passwdFile(passwdFile_)
+{
}
void VncAuthPasswdParameter::getVncAuthPasswd(std::string *password, std::string *readOnlyPassword) {
@@ -151,8 +153,8 @@ void VncAuthPasswdParameter::getVncAuthPasswd(std::string *password, std::string
}
}
- assert(password != NULL);
- assert(readOnlyPassword != NULL);
+ assert(password != nullptr);
+ assert(readOnlyPassword != nullptr);
try {
*password = deobfuscate(obfuscated.data(), obfuscated.size());
diff --git a/common/rfb/SSecurityVncAuth.h b/common/rfb/SSecurityVncAuth.h
index 7f27b02b..532abe0a 100644
--- a/common/rfb/SSecurityVncAuth.h
+++ b/common/rfb/SSecurityVncAuth.h
@@ -44,7 +44,7 @@ namespace rfb {
class VncAuthPasswdParameter : public VncAuthPasswdGetter, BinaryParameter {
public:
VncAuthPasswdParameter(const char* name, const char* desc, StringParameter* passwdFile_);
- virtual void getVncAuthPasswd(std::string *password, std::string *readOnlyPassword);
+ void getVncAuthPasswd(std::string *password, std::string *readOnlyPassword) override;
protected:
StringParameter* passwdFile;
};
@@ -52,10 +52,10 @@ namespace rfb {
class SSecurityVncAuth : public SSecurity {
public:
SSecurityVncAuth(SConnection* sc);
- virtual bool processMsg();
- virtual int getType() const {return secTypeVncAuth;}
- virtual const char* getUserName() const {return 0;}
- virtual AccessRights getAccessRights() const { return accessRights; }
+ bool processMsg() override;
+ int getType() const override {return secTypeVncAuth;}
+ const char* getUserName() const override {return nullptr;}
+ AccessRights getAccessRights() const override { return accessRights; }
static StringParameter vncAuthPasswdFile;
static VncAuthPasswdParameter vncAuthPasswd;
private:
diff --git a/common/rfb/Security.cxx b/common/rfb/Security.cxx
index caf6420f..01191c65 100644
--- a/common/rfb/Security.cxx
+++ b/common/rfb/Security.cxx
@@ -21,29 +21,14 @@
#include <config.h>
#endif
-#include <assert.h>
-#include <stdlib.h>
#include <string.h>
-#include <rfb/CSecurityNone.h>
-#include <rfb/CSecurityStack.h>
-#include <rfb/CSecurityVeNCrypt.h>
-#include <rfb/CSecurityVncAuth.h>
-#include <rfb/CSecurityPlain.h>
-#include <rdr/Exception.h>
+
+#include <algorithm>
+
#include <rfb/LogWriter.h>
#include <rfb/Security.h>
-#include <rfb/SSecurityNone.h>
-#include <rfb/SSecurityStack.h>
-#include <rfb/SSecurityPlain.h>
-#include <rfb/SSecurityVncAuth.h>
-#include <rfb/SSecurityVeNCrypt.h>
-#ifdef HAVE_GNUTLS
-#include <rfb/CSecurityTLS.h>
-#include <rfb/SSecurityTLS.h>
-#endif
#include <rfb/util.h>
-using namespace rdr;
using namespace rfb;
using namespace std;
@@ -67,23 +52,22 @@ Security::Security(StringParameter &secTypes)
const std::list<uint8_t> Security::GetEnabledSecTypes(void)
{
list<uint8_t> result;
- list<uint32_t>::iterator i;
/* Partial workaround for Vino's stupid behaviour. It doesn't allow
* the basic authentication types as part of the VeNCrypt handshake,
* making it impossible for a client to do opportunistic encryption.
* At least make it possible to connect when encryption is explicitly
* disabled. */
- for (i = enabledSecTypes.begin(); i != enabledSecTypes.end(); i++) {
- if (*i >= 0x100) {
+ for (uint32_t type : enabledSecTypes) {
+ if (type >= 0x100) {
result.push_back(secTypeVeNCrypt);
break;
}
}
- for (i = enabledSecTypes.begin(); i != enabledSecTypes.end(); i++)
- if (*i < 0x100)
- result.push_back(*i);
+ for (uint32_t type : enabledSecTypes)
+ if (type < 0x100)
+ result.push_back(type);
return result;
}
@@ -91,33 +75,28 @@ const std::list<uint8_t> Security::GetEnabledSecTypes(void)
const std::list<uint32_t> Security::GetEnabledExtSecTypes(void)
{
list<uint32_t> result;
- list<uint32_t>::iterator i;
- for (i = enabledSecTypes.begin(); i != enabledSecTypes.end(); i++)
- if (*i != secTypeVeNCrypt) /* Do not include VeNCrypt type to avoid loops */
- result.push_back(*i);
+ for (uint32_t type : enabledSecTypes)
+ if (type != secTypeVeNCrypt) /* Do not include VeNCrypt type to avoid loops */
+ result.push_back(type);
return result;
}
void Security::EnableSecType(uint32_t secType)
{
- list<uint32_t>::iterator i;
-
- for (i = enabledSecTypes.begin(); i != enabledSecTypes.end(); i++)
- if (*i == secType)
- return;
+ if (std::find(enabledSecTypes.begin(), enabledSecTypes.end(),
+ secType) != enabledSecTypes.end())
+ return;
enabledSecTypes.push_back(secType);
}
bool Security::IsSupported(uint32_t secType)
{
- list<uint32_t>::iterator i;
-
- for (i = enabledSecTypes.begin(); i != enabledSecTypes.end(); i++)
- if (*i == secType)
- return true;
+ if (std::find(enabledSecTypes.begin(), enabledSecTypes.end(),
+ secType) != enabledSecTypes.end())
+ return true;
if (secType == secTypeVeNCrypt)
return true;
@@ -126,15 +105,14 @@ bool Security::IsSupported(uint32_t secType)
char *Security::ToString(void)
{
- list<uint32_t>::iterator i;
static char out[128]; /* Should be enough */
bool firstpass = true;
const char *name;
memset(out, 0, sizeof(out));
- for (i = enabledSecTypes.begin(); i != enabledSecTypes.end(); i++) {
- name = secTypeName(*i);
+ for (uint32_t type : enabledSecTypes) {
+ name = secTypeName(type);
if (name[0] == '[') /* Unknown security type */
continue;
diff --git a/common/rfb/SecurityClient.cxx b/common/rfb/SecurityClient.cxx
index 1350640d..12860662 100644
--- a/common/rfb/SecurityClient.cxx
+++ b/common/rfb/SecurityClient.cxx
@@ -41,9 +41,9 @@
using namespace rdr;
using namespace rfb;
-UserPasswdGetter *CSecurity::upg = NULL;
+UserPasswdGetter *CSecurity::upg = nullptr;
#if defined(HAVE_GNUTLS) || defined(HAVE_NETTLE)
-UserMsgBox *CSecurity::msg = NULL;
+UserMsgBox *CSecurity::msg = nullptr;
#endif
StringParameter SecurityClient::secTypes
@@ -67,9 +67,9 @@ ConfViewer);
CSecurity* SecurityClient::GetCSecurity(CConnection* cc, uint32_t secType)
{
- assert (CSecurity::upg != NULL); /* (upg == NULL) means bug in the viewer */
+ assert (CSecurity::upg != nullptr); /* (upg == nullptr) means bug in the viewer */
#if defined(HAVE_GNUTLS) || defined(HAVE_NETTLE)
- assert (CSecurity::msg != NULL);
+ assert (CSecurity::msg != nullptr);
#endif
if (!IsSupported(secType))
diff --git a/common/rfb/ServerParams.cxx b/common/rfb/ServerParams.cxx
index 6af446c2..9f6f5307 100644
--- a/common/rfb/ServerParams.cxx
+++ b/common/rfb/ServerParams.cxx
@@ -38,7 +38,7 @@ ServerParams::ServerParams()
{
setName("");
- cursor_ = new Cursor(0, 0, Point(), NULL);
+ cursor_ = new Cursor(0, 0, Point(), nullptr);
clipFlags = 0;
memset(clipSizes, 0, sizeof(clipSizes));
diff --git a/common/rfb/TightDecoder.cxx b/common/rfb/TightDecoder.cxx
index 54b620ea..807f71a5 100644
--- a/common/rfb/TightDecoder.cxx
+++ b/common/rfb/TightDecoder.cxx
@@ -345,7 +345,7 @@ void TightDecoder::decodeRect(const Rect& r, const uint8_t* buffer,
size_t rowSize, dataSize;
uint8_t* netbuf;
- netbuf = NULL;
+ netbuf = nullptr;
if (palSize != 0) {
if (palSize <= 2)
@@ -387,7 +387,7 @@ void TightDecoder::decodeRect(const Rect& r, const uint8_t* buffer,
zis[streamId].readBytes(netbuf, dataSize);
zis[streamId].flushUnderlying();
- zis[streamId].setUnderlying(NULL, 0);
+ zis[streamId].setUnderlying(nullptr, 0);
delete ms;
bufptr = netbuf;
diff --git a/common/rfb/TightDecoder.h b/common/rfb/TightDecoder.h
index 764f138e..d569a7fd 100644
--- a/common/rfb/TightDecoder.h
+++ b/common/rfb/TightDecoder.h
@@ -31,18 +31,17 @@ namespace rfb {
public:
TightDecoder();
virtual ~TightDecoder();
- virtual bool readRect(const Rect& r, rdr::InStream* is,
- const ServerParams& server, rdr::OutStream* os);
- virtual bool doRectsConflict(const Rect& rectA,
- const uint8_t* bufferA,
- size_t buflenA,
- const Rect& rectB,
- const uint8_t* bufferB,
- size_t buflenB,
- const ServerParams& server);
- virtual void decodeRect(const Rect& r, const uint8_t* buffer,
- size_t buflen, const ServerParams& server,
- ModifiablePixelBuffer* pb);
+ bool readRect(const Rect& r, rdr::InStream* is,
+ const ServerParams& server,
+ rdr::OutStream* os) override;
+ bool doRectsConflict(const Rect& rectA,
+ const uint8_t* bufferA, size_t buflenA,
+ const Rect& rectB,
+ const uint8_t* bufferB, size_t buflenB,
+ const ServerParams& server) override;
+ void decodeRect(const Rect& r, const uint8_t* buffer,
+ size_t buflen, const ServerParams& server,
+ ModifiablePixelBuffer* pb) override;
private:
uint32_t readCompact(rdr::InStream* is);
diff --git a/common/rfb/TightEncoder.cxx b/common/rfb/TightEncoder.cxx
index 1a169a3d..169b74f7 100644
--- a/common/rfb/TightEncoder.cxx
+++ b/common/rfb/TightEncoder.cxx
@@ -60,8 +60,8 @@ static const TightConf conf[10] = {
{ 9, 9, 9 } // 9
};
-TightEncoder::TightEncoder(SConnection* conn) :
- Encoder(conn, encodingTight, EncoderPlain, 256)
+TightEncoder::TightEncoder(SConnection* conn_) :
+ Encoder(conn_, encodingTight, EncoderPlain, 256)
{
setCompressLevel(-1);
}
@@ -260,12 +260,12 @@ void TightEncoder::flushZlibOutStream(rdr::OutStream* os_)
rdr::ZlibOutStream* zos;
zos = dynamic_cast<rdr::ZlibOutStream*>(os_);
- if (zos == NULL)
+ if (zos == nullptr)
return;
zos->cork(false);
zos->flush();
- zos->setUnderlying(NULL);
+ zos->setUnderlying(nullptr);
os = conn->getOutStream();
diff --git a/common/rfb/TightEncoder.h b/common/rfb/TightEncoder.h
index 0608eb09..3a7210c7 100644
--- a/common/rfb/TightEncoder.h
+++ b/common/rfb/TightEncoder.h
@@ -31,14 +31,14 @@ namespace rfb {
TightEncoder(SConnection* conn);
virtual ~TightEncoder();
- virtual bool isSupported();
+ bool isSupported() override;
- virtual void setCompressLevel(int level);
+ void setCompressLevel(int level) override;
- virtual void writeRect(const PixelBuffer* pb, const Palette& palette);
- virtual void writeSolidRect(int width, int height,
- const PixelFormat& pf,
- const uint8_t* colour);
+ void writeRect(const PixelBuffer* pb,
+ const Palette& palette) override;
+ void writeSolidRect(int width, int height, const PixelFormat& pf,
+ const uint8_t* colour) override;
protected:
void writeMonoRect(const PixelBuffer* pb, const Palette& palette);
diff --git a/common/rfb/TightJPEGEncoder.cxx b/common/rfb/TightJPEGEncoder.cxx
index 5c8706ee..de8fd77f 100644
--- a/common/rfb/TightJPEGEncoder.cxx
+++ b/common/rfb/TightJPEGEncoder.cxx
@@ -68,8 +68,8 @@ static const struct TightJPEGConfiguration conf[10] = {
};
-TightJPEGEncoder::TightJPEGEncoder(SConnection* conn) :
- Encoder(conn, encodingTight,
+TightJPEGEncoder::TightJPEGEncoder(SConnection* conn_) :
+ Encoder(conn_, encodingTight,
(EncoderFlags)(EncoderUseNativePF | EncoderLossy), -1, 9),
qualityLevel(-1), fineQuality(-1), fineSubsampling(subsampleUndefined)
{
diff --git a/common/rfb/TightJPEGEncoder.h b/common/rfb/TightJPEGEncoder.h
index 002deabb..81d9f40d 100644
--- a/common/rfb/TightJPEGEncoder.h
+++ b/common/rfb/TightJPEGEncoder.h
@@ -30,17 +30,17 @@ namespace rfb {
TightJPEGEncoder(SConnection* conn);
virtual ~TightJPEGEncoder();
- virtual bool isSupported();
+ bool isSupported() override;
- virtual void setQualityLevel(int level);
- virtual void setFineQualityLevel(int quality, int subsampling);
+ void setQualityLevel(int level) override;
+ void setFineQualityLevel(int quality, int subsampling) override;
- virtual int getQualityLevel();
+ int getQualityLevel() override;
- virtual void writeRect(const PixelBuffer* pb, const Palette& palette);
- virtual void writeSolidRect(int width, int height,
- const PixelFormat& pf,
- const uint8_t* colour);
+ void writeRect(const PixelBuffer* pb,
+ const Palette& palette) override;
+ void writeSolidRect(int width, int height, const PixelFormat& pf,
+ const uint8_t* colour) override;
protected:
void writeCompact(uint32_t value, rdr::OutStream* os);
diff --git a/common/rfb/Timer.cxx b/common/rfb/Timer.cxx
index e9ae5227..5216c7e3 100644
--- a/common/rfb/Timer.cxx
+++ b/common/rfb/Timer.cxx
@@ -26,6 +26,8 @@
#include <stdio.h>
#include <sys/time.h>
+#include <algorithm>
+
#include <rfb/Timer.h>
#include <rfb/util.h>
#include <rfb/LogWriter.h>
@@ -63,7 +65,7 @@ int Timer::checkTimeouts() {
if (pending.empty())
return -1;
- gettimeofday(&start, 0);
+ gettimeofday(&start, nullptr);
while (pending.front()->isBefore(start)) {
Timer* timer;
@@ -81,7 +83,7 @@ int Timer::checkTimeouts() {
int Timer::getNextTimeout() {
timeval now;
- gettimeofday(&now, 0);
+ gettimeofday(&now, nullptr);
if (pending.empty())
return -1;
@@ -115,7 +117,7 @@ void Timer::insertTimer(Timer* t) {
void Timer::start(int timeoutMs_) {
timeval now;
- gettimeofday(&now, 0);
+ gettimeofday(&now, nullptr);
stop();
timeoutMs = timeoutMs_;
dueTime = addMillis(now, timeoutMs);
@@ -125,7 +127,7 @@ void Timer::start(int timeoutMs_) {
void Timer::repeat(int timeoutMs_) {
timeval now;
- gettimeofday(&now, 0);
+ gettimeofday(&now, nullptr);
if (isStarted()) {
vlog.error("Incorrectly repeating already running timer");
@@ -153,12 +155,8 @@ void Timer::stop() {
}
bool Timer::isStarted() {
- std::list<Timer*>::iterator i;
- for (i=pending.begin(); i!=pending.end(); i++) {
- if (*i == this)
- return true;
- }
- return false;
+ return std::find(pending.begin(), pending.end(),
+ this) != pending.end();
}
int Timer::getTimeoutMs() {
@@ -167,7 +165,7 @@ int Timer::getTimeoutMs() {
int Timer::getRemainingMs() {
timeval now;
- gettimeofday(&now, 0);
+ gettimeofday(&now, nullptr);
return __rfbmax(0, diffTimeMillis(dueTime, now));
}
diff --git a/common/rfb/Timer.h b/common/rfb/Timer.h
index 36ec46c5..362cb84e 100644
--- a/common/rfb/Timer.h
+++ b/common/rfb/Timer.h
@@ -124,7 +124,7 @@ namespace rfb {
MethodTimer(T* obj_, void (T::*cb_)(Timer*))
: Timer(this), obj(obj_), cb(cb_) {}
- virtual void handleTimeout(Timer* t) { (obj->*cb)(t); }
+ void handleTimeout(Timer* t) override { return (obj->*cb)(t); }
private:
T* obj;
diff --git a/common/rfb/UnixPasswordValidator.h b/common/rfb/UnixPasswordValidator.h
index 28d083a1..4d623d6c 100644
--- a/common/rfb/UnixPasswordValidator.h
+++ b/common/rfb/UnixPasswordValidator.h
@@ -28,7 +28,7 @@ namespace rfb
class UnixPasswordValidator: public PasswordValidator {
protected:
bool validateInternal(SConnection * sc, const char *username,
- const char *password);
+ const char *password) override;
};
}
diff --git a/common/rfb/UpdateTracker.h b/common/rfb/UpdateTracker.h
index 8983b378..e91b9621 100644
--- a/common/rfb/UpdateTracker.h
+++ b/common/rfb/UpdateTracker.h
@@ -53,14 +53,14 @@ namespace rfb {
class ClippingUpdateTracker : public UpdateTracker {
public:
- ClippingUpdateTracker() : ut(0) {}
+ ClippingUpdateTracker() : ut(nullptr) {}
ClippingUpdateTracker(UpdateTracker* ut_, const Rect& r=Rect()) : ut(ut_), clipRect(r) {}
void setUpdateTracker(UpdateTracker* ut_) {ut = ut_;}
void setClipRect(const Rect& cr) {clipRect = cr;}
- virtual void add_changed(const Region &region);
- virtual void add_copied(const Region &dest, const Point &delta);
+ void add_changed(const Region &region) override;
+ void add_copied(const Region &dest, const Point &delta) override;
protected:
UpdateTracker* ut;
Rect clipRect;
@@ -71,8 +71,8 @@ namespace rfb {
SimpleUpdateTracker();
virtual ~SimpleUpdateTracker();
- virtual void add_changed(const Region &region);
- virtual void add_copied(const Region &dest, const Point &delta);
+ void add_changed(const Region &region) override;
+ void add_copied(const Region &dest, const Point &delta) override;
virtual void subtract(const Region& region);
// Fill the supplied UpdateInfo structure with update information
diff --git a/common/rfb/VNCSConnectionST.cxx b/common/rfb/VNCSConnectionST.cxx
index 306bba1d..a40a1a30 100644
--- a/common/rfb/VNCSConnectionST.cxx
+++ b/common/rfb/VNCSConnectionST.cxx
@@ -48,7 +48,7 @@ using namespace rfb;
static LogWriter vlog("VNCSConnST");
-static Cursor emptyCursor(0, 0, Point(0, 0), NULL);
+static Cursor emptyCursor(0, 0, Point(0, 0), nullptr);
VNCSConnectionST::VNCSConnectionST(VNCServerST* server_, network::Socket *s,
bool reverse, AccessRights ar)
@@ -56,7 +56,7 @@ VNCSConnectionST::VNCSConnectionST(VNCServerST* server_, network::Socket *s,
sock(s), reverseConnection(reverse),
inProcessMessages(false),
pendingSyncFence(false), syncFence(false), fenceFlags(0),
- fenceDataLen(0), fenceData(NULL), congestionTimer(this),
+ fenceDataLen(0), fenceData(nullptr), congestionTimer(this),
losslessTimer(this), server(server_),
updateRenderedCursor(false), removeRenderedCursor(false),
continuousUpdates(false), encodeManager(this), idleTimer(this),
@@ -409,7 +409,7 @@ bool VNCSConnectionST::needRenderedCursor()
if (!client.supportsLocalCursor())
return true;
if ((server->getCursorPos() != pointerEventPos) &&
- (time(0) - pointerEventTime) > 0)
+ (time(nullptr) - pointerEventTime) > 0)
return true;
return false;
@@ -481,7 +481,7 @@ void VNCSConnectionST::pointerEvent(const Point& pos, int buttonMask)
{
if (rfb::Server::idleTimeout)
idleTimer.start(secsToMillis(rfb::Server::idleTimeout));
- pointerEventTime = time(0);
+ pointerEventTime = time(nullptr);
if (!accessCheck(AccessPtrEvents)) return;
if (!rfb::Server::acceptPointerEvents) return;
pointerEventPos = pos;
@@ -690,7 +690,7 @@ void VNCSConnectionST::fence(uint32_t flags, unsigned len, const uint8_t data[])
fenceFlags = flags & (fenceFlagBlockBefore | fenceFlagBlockAfter | fenceFlagSyncNext);
fenceDataLen = len;
delete [] fenceData;
- fenceData = NULL;
+ fenceData = nullptr;
if (len > 0) {
fenceData = new uint8_t[len];
memcpy(fenceData, data, len);
@@ -1001,7 +1001,7 @@ void VNCSConnectionST::writeDataUpdate()
// Does the client need a server-side rendered cursor?
- cursor = NULL;
+ cursor = nullptr;
if (needRenderedCursor()) {
Rect renderedCursorRect;
@@ -1083,7 +1083,7 @@ void VNCSConnectionST::writeLosslessRefresh()
// Prepare the cursor in case it overlaps with a region getting
// refreshed
- cursor = NULL;
+ cursor = nullptr;
if (needRenderedCursor())
cursor = server->getRenderedCursor();
diff --git a/common/rfb/VNCSConnectionST.h b/common/rfb/VNCSConnectionST.h
index 3a9ec242..e9badd72 100644
--- a/common/rfb/VNCSConnectionST.h
+++ b/common/rfb/VNCSConnectionST.h
@@ -46,8 +46,8 @@ namespace rfb {
// SConnection methods
- virtual bool accessCheck(AccessRights ar) const;
- virtual void close(const char* reason);
+ bool accessCheck(AccessRights ar) const override;
+ void close(const char* reason) override;
using SConnection::authenticated;
@@ -118,30 +118,32 @@ namespace rfb {
private:
// SConnection callbacks
- // These methods are invoked as callbacks from processMsg()
-
- virtual void authSuccess();
- virtual void queryConnection(const char* userName);
- virtual void clientInit(bool shared);
- virtual void setPixelFormat(const PixelFormat& pf);
- virtual void pointerEvent(const Point& pos, int buttonMask);
- virtual void keyEvent(uint32_t keysym, uint32_t keycode, bool down);
- virtual void framebufferUpdateRequest(const Rect& r, bool incremental);
- virtual void setDesktopSize(int fb_width, int fb_height,
- const ScreenSet& layout);
- virtual void fence(uint32_t flags, unsigned len, const uint8_t data[]);
- virtual void enableContinuousUpdates(bool enable,
- int x, int y, int w, int h);
- virtual void handleClipboardRequest();
- virtual void handleClipboardAnnounce(bool available);
- virtual void handleClipboardData(const char* data);
- virtual void supportsLocalCursor();
- virtual void supportsFence();
- virtual void supportsContinuousUpdates();
- virtual void supportsLEDState();
+ // These methods are invoked as callbacks from processMsg(
+ void authSuccess() override;
+ void queryConnection(const char* userName) override;
+ void clientInit(bool shared) override;
+ void setPixelFormat(const PixelFormat& pf) override;
+ void pointerEvent(const Point& pos, int buttonMask) override;
+ void keyEvent(uint32_t keysym, uint32_t keycode,
+ bool down) override;
+ void framebufferUpdateRequest(const Rect& r,
+ bool incremental) override;
+ void setDesktopSize(int fb_width, int fb_height,
+ const ScreenSet& layout) override;
+ void fence(uint32_t flags, unsigned len,
+ const uint8_t data[]) override;
+ void enableContinuousUpdates(bool enable,
+ int x, int y, int w, int h) override;
+ void handleClipboardRequest() override;
+ void handleClipboardAnnounce(bool available) override;
+ void handleClipboardData(const char* data) override;
+ void supportsLocalCursor() override;
+ void supportsFence() override;
+ void supportsContinuousUpdates() override;
+ void supportsLEDState() override;
// Timer callbacks
- virtual void handleTimeout(Timer* t);
+ void handleTimeout(Timer* t) override;
// Internal methods
diff --git a/common/rfb/VNCServer.h b/common/rfb/VNCServer.h
index 3ac9fb94..4e3a5b23 100644
--- a/common/rfb/VNCServer.h
+++ b/common/rfb/VNCServer.h
@@ -115,7 +115,7 @@ namespace rfb {
// acceptance, or false for rejection, in which case a string
// reason may also be given.
virtual void approveConnection(network::Socket* sock, bool accept,
- const char* reason = NULL) = 0;
+ const char* reason = nullptr) = 0;
// - Close all currently-connected clients, by calling
// their close() method with the supplied reason.
diff --git a/common/rfb/VNCServerST.cxx b/common/rfb/VNCServerST.cxx
index b9579f12..a8fa1739 100644
--- a/common/rfb/VNCServerST.cxx
+++ b/common/rfb/VNCServerST.cxx
@@ -83,10 +83,10 @@ static LogWriter connectionsLog("Connections");
VNCServerST::VNCServerST(const char* name_, SDesktop* desktop_)
: blHosts(&blacklist), desktop(desktop_), desktopStarted(false),
- blockCounter(0), pb(0), ledState(ledUnknown),
- name(name_), pointerClient(0), clipboardClient(0),
+ blockCounter(0), pb(nullptr), ledState(ledUnknown),
+ name(name_), pointerClient(nullptr), clipboardClient(nullptr),
pointerClientTime(0),
- comparer(0), cursor(new Cursor(0, 0, Point(), NULL)),
+ comparer(nullptr), cursor(new Cursor(0, 0, Point(), nullptr)),
renderedCursorInvalid(false),
keyRemapper(&KeyRemapper::defInstance),
idleTimer(this), disconnectTimer(this), connectTimer(this),
@@ -177,19 +177,19 @@ void VNCServerST::removeSocket(network::Socket* sock) {
if ((*ci)->getSock() == sock) {
// - Remove any references to it
if (pointerClient == *ci)
- pointerClient = NULL;
+ pointerClient = nullptr;
if (clipboardClient == *ci)
handleClipboardAnnounce(*ci, false);
clipboardRequestors.remove(*ci);
- std::string name((*ci)->getPeerEndpoint());
+ std::string peer((*ci)->getPeerEndpoint());
// - Delete the per-Socket resources
delete *ci;
clients.remove(*ci);
- connectionsLog.status("closed: %s", name.c_str());
+ connectionsLog.status("closed: %s", peer.c_str());
// - Check that the desktop object is still required
if (authClientCount() == 0)
@@ -275,7 +275,7 @@ void VNCServerST::setPixelBuffer(PixelBuffer* pb_, const ScreenSet& layout)
pb = pb_;
delete comparer;
- comparer = 0;
+ comparer = nullptr;
if (!pb) {
screenLayout = ScreenSet();
@@ -297,9 +297,8 @@ void VNCServerST::setPixelBuffer(PixelBuffer* pb_, const ScreenSet& layout)
renderedCursorInvalid = true;
add_changed(pb->getRect());
- std::list<VNCSConnectionST*>::iterator ci, ci_next;
- for (ci=clients.begin();ci!=clients.end();ci=ci_next) {
- ci_next = ci; ci_next++;
+ std::list<VNCSConnectionST*>::iterator ci;
+ for (ci = clients.begin(); ci != clients.end(); ++ci) {
(*ci)->pixelBufferChange();
// Since the new pixel buffer means an ExtendedDesktopSize needs to
// be sent anyway, we don't need to call screenLayoutChange.
@@ -346,16 +345,14 @@ void VNCServerST::setScreenLayout(const ScreenSet& layout)
screenLayout = layout;
- std::list<VNCSConnectionST*>::iterator ci, ci_next;
- for (ci=clients.begin();ci!=clients.end();ci=ci_next) {
- ci_next = ci; ci_next++;
+ std::list<VNCSConnectionST*>::iterator ci;
+ for (ci = clients.begin(); ci != clients.end(); ++ci)
(*ci)->screenLayoutChangeOrClose(reasonServer);
- }
}
void VNCServerST::requestClipboard()
{
- if (clipboardClient == NULL) {
+ if (clipboardClient == nullptr) {
slog.debug("Got request for client clipboard but no client currently owns the clipboard");
return;
}
@@ -365,54 +362,46 @@ void VNCServerST::requestClipboard()
void VNCServerST::announceClipboard(bool available)
{
- std::list<VNCSConnectionST*>::iterator ci, ci_next;
+ std::list<VNCSConnectionST*>::iterator ci;
clipboardRequestors.clear();
- for (ci = clients.begin(); ci != clients.end(); ci = ci_next) {
- ci_next = ci; ci_next++;
+ for (ci = clients.begin(); ci != clients.end(); ++ci)
(*ci)->announceClipboardOrClose(available);
- }
}
void VNCServerST::sendClipboardData(const char* data)
{
- std::list<VNCSConnectionST*>::iterator ci, ci_next;
+ std::list<VNCSConnectionST*>::iterator ci;
- if (strchr(data, '\r') != NULL)
+ if (strchr(data, '\r') != nullptr)
throw Exception("Invalid carriage return in clipboard data");
for (ci = clipboardRequestors.begin();
- ci != clipboardRequestors.end(); ci = ci_next) {
- ci_next = ci; ci_next++;
+ ci != clipboardRequestors.end(); ++ci)
(*ci)->sendClipboardDataOrClose(data);
- }
clipboardRequestors.clear();
}
void VNCServerST::bell()
{
- std::list<VNCSConnectionST*>::iterator ci, ci_next;
- for (ci = clients.begin(); ci != clients.end(); ci = ci_next) {
- ci_next = ci; ci_next++;
+ std::list<VNCSConnectionST*>::iterator ci;
+ for (ci = clients.begin(); ci != clients.end(); ++ci)
(*ci)->bellOrClose();
- }
}
void VNCServerST::setName(const char* name_)
{
name = name_;
- std::list<VNCSConnectionST*>::iterator ci, ci_next;
- for (ci = clients.begin(); ci != clients.end(); ci = ci_next) {
- ci_next = ci; ci_next++;
+ std::list<VNCSConnectionST*>::iterator ci;
+ for (ci = clients.begin(); ci != clients.end(); ++ci)
(*ci)->setDesktopNameOrClose(name_);
- }
}
void VNCServerST::add_changed(const Region& region)
{
- if (comparer == NULL)
+ if (comparer == nullptr)
return;
comparer->add_changed(region);
@@ -421,7 +410,7 @@ void VNCServerST::add_changed(const Region& region)
void VNCServerST::add_copied(const Region& dest, const Point& delta)
{
- if (comparer == NULL)
+ if (comparer == nullptr)
return;
comparer->add_copied(dest, delta);
@@ -437,9 +426,8 @@ void VNCServerST::setCursor(int width, int height, const Point& newHotspot,
renderedCursorInvalid = true;
- std::list<VNCSConnectionST*>::iterator ci, ci_next;
- for (ci = clients.begin(); ci != clients.end(); ci = ci_next) {
- ci_next = ci; ci_next++;
+ std::list<VNCSConnectionST*>::iterator ci;
+ for (ci = clients.begin(); ci != clients.end(); ++ci) {
(*ci)->renderedCursorChange();
(*ci)->setCursorOrClose();
}
@@ -461,17 +449,15 @@ void VNCServerST::setCursorPos(const Point& pos, bool warped)
void VNCServerST::setLEDState(unsigned int state)
{
- std::list<VNCSConnectionST*>::iterator ci, ci_next;
+ std::list<VNCSConnectionST*>::iterator ci;
if (state == ledState)
return;
ledState = state;
- for (ci = clients.begin(); ci != clients.end(); ci = ci_next) {
- ci_next = ci; ci_next++;
+ for (ci = clients.begin(); ci != clients.end(); ++ci)
(*ci)->setLEDStateOrClose(state);
- }
}
// Event handlers
@@ -498,14 +484,14 @@ void VNCServerST::keyEvent(uint32_t keysym, uint32_t keycode, bool down)
void VNCServerST::pointerEvent(VNCSConnectionST* client,
const Point& pos, int buttonMask)
{
- time_t now = time(0);
+ time_t now = time(nullptr);
if (rfb::Server::maxIdleTime)
idleTimer.start(secsToMillis(rfb::Server::maxIdleTime));
// Let one client own the cursor whilst buttons are pressed in order
// to provide a bit more sane user experience. But limit the time to
// prevent locking out all others when e.g. the network is down.
- if ((pointerClient != NULL) && (pointerClient != client) &&
+ if ((pointerClient != nullptr) && (pointerClient != client) &&
((now - pointerClientTime) < 10))
return;
@@ -513,7 +499,7 @@ void VNCServerST::pointerEvent(VNCSConnectionST* client,
if (buttonMask)
pointerClient = client;
else
- pointerClient = NULL;
+ pointerClient = nullptr;
desktop->pointerEvent(pos, buttonMask);
}
@@ -533,7 +519,7 @@ void VNCServerST::handleClipboardAnnounce(VNCSConnectionST* client,
else {
if (client != clipboardClient)
return;
- clipboardClient = NULL;
+ clipboardClient = nullptr;
}
desktop->handleClipboardAnnounce(available);
}
@@ -553,7 +539,7 @@ unsigned int VNCServerST::setDesktopSize(VNCSConnectionST* requester,
const ScreenSet& layout)
{
unsigned int result;
- std::list<VNCSConnectionST*>::iterator ci, ci_next;
+ std::list<VNCSConnectionST*>::iterator ci;
// We can't handle a framebuffer larger than this, so don't let a
// client set one (see PixelBuffer.cxx)
@@ -580,8 +566,7 @@ unsigned int VNCServerST::setDesktopSize(VNCSConnectionST* requester,
throw Exception("Desktop configured a different screen layout than requested");
// Notify other clients
- for (ci=clients.begin();ci!=clients.end();ci=ci_next) {
- ci_next = ci; ci_next++;
+ for (ci = clients.begin(); ci != clients.end(); ++ci) {
if ((*ci) == requester)
continue;
(*ci)->screenLayoutChangeOrClose(reasonOtherClient);
@@ -606,9 +591,8 @@ void VNCServerST::approveConnection(network::Socket* sock, bool accept,
void VNCServerST::closeClients(const char* reason, network::Socket* except)
{
- std::list<VNCSConnectionST*>::iterator i, next_i;
- for (i=clients.begin(); i!=clients.end(); i=next_i) {
- next_i = i; next_i++;
+ std::list<VNCSConnectionST*>::iterator i;
+ for (i = clients.begin(); i != clients.end(); ++i) {
if ((*i)->getSock() != except)
(*i)->close(reason);
}
@@ -633,7 +617,7 @@ SConnection* VNCServerST::getConnection(network::Socket* sock) {
if ((*ci)->getSock() == sock)
return (SConnection*)*ci;
}
- return 0;
+ return nullptr;
}
void VNCServerST::handleTimeout(Timer* t)
@@ -697,14 +681,14 @@ void VNCServerST::queryConnection(VNCSConnectionST* client,
// - Are we configured to do queries?
if (!rfb::Server::queryConnect &&
!client->getSock()->requiresQuery()) {
- approveConnection(client->getSock(), true, NULL);
+ approveConnection(client->getSock(), true, nullptr);
return;
}
// - Does the client have the right to bypass the query?
if (client->accessCheck(AccessNoQuery))
{
- approveConnection(client->getSock(), true, NULL);
+ approveConnection(client->getSock(), true, nullptr);
return;
}
@@ -832,7 +816,7 @@ void VNCServerST::writeUpdate()
UpdateInfo ui;
Region toCheck;
- std::list<VNCSConnectionST*>::iterator ci, ci_next;
+ std::list<VNCSConnectionST*>::iterator ci;
assert(blockCounter == 0);
assert(desktopStarted);
@@ -861,8 +845,7 @@ void VNCServerST::writeUpdate()
comparer->clear();
- for (ci = clients.begin(); ci != clients.end(); ci = ci_next) {
- ci_next = ci; ci_next++;
+ for (ci = clients.begin(); ci != clients.end(); ++ci) {
(*ci)->add_copied(ui.copied, ui.copy_delta);
(*ci)->add_changed(ui.changed);
(*ci)->writeFramebufferUpdateOrClose();
@@ -906,9 +889,8 @@ bool VNCServerST::getComparerState()
if (rfb::Server::compareFB != 2)
return true;
- std::list<VNCSConnectionST*>::iterator ci, ci_next;
- for (ci=clients.begin();ci!=clients.end();ci=ci_next) {
- ci_next = ci; ci_next++;
+ std::list<VNCSConnectionST*>::iterator ci;
+ for (ci = clients.begin(); ci != clients.end(); ++ci) {
if ((*ci)->getComparerState())
return true;
}
diff --git a/common/rfb/VNCServerST.h b/common/rfb/VNCServerST.h
index 90c8d753..501882aa 100644
--- a/common/rfb/VNCServerST.h
+++ b/common/rfb/VNCServerST.h
@@ -56,54 +56,54 @@ namespace rfb {
// addSocket
// Causes the server to allocate an RFB-protocol management
// structure for the socket & initialise it.
- virtual void addSocket(network::Socket* sock, bool outgoing=false,
- AccessRights ar=AccessDefault);
+ void addSocket(network::Socket* sock, bool outgoing=false,
+ AccessRights ar=AccessDefault) override;
// removeSocket
// Clean up any resources associated with the Socket
- virtual void removeSocket(network::Socket* sock);
+ void removeSocket(network::Socket* sock) override;
// getSockets() gets a list of sockets. This can be used to generate an
// fd_set for calling select().
- virtual void getSockets(std::list<network::Socket*>* sockets);
+ void getSockets(std::list<network::Socket*>* sockets) override;
// processSocketReadEvent
// Read more RFB data from the Socket. If an error occurs during
// processing then shutdown() is called on the Socket, causing
// removeSocket() to be called by the caller at a later time.
- virtual void processSocketReadEvent(network::Socket* sock);
+ void processSocketReadEvent(network::Socket* sock) override;
// processSocketWriteEvent
// Flush pending data from the Socket on to the network.
- virtual void processSocketWriteEvent(network::Socket* sock);
-
- virtual void blockUpdates();
- virtual void unblockUpdates();
- virtual uint64_t getMsc();
- virtual void queueMsc(uint64_t target);
- virtual void setPixelBuffer(PixelBuffer* pb, const ScreenSet& layout);
- virtual void setPixelBuffer(PixelBuffer* pb);
- virtual void setScreenLayout(const ScreenSet& layout);
- virtual const PixelBuffer* getPixelBuffer() const { return pb; }
-
- virtual void requestClipboard();
- virtual void announceClipboard(bool available);
- virtual void sendClipboardData(const char* data);
-
- virtual void approveConnection(network::Socket* sock, bool accept,
- const char* reason);
- virtual void closeClients(const char* reason) {closeClients(reason, 0);}
- virtual SConnection* getConnection(network::Socket* sock);
-
- virtual void add_changed(const Region &region);
- virtual void add_copied(const Region &dest, const Point &delta);
- virtual void setCursor(int width, int height, const Point& hotspot,
- const uint8_t* data);
- virtual void setCursorPos(const Point& p, bool warped);
- virtual void setName(const char* name_);
- virtual void setLEDState(unsigned state);
-
- virtual void bell();
+ void processSocketWriteEvent(network::Socket* sock) override;
+
+ void blockUpdates() override;
+ void unblockUpdates() override;
+ uint64_t getMsc() override;
+ void queueMsc(uint64_t target) override;
+ void setPixelBuffer(PixelBuffer* pb, const ScreenSet& layout) override;
+ void setPixelBuffer(PixelBuffer* pb) override;
+ void setScreenLayout(const ScreenSet& layout) override;
+ const PixelBuffer* getPixelBuffer() const override { return pb; }
+
+ void requestClipboard() override;
+ void announceClipboard(bool available) override;
+ void sendClipboardData(const char* data) override;
+
+ void approveConnection(network::Socket* sock, bool accept,
+ const char* reason) override;
+ void closeClients(const char* reason) override {closeClients(reason, nullptr);}
+ SConnection* getConnection(network::Socket* sock) override;
+
+ void add_changed(const Region &region) override;
+ void add_copied(const Region &dest, const Point &delta) override;
+ void setCursor(int width, int height, const Point& hotspot,
+ const uint8_t* data) override;
+ void setCursorPos(const Point& p, bool warped) override;
+ void setName(const char* name_) override;
+ void setLEDState(unsigned state) override;
+
+ void bell() override;
// VNCServerST-only methods
@@ -155,7 +155,7 @@ namespace rfb {
protected:
// Timer callbacks
- virtual void handleTimeout(Timer* t);
+ void handleTimeout(Timer* t) override;
// - Internal methods
diff --git a/common/rfb/WinPasswdValidator.h b/common/rfb/WinPasswdValidator.h
index ef2310a9..340a6234 100644
--- a/common/rfb/WinPasswdValidator.h
+++ b/common/rfb/WinPasswdValidator.h
@@ -30,7 +30,7 @@ namespace rfb
WinPasswdValidator() {};
virtual ~WinPasswdValidator() {};
protected:
- bool validateInternal(SConnection *sc, const char* username, const char* password);
+ bool validateInternal(SConnection *sc, const char* username, const char* password) override;
};
}
diff --git a/common/rfb/ZRLEDecoder.cxx b/common/rfb/ZRLEDecoder.cxx
index 4b768afc..474fd6ca 100644
--- a/common/rfb/ZRLEDecoder.cxx
+++ b/common/rfb/ZRLEDecoder.cxx
@@ -106,20 +106,19 @@ void ZRLEDecoder::decodeRect(const Rect& r, const uint8_t* buffer,
rdr::MemInStream is(buffer, buflen);
const rfb::PixelFormat& pf = server.pf();
switch (pf.bpp) {
- case 8: zrleDecode<uint8_t>(r, &is, &zis, pf, pb); break;
- case 16: zrleDecode<uint16_t>(r, &is, &zis, pf, pb); break;
- case 32: zrleDecode<uint32_t>(r, &is, &zis, pf, pb); break;
+ case 8: zrleDecode<uint8_t>(r, &is, pf, pb); break;
+ case 16: zrleDecode<uint16_t>(r, &is, pf, pb); break;
+ case 32: zrleDecode<uint32_t>(r, &is, pf, pb); break;
}
}
template<class T>
void ZRLEDecoder::zrleDecode(const Rect& r, rdr::InStream* is,
- rdr::ZlibInStream* zis,
const PixelFormat& pf,
ModifiablePixelBuffer* pb)
{
int length = is->readU32();
- zis->setUnderlying(is, length);
+ zis.setUnderlying(is, length);
Rect t;
T buf[64 * 64];
@@ -141,24 +140,24 @@ void ZRLEDecoder::zrleDecode(const Rect& r, rdr::InStream* is,
t.br.x = __rfbmin(r.br.x, t.tl.x + 64);
- zlibHasData(zis, 1);
- int mode = zis->readU8();
+ zlibHasData(&zis, 1);
+ int mode = zis.readU8();
bool rle = mode & 128;
int palSize = mode & 127;
T palette[128];
if (isLowCPixel || isHighCPixel)
- zlibHasData(zis, 3 * palSize);
+ zlibHasData(&zis, 3 * palSize);
else
- zlibHasData(zis, sizeof(T) * palSize);
+ zlibHasData(&zis, sizeof(T) * palSize);
for (int i = 0; i < palSize; i++) {
if (isLowCPixel)
- palette[i] = readOpaque24A(zis);
+ palette[i] = readOpaque24A(&zis);
else if (isHighCPixel)
- palette[i] = readOpaque24B(zis);
+ palette[i] = readOpaque24B(&zis);
else
- palette[i] = readPixel<T>(zis);
+ palette[i] = readPixel<T>(&zis);
}
if (palSize == 1) {
@@ -173,19 +172,19 @@ void ZRLEDecoder::zrleDecode(const Rect& r, rdr::InStream* is,
// raw
if (isLowCPixel || isHighCPixel)
- zlibHasData(zis, 3 * t.area());
+ zlibHasData(&zis, 3 * t.area());
else
- zlibHasData(zis, sizeof(T) * t.area());
+ zlibHasData(&zis, sizeof(T) * t.area());
if (isLowCPixel || isHighCPixel) {
for (T* ptr = buf; ptr < buf+t.area(); ptr++) {
if (isLowCPixel)
- *ptr = readOpaque24A(zis);
+ *ptr = readOpaque24A(&zis);
else
- *ptr = readOpaque24B(zis);
+ *ptr = readOpaque24B(&zis);
}
} else {
- zis->readBytes((uint8_t*)buf, t.area() * sizeof(T));
+ zis.readBytes((uint8_t*)buf, t.area() * sizeof(T));
}
} else {
@@ -203,8 +202,8 @@ void ZRLEDecoder::zrleDecode(const Rect& r, rdr::InStream* is,
while (ptr < eol) {
if (nbits == 0) {
- zlibHasData(zis, 1);
- byte = zis->readU8();
+ zlibHasData(&zis, 1);
+ byte = zis.readU8();
nbits = 8;
}
nbits -= bppp;
@@ -225,20 +224,20 @@ void ZRLEDecoder::zrleDecode(const Rect& r, rdr::InStream* is,
while (ptr < end) {
T pix;
if (isLowCPixel || isHighCPixel)
- zlibHasData(zis, 3);
+ zlibHasData(&zis, 3);
else
- zlibHasData(zis, sizeof(T));
+ zlibHasData(&zis, sizeof(T));
if (isLowCPixel)
- pix = readOpaque24A(zis);
+ pix = readOpaque24A(&zis);
else if (isHighCPixel)
- pix = readOpaque24B(zis);
+ pix = readOpaque24B(&zis);
else
- pix = readPixel<T>(zis);
+ pix = readPixel<T>(&zis);
int len = 1;
int b;
do {
- zlibHasData(zis, 1);
- b = zis->readU8();
+ zlibHasData(&zis, 1);
+ b = zis.readU8();
len += b;
} while (b == 255);
@@ -256,14 +255,14 @@ void ZRLEDecoder::zrleDecode(const Rect& r, rdr::InStream* is,
T* ptr = buf;
T* end = ptr + t.area();
while (ptr < end) {
- zlibHasData(zis, 1);
- int index = zis->readU8();
+ zlibHasData(&zis, 1);
+ int index = zis.readU8();
int len = 1;
if (index & 128) {
int b;
do {
- zlibHasData(zis, 1);
- b = zis->readU8();
+ zlibHasData(&zis, 1);
+ b = zis.readU8();
len += b;
} while (b == 255);
@@ -285,6 +284,6 @@ void ZRLEDecoder::zrleDecode(const Rect& r, rdr::InStream* is,
}
}
- zis->flushUnderlying();
- zis->setUnderlying(NULL, 0);
+ zis.flushUnderlying();
+ zis.setUnderlying(nullptr, 0);
}
diff --git a/common/rfb/ZRLEDecoder.h b/common/rfb/ZRLEDecoder.h
index e72bf1b6..facf0adc 100644
--- a/common/rfb/ZRLEDecoder.h
+++ b/common/rfb/ZRLEDecoder.h
@@ -30,16 +30,16 @@ namespace rfb {
public:
ZRLEDecoder();
virtual ~ZRLEDecoder();
- virtual bool readRect(const Rect& r, rdr::InStream* is,
- const ServerParams& server, rdr::OutStream* os);
- virtual void decodeRect(const Rect& r, const uint8_t* buffer,
- size_t buflen, const ServerParams& server,
- ModifiablePixelBuffer* pb);
+ bool readRect(const Rect& r, rdr::InStream* is,
+ const ServerParams& server,
+ rdr::OutStream* os) override;
+ void decodeRect(const Rect& r, const uint8_t* buffer,
+ size_t buflen, const ServerParams& server,
+ ModifiablePixelBuffer* pb) override;
private:
template<class T>
void zrleDecode(const Rect& r, rdr::InStream* is,
- rdr::ZlibInStream* zis,
const PixelFormat& pf, ModifiablePixelBuffer* pb);
private:
diff --git a/common/rfb/ZRLEEncoder.cxx b/common/rfb/ZRLEEncoder.cxx
index ad3aec1a..1e2c6ef4 100644
--- a/common/rfb/ZRLEEncoder.cxx
+++ b/common/rfb/ZRLEEncoder.cxx
@@ -36,9 +36,9 @@ static LogWriter vlog("ZRLEEncoder");
IntParameter zlibLevel("ZlibLevel","[DEPRECATED] Zlib compression level",-1);
-ZRLEEncoder::ZRLEEncoder(SConnection* conn)
- : Encoder(conn, encodingZRLE, EncoderPlain, 127),
- zos(0, 2), mos(129*1024)
+ZRLEEncoder::ZRLEEncoder(SConnection* conn_)
+ : Encoder(conn_, encodingZRLE, EncoderPlain, 127),
+ zos(nullptr, 2), mos(129*1024)
{
if (zlibLevel != -1) {
vlog.info("Warning: The ZlibLevel option is deprecated and is "
@@ -50,7 +50,7 @@ ZRLEEncoder::ZRLEEncoder(SConnection* conn)
ZRLEEncoder::~ZRLEEncoder()
{
- zos.setUnderlying(NULL);
+ zos.setUnderlying(nullptr);
}
bool ZRLEEncoder::isSupported()
diff --git a/common/rfb/ZRLEEncoder.h b/common/rfb/ZRLEEncoder.h
index fa89f10f..87d87e94 100644
--- a/common/rfb/ZRLEEncoder.h
+++ b/common/rfb/ZRLEEncoder.h
@@ -30,14 +30,14 @@ namespace rfb {
ZRLEEncoder(SConnection* conn);
virtual ~ZRLEEncoder();
- virtual bool isSupported();
+ bool isSupported() override;
- virtual void setCompressLevel(int level);
+ void setCompressLevel(int level) override;
- virtual void writeRect(const PixelBuffer* pb, const Palette& palette);
- virtual void writeSolidRect(int width, int height,
- const PixelFormat& pf,
- const uint8_t* colour);
+ void writeRect(const PixelBuffer* pb,
+ const Palette& palette) override;
+ void writeSolidRect(int width, int height, const PixelFormat& pf,
+ const uint8_t* colour) override;
protected:
void writePaletteTile(const Rect& tile, const PixelBuffer* pb,
diff --git a/common/rfb/obfuscate.cxx b/common/rfb/obfuscate.cxx
index d40e25c3..2afc1512 100644
--- a/common/rfb/obfuscate.cxx
+++ b/common/rfb/obfuscate.cxx
@@ -41,7 +41,7 @@ std::vector<uint8_t> rfb::obfuscate(const char *str)
{
std::vector<uint8_t> buf(8);
- assert(str != NULL);
+ assert(str != nullptr);
size_t l = strlen(str), i;
for (i=0; i<8; i++)
@@ -59,7 +59,7 @@ std::string rfb::deobfuscate(const uint8_t *data, size_t len)
if (len != 8)
throw rdr::Exception("bad obfuscated password length");
- assert(data != NULL);
+ assert(data != nullptr);
deskey(d3desObfuscationKey, DE1);
des((uint8_t*)data, (uint8_t*)buf);
diff --git a/common/rfb/util.cxx b/common/rfb/util.cxx
index 48f59846..3c62b1df 100644
--- a/common/rfb/util.cxx
+++ b/common/rfb/util.cxx
@@ -40,7 +40,7 @@ namespace rfb {
std::string out;
va_start(ap, fmt);
- len = vsnprintf(NULL, 0, fmt, ap);
+ len = vsnprintf(nullptr, 0, fmt, ap);
va_end(ap);
if (len < 0)
@@ -68,13 +68,13 @@ namespace rfb {
start = src;
do {
stop = strchr(start, delimiter);
- if (stop == NULL) {
+ if (stop == nullptr) {
out.push_back(start);
} else {
out.push_back(std::string(start, stop-start));
start = stop + 1;
}
- } while (stop != NULL);
+ } while (stop != nullptr);
return out;
}
@@ -621,7 +621,7 @@ namespace rfb {
{
struct timeval now;
- gettimeofday(&now, NULL);
+ gettimeofday(&now, nullptr);
return msBetween(then, &now);
}
diff --git a/release/CMakeLists.txt b/release/CMakeLists.txt
index 043cc1c5..6cb14de0 100644
--- a/release/CMakeLists.txt
+++ b/release/CMakeLists.txt
@@ -18,7 +18,7 @@ configure_file(tigervnc.iss.in tigervnc.iss)
add_custom_target(installer
iscc -o. ${INST_DEFS} -F${CMAKE_PROJECT_NAME}${INST_SUFFIX}-${VERSION} tigervnc.iss
DEPENDS vncviewer
- SOURCES tigervnc.iss)
+ SOURCES ${CMAKE_CURRENT_BINARY_DIR}/tigervnc.iss)
if(BUILD_WINVNC)
configure_file(winvnc.iss.in winvnc.iss)
@@ -26,7 +26,7 @@ if(BUILD_WINVNC)
add_custom_target(winvnc_installer
iscc -o. ${INST_DEFS} -F${CMAKE_PROJECT_NAME}${INST_SUFFIX}-winvnc-${VERSION} winvnc.iss
DEPENDS winvnc4 wm_hooks vncconfig
- SOURCES winvnc.iss)
+ SOURCES ${CMAKE_CURRENT_BINARY_DIR}/winvnc.iss)
endif()
endif() # WIN32
diff --git a/tests/perf/decperf.cxx b/tests/perf/decperf.cxx
index c72ec1d7..66a50d02 100644
--- a/tests/perf/decperf.cxx
+++ b/tests/perf/decperf.cxx
@@ -52,11 +52,11 @@ class DummyOutStream : public rdr::OutStream {
public:
DummyOutStream();
- virtual size_t length();
- virtual void flush();
+ size_t length() override;
+ void flush() override;
private:
- virtual void overrun(size_t needed);
+ void overrun(size_t needed) override;
int offset;
uint8_t buf[131072];
@@ -67,15 +67,15 @@ public:
CConn(const char *filename);
~CConn();
- virtual void initDone();
- virtual void setPixelFormat(const rfb::PixelFormat& pf);
- virtual void setCursor(int, int, const rfb::Point&, const uint8_t*);
- virtual void setCursorPos(const rfb::Point&);
- virtual void framebufferUpdateStart();
- virtual void framebufferUpdateEnd();
- virtual void setColourMapEntries(int, int, uint16_t*);
- virtual void bell();
- virtual void serverCutText(const char*);
+ void initDone() override;
+ void setPixelFormat(const rfb::PixelFormat& pf) override;
+ void setCursor(int, int, const rfb::Point&, const uint8_t*) override;
+ void setCursorPos(const rfb::Point&) override;
+ void framebufferUpdateStart() override;
+ void framebufferUpdateEnd() override;
+ void setColourMapEntries(int, int, uint16_t*) override;
+ void bell() override;
+ void serverCutText(const char*) override;
public:
double cpuTime;
@@ -193,7 +193,7 @@ static struct stats runTest(const char *fn)
struct timeval start, stop;
struct stats s;
- gettimeofday(&start, NULL);
+ gettimeofday(&start, nullptr);
try {
cc = new CConn(fn);
@@ -211,7 +211,7 @@ static struct stats runTest(const char *fn)
exit(1);
}
- gettimeofday(&stop, NULL);
+ gettimeofday(&stop, nullptr);
s.decodeTime = cc->cpuTime;
s.realTime = (double)stop.tv_sec - start.tv_sec;
diff --git a/tests/perf/encperf.cxx b/tests/perf/encperf.cxx
index 388dcc95..25dca490 100644
--- a/tests/perf/encperf.cxx
+++ b/tests/perf/encperf.cxx
@@ -80,11 +80,11 @@ class DummyOutStream : public rdr::OutStream {
public:
DummyOutStream();
- virtual size_t length();
- virtual void flush();
+ size_t length() override;
+ void flush() override;
private:
- virtual void overrun(size_t needed);
+ void overrun(size_t needed) override;
int offset;
uint8_t buf[131072];
@@ -98,16 +98,16 @@ public:
void getStats(double& ratio, unsigned long long& bytes,
unsigned long long& rawEquivalent);
- virtual void initDone() {};
- virtual void resizeFramebuffer();
- virtual void setCursor(int, int, const rfb::Point&, const uint8_t*);
- virtual void setCursorPos(const rfb::Point&);
- virtual void framebufferUpdateStart();
- virtual void framebufferUpdateEnd();
- virtual bool dataRect(const rfb::Rect&, int);
- virtual void setColourMapEntries(int, int, uint16_t*);
- virtual void bell();
- virtual void serverCutText(const char*);
+ void initDone() override {};
+ void resizeFramebuffer() override;
+ void setCursor(int, int, const rfb::Point&, const uint8_t*) override;
+ void setCursorPos(const rfb::Point&) override;
+ void framebufferUpdateStart() override;
+ void framebufferUpdateEnd() override;
+ bool dataRect(const rfb::Rect&, int) override;
+ void setColourMapEntries(int, int, uint16_t*) override;
+ void bell() override;
+ void serverCutText(const char*) override;
public:
double decodeTime;
@@ -136,10 +136,10 @@ public:
void getStats(double&, unsigned long long&, unsigned long long&);
- virtual void setAccessRights(rfb::AccessRights ar);
+ void setAccessRights(rfb::AccessRights ar) override;
- virtual void setDesktopSize(int fb_width, int fb_height,
- const rfb::ScreenSet& layout);
+ void setDesktopSize(int fb_width, int fb_height,
+ const rfb::ScreenSet& layout) override;
protected:
DummyOutStream *out;
@@ -279,8 +279,8 @@ void CConn::serverCutText(const char*)
{
}
-Manager::Manager(class rfb::SConnection *conn) :
- EncodeManager(conn)
+Manager::Manager(class rfb::SConnection *conn_) :
+ EncodeManager(conn_)
{
}
@@ -308,7 +308,7 @@ SConn::SConn()
: SConnection(rfb::AccessDefault)
{
out = new DummyOutStream;
- setStreams(NULL, out);
+ setStreams(nullptr, out);
setWriter(new rfb::SMsgWriter(&client, out));
@@ -323,7 +323,7 @@ SConn::~SConn()
void SConn::writeUpdate(const rfb::UpdateInfo& ui, const rfb::PixelBuffer* pb)
{
- manager->writeUpdate(ui, pb, NULL);
+ manager->writeUpdate(ui, pb, nullptr);
}
void SConn::getStats(double& ratio, unsigned long long& bytes,
@@ -357,7 +357,7 @@ static struct stats runTest(const char *fn)
struct stats s;
struct timeval start, stop;
- gettimeofday(&start, NULL);
+ gettimeofday(&start, nullptr);
try {
cc = new CConn(fn);
@@ -375,7 +375,7 @@ static struct stats runTest(const char *fn)
exit(1);
}
- gettimeofday(&stop, NULL);
+ gettimeofday(&stop, nullptr);
s.decodeTime = cc->decodeTime;
s.encodeTime = cc->encodeTime;
@@ -388,13 +388,13 @@ static struct stats runTest(const char *fn)
return s;
}
-static void sort(double *array, int count)
+static void sort(double *array, int len)
{
bool sorted;
int i;
do {
sorted = true;
- for (i = 1; i < count; i++) {
+ for (i = 1; i < len; i++) {
if (array[i-1] > array[i]) {
double d;
d = array[i];
@@ -420,7 +420,7 @@ int main(int argc, char **argv)
const char *fn;
- fn = NULL;
+ fn = nullptr;
for (i = 1; i < argc; i++) {
if (rfb::Configuration::setParam(argv[i]))
continue;
@@ -435,7 +435,7 @@ int main(int argc, char **argv)
usage(argv[0]);
}
- if (fn != NULL)
+ if (fn != nullptr)
usage(argv[0]);
fn = argv[i];
@@ -447,7 +447,7 @@ int main(int argc, char **argv)
double *dev = new double[runCount];
double median, meddev;
- if (fn == NULL) {
+ if (fn == nullptr) {
fprintf(stderr, "No file specified!\n\n");
usage(argv[0]);
}
diff --git a/tests/perf/fbperf.cxx b/tests/perf/fbperf.cxx
index dddf19fb..357aede2 100644
--- a/tests/perf/fbperf.cxx
+++ b/tests/perf/fbperf.cxx
@@ -43,10 +43,10 @@ public:
virtual void start(int width, int height);
virtual void stop();
- virtual void draw();
+ void draw() override;
protected:
- virtual void flush();
+ void flush() override;
void update();
virtual void changefb();
@@ -63,17 +63,17 @@ protected:
class PartialTestWindow: public TestWindow {
protected:
- virtual void changefb();
+ void changefb() override;
};
class OverlayTestWindow: public PartialTestWindow {
public:
OverlayTestWindow();
- virtual void start(int width, int height);
- virtual void stop();
+ void start(int width, int height) override;
+ void stop() override;
- virtual void draw();
+ void draw() override;
protected:
Surface* overlay;
@@ -82,7 +82,7 @@ protected:
TestWindow::TestWindow() :
Fl_Window(0, 0, "Framebuffer Performance Test"),
- fb(NULL)
+ fb(nullptr)
{
}
@@ -116,7 +116,7 @@ void TestWindow::stop()
hide();
delete fb;
- fb = NULL;
+ fb = nullptr;
Fl::remove_idle(timer, this);
}
@@ -208,7 +208,7 @@ void PartialTestWindow::changefb()
}
OverlayTestWindow::OverlayTestWindow() :
- overlay(NULL), offscreen(NULL)
+ overlay(nullptr), offscreen(nullptr)
{
}
@@ -224,7 +224,7 @@ void OverlayTestWindow::start(int width, int height)
#if !defined(__APPLE__)
offscreen = new Surface(w(), h());
#else
- offscreen = NULL;
+ offscreen = nullptr;
#endif
}
@@ -233,9 +233,9 @@ void OverlayTestWindow::stop()
PartialTestWindow::stop();
delete offscreen;
- offscreen = NULL;
+ offscreen = nullptr;
delete overlay;
- overlay = NULL;
+ overlay = nullptr;
}
void OverlayTestWindow::draw()
@@ -299,7 +299,7 @@ static void dosubtest(TestWindow* win, int width, int height,
win->start(width, height);
- gettimeofday(&start, NULL);
+ gettimeofday(&start, nullptr);
while (rfb::msSince(&start) < 3000)
Fl::wait();
diff --git a/tests/perf/util.cxx b/tests/perf/util.cxx
index 98b2568e..2720c237 100644
--- a/tests/perf/util.cxx
+++ b/tests/perf/util.cxx
@@ -65,8 +65,8 @@ cpucounter_t newCpuCounter(void)
syscounter_t *c;
c = (syscounter_t*)malloc(sizeof(syscounter_t) * 2);
- if (c == NULL)
- return NULL;
+ if (c == nullptr)
+ return nullptr;
memset(c, 0, sizeof(syscounter_t) * 2);
@@ -149,7 +149,7 @@ void startTimeCounter(void)
#ifdef WIN32
QueryPerformanceCounter(&timeStart);
#else
- gettimeofday(&timeStart, NULL);
+ gettimeofday(&timeStart, nullptr);
#endif
}
@@ -158,7 +158,7 @@ void endTimeCounter(void)
#ifdef WIN32
QueryPerformanceCounter(&timeEnd);
#else
- gettimeofday(&timeEnd, NULL);
+ gettimeofday(&timeEnd, nullptr);
#endif
}
diff --git a/tests/unit/emulatemb.cxx b/tests/unit/emulatemb.cxx
index 7dfc2541..662eedef 100644
--- a/tests/unit/emulatemb.cxx
+++ b/tests/unit/emulatemb.cxx
@@ -42,7 +42,7 @@ rfb::BoolParameter emulateMiddleButton("dummy_name", "dummy_desc", true);
class TestClass : public EmulateMB
{
public:
- virtual void sendPointerEvent(const rfb::Point& pos, int buttonMask);
+ void sendPointerEvent(const rfb::Point& pos, int buttonMask) override;
struct PointerEventParams {rfb::Point pos; int mask; };
diff --git a/tests/unit/gesturehandler.cxx b/tests/unit/gesturehandler.cxx
index bc39c24c..73b8c62c 100644
--- a/tests/unit/gesturehandler.cxx
+++ b/tests/unit/gesturehandler.cxx
@@ -30,7 +30,7 @@
class TestClass : public GestureHandler
{
protected:
- virtual void handleGestureEvent(const GestureEvent& event);
+ void handleGestureEvent(const GestureEvent& event) override;
public:
std::vector<GestureEvent> events;
diff --git a/tests/unit/pixelformat.cxx b/tests/unit/pixelformat.cxx
index a2ca50d0..614d1255 100644
--- a/tests/unit/pixelformat.cxx
+++ b/tests/unit/pixelformat.cxx
@@ -36,7 +36,7 @@ static void doTest(bool should_fail, int b, int d, bool e, bool t,
try {
pf = new rfb::PixelFormat(b, d, e, t, rm, gm, bm, rs, gs, bs);
- } catch(rfb::Exception &e) {
+ } catch(rfb::Exception&) {
if (should_fail)
printf("OK");
else
diff --git a/tests/unit/unicode.cxx b/tests/unit/unicode.cxx
index cb15e7e1..71815042 100644
--- a/tests/unit/unicode.cxx
+++ b/tests/unit/unicode.cxx
@@ -180,7 +180,7 @@ int main(int /*argc*/, char** /*argv*/)
for (i = 0;i < ARRAY_SIZE(latin1utf8);i++) {
/* Expected failure? */
- if (strchr(latin1utf8[i].latin1, '?') != NULL)
+ if (strchr(latin1utf8[i].latin1, '?') != nullptr)
continue;
out = rfb::latin1ToUTF8(latin1utf8[i].latin1);
@@ -212,7 +212,7 @@ int main(int /*argc*/, char** /*argv*/)
for (i = 0;i < ARRAY_SIZE(utf8utf16);i++) {
/* Expected failure? */
- if (strstr(utf8utf16[i].utf8, "\xef\xbf\xbd") != NULL)
+ if (strstr(utf8utf16[i].utf8, "\xef\xbf\xbd") != nullptr)
continue;
wout = rfb::utf8ToUTF16(utf8utf16[i].utf8);
diff --git a/unix/common/randr.cxx b/unix/common/randr.cxx
index 12c4841f..e4e2d7be 100644
--- a/unix/common/randr.cxx
+++ b/unix/common/randr.cxx
@@ -236,10 +236,14 @@ static unsigned int _setScreenLayout(bool dryrun,
/* Next, reconfigure all known outputs */
for (int i = 0;i < vncRandRGetOutputCount();i++) {
unsigned int output;
+ char *name_;
+ std::string name;
rfb::ScreenSet::const_iterator iter;
output = vncRandRGetOutputId(i);
+ name = name_ = vncRandRGetOutputName(i);
+ free(name_);
/* Known? */
if (outputIdMap->count(output) == 0)
@@ -259,31 +263,24 @@ static unsigned int _setScreenLayout(bool dryrun,
/* Probably not needed, but let's be safe */
if (!vncRandRIsOutputUsable(i)) {
- if (logErrors) {
- char *name = vncRandRGetOutputName(i);
- vlog.error("Required output '%s' cannot be used", name);
- free(name);
- }
+ if (logErrors)
+ vlog.error("Required output '%s' cannot be used", name.c_str());
return rfb::resultInvalid;
}
/* Possible mode? */
if (!vncRandRCheckOutputMode(i, iter->dimensions.width(),
iter->dimensions.height())) {
- if (logErrors) {
- char *name = vncRandRGetOutputName(i);
- vlog.error("Output '%s' does not support required mode %dx%d", name,
+ if (logErrors)
+ vlog.error("Output '%s' does not support required mode %dx%d",
+ name.c_str(),
iter->dimensions.width(), iter->dimensions.height());
- free(name);
- }
return rfb::resultInvalid;
}
- char *name = vncRandRGetOutputName(i);
- vlog.debug("Reconfiguring output '%s' to %dx%d+%d+%d", name,
+ vlog.debug("Reconfiguring output '%s' to %dx%d+%d+%d", name.c_str(),
iter->dimensions.width(), iter->dimensions.height(),
iter->dimensions.tl.x, iter->dimensions.tl.y);
- free(name);
if (dryrun)
continue;
@@ -295,13 +292,11 @@ static unsigned int _setScreenLayout(bool dryrun,
iter->dimensions.width(),
iter->dimensions.height());
if (!ret) {
- if (logErrors) {
- char *name = vncRandRGetOutputName(i);
- vlog.error("Failed to reconfigure output '%s' to %dx%d+%d+%d", name,
+ if (logErrors)
+ vlog.error("Failed to reconfigure output '%s' to %dx%d+%d+%d",
+ name.c_str(),
iter->dimensions.width(), iter->dimensions.height(),
iter->dimensions.tl.x, iter->dimensions.tl.y);
- free(name);
- }
return rfb::resultInvalid;
}
}
@@ -311,6 +306,8 @@ static unsigned int _setScreenLayout(bool dryrun,
for (iter = layout.begin();iter != layout.end();++iter) {
OutputIdMap::const_iterator oi;
unsigned int output;
+ char *name_;
+ std::string name;
int i;
/* Does this screen have an output already? */
@@ -332,6 +329,8 @@ static unsigned int _setScreenLayout(bool dryrun,
return rfb::resultInvalid;
}
output = vncRandRGetOutputId(i);
+ name = name_ = vncRandRGetOutputName(i);
+ free(name_);
/*
* Make sure we already have an entry for this, or
@@ -342,31 +341,24 @@ static unsigned int _setScreenLayout(bool dryrun,
/* Probably not needed, but let's be safe */
if (!vncRandRIsOutputUsable(i)) {
- if (logErrors) {
- char *name = vncRandRGetOutputName(i);
- vlog.error("Required new output '%s' cannot be used", name);
- free(name);
- }
+ if (logErrors)
+ vlog.error("Required new output '%s' cannot be used", name.c_str());
return rfb::resultInvalid;
}
/* Possible mode? */
if (!vncRandRCheckOutputMode(i, iter->dimensions.width(),
iter->dimensions.height())) {
- if (logErrors) {
- char *name = vncRandRGetOutputName(i);
- vlog.error("New output '%s' does not support required mode %dx%d", name,
+ if (logErrors)
+ vlog.error("New output '%s' does not support required mode %dx%d",
+ name.c_str(),
iter->dimensions.width(), iter->dimensions.height());
- free(name);
- }
return rfb::resultInvalid;
}
- char *name = vncRandRGetOutputName(i);
- vlog.debug("Reconfiguring new output '%s' to %dx%d+%d+%d", name,
+ vlog.debug("Reconfiguring new output '%s' to %dx%d+%d+%d", name.c_str(),
iter->dimensions.width(), iter->dimensions.height(),
iter->dimensions.tl.x, iter->dimensions.tl.y);
- free(name);
if (dryrun)
continue;
@@ -378,13 +370,11 @@ static unsigned int _setScreenLayout(bool dryrun,
iter->dimensions.width(),
iter->dimensions.height());
if (!ret) {
- if (logErrors) {
- char *name = vncRandRGetOutputName(i);
- vlog.error("Failed to reconfigure new output '%s' to %dx%d+%d+%d", name,
+ if (logErrors)
+ vlog.error("Failed to reconfigure new output '%s' to %dx%d+%d+%d",
+ name.c_str(),
iter->dimensions.width(), iter->dimensions.height(),
iter->dimensions.tl.x, iter->dimensions.tl.y);
- free(name);
- }
return rfb::resultInvalid;
}
}
diff --git a/unix/tx/TXButton.h b/unix/tx/TXButton.h
index a51f2ecd..88964833 100644
--- a/unix/tx/TXButton.h
+++ b/unix/tx/TXButton.h
@@ -41,14 +41,15 @@ public:
class TXButton : public TXWindow, public TXEventHandler {
public:
- TXButton(Display* dpy_, const char* text_, TXButtonCallback* cb_=0,
- TXWindow* parent_=0, int w=1, int h=1)
+ TXButton(Display* dpy_, const char* text_,
+ TXButtonCallback* cb_=nullptr,
+ TXWindow* parent_=nullptr, int w=1, int h=1)
: TXWindow(dpy_, w, h, parent_), cb(cb_), down(false),
disabled_(false)
{
setEventHandler(this);
setText(text_);
- gc = XCreateGC(dpy, win(), 0, 0);
+ gc = XCreateGC(dpy, win(), 0, nullptr);
XSetFont(dpy, gc, defaultFont);
addEventMask(ExposureMask | ButtonPressMask | ButtonReleaseMask);
}
@@ -91,7 +92,7 @@ private:
XDrawString(dpy, win(), gc, startx, starty, text.data(), text.size());
}
- virtual void handleEvent(TXWindow* /*w*/, XEvent* ev) {
+ void handleEvent(TXWindow* /*w*/, XEvent* ev) override {
switch (ev->type) {
case Expose:
paint();
diff --git a/unix/tx/TXCheckbox.h b/unix/tx/TXCheckbox.h
index 76cdc950..179e3e84 100644
--- a/unix/tx/TXCheckbox.h
+++ b/unix/tx/TXCheckbox.h
@@ -48,14 +48,15 @@ public:
class TXCheckbox : public TXWindow, public TXEventHandler {
public:
TXCheckbox(Display* dpy_, const char* text_, TXCheckboxCallback* cb_,
- bool radio_=false, TXWindow* parent_=0, int w=1, int h=1)
- : TXWindow(dpy_, w, h, parent_), cb(cb_), text(0),
+ bool radio_=false, TXWindow* parent_=nullptr,
+ int w=1, int h=1)
+ : TXWindow(dpy_, w, h, parent_), cb(cb_), text(nullptr),
boxSize(radio_ ? 12 : 13), boxPad(4),
checked_(false), disabled_(false), radio(radio_)
{
setEventHandler(this);
setText(text_);
- gc = XCreateGC(dpy, win(), 0, 0);
+ gc = XCreateGC(dpy, win(), 0, nullptr);
XSetFont(dpy, gc, defaultFont);
addEventMask(ExposureMask| ButtonPressMask | ButtonReleaseMask);
}
@@ -109,7 +110,7 @@ private:
text, strlen(text));
}
- virtual void handleEvent(TXWindow* /*w*/, XEvent* ev) {
+ void handleEvent(TXWindow* /*w*/, XEvent* ev) override {
switch (ev->type) {
case Expose:
paint();
diff --git a/unix/tx/TXDialog.h b/unix/tx/TXDialog.h
index 861a20be..720c50d0 100644
--- a/unix/tx/TXDialog.h
+++ b/unix/tx/TXDialog.h
@@ -33,9 +33,9 @@
class TXDialog : public TXWindow, public TXDeleteWindowCallback {
public:
- TXDialog(Display* dpy, int width, int height, const char* name,
+ TXDialog(Display* dpy_, int width, int height, const char* name,
bool modal_=false)
- : TXWindow(dpy, width, height), done(false), ok(false), modal(modal_)
+ : TXWindow(dpy_, width, height), done(false), ok(false), modal(modal_)
{
toplevel(name, this);
resize(width, height);
@@ -62,7 +62,7 @@ public:
fd_set rfds;
FD_ZERO(&rfds);
FD_SET(ConnectionNumber(dpy), &rfds);
- int n = select(FD_SETSIZE, &rfds, 0, 0, 0);
+ int n = select(FD_SETSIZE, &rfds, nullptr, nullptr, nullptr);
if (n < 0) throw rdr::SystemException("select",errno);
}
}
@@ -82,7 +82,7 @@ public:
}
protected:
- virtual void deleteWindow(TXWindow* /*w*/) {
+ void deleteWindow(TXWindow* /*w*/) override {
ok = false;
done = true;
unmap();
diff --git a/unix/tx/TXLabel.h b/unix/tx/TXLabel.h
index 24b8cbb3..1e0cc0e5 100644
--- a/unix/tx/TXLabel.h
+++ b/unix/tx/TXLabel.h
@@ -35,7 +35,7 @@ public:
enum HAlign { left, centre, right };
enum VAlign { top, middle, bottom };
- TXLabel(Display* dpy_, const char* text_, TXWindow* parent_=0,
+ TXLabel(Display* dpy_, const char* text_, TXWindow* parent_=nullptr,
int w=1, int h=1, HAlign ha=centre, VAlign va=middle)
: TXWindow(dpy_, w, h, parent_), lineSpacing(2), lines(0),
halign(ha), valign(va)
@@ -108,7 +108,7 @@ private:
} while (i < text.size());
}
- virtual void handleEvent(TXWindow* /*w*/, XEvent* ev) {
+ void handleEvent(TXWindow* /*w*/, XEvent* ev) override {
switch (ev->type) {
case Expose:
paint();
diff --git a/unix/tx/TXWindow.cxx b/unix/tx/TXWindow.cxx
index ee097e45..343b9c28 100644
--- a/unix/tx/TXWindow.cxx
+++ b/unix/tx/TXWindow.cxx
@@ -44,15 +44,15 @@ unsigned long TXWindow::disabledFg, TXWindow::disabledBg;
unsigned long TXWindow::enabledBg;
unsigned long TXWindow::scrollbarBg;
Colormap TXWindow::cmap = 0;
-GC TXWindow::defaultGC = 0;
+GC TXWindow::defaultGC = nullptr;
Font TXWindow::defaultFont = 0;
-XFontStruct* TXWindow::defaultFS = 0;
+XFontStruct* TXWindow::defaultFS = nullptr;
Time TXWindow::cutBufferTime = 0;
Pixmap TXWindow::dot = 0, TXWindow::tick = 0;
const int TXWindow::dotSize = 4, TXWindow::tickSize = 8;
char* TXWindow::defaultWindowClass;
-TXGlobalEventHandler* TXWindow::globalEventHandler = NULL;
+TXGlobalEventHandler* TXWindow::globalEventHandler = nullptr;
void TXWindow::init(Display* dpy, const char* defaultWindowClass_)
{
@@ -79,7 +79,7 @@ void TXWindow::init(Display* dpy, const char* defaultWindowClass_)
darkBg = disabledFg = cols[3].pixel;
scrollbarBg = cols[4].pixel;
white = enabledBg = cols[5].pixel;
- defaultGC = XCreateGC(dpy, DefaultRootWindow(dpy), 0, 0);
+ defaultGC = XCreateGC(dpy, DefaultRootWindow(dpy), 0, nullptr);
defaultFS
= XLoadQueryFont(dpy, "-*-helvetica-medium-r-*-*-12-*-*-*-*-*-*-*");
if (!defaultFS) {
@@ -258,7 +258,8 @@ Window TXWindow::windowWithName(Display* dpy, Window top, const char* name)
TXWindow::TXWindow(Display* dpy_, int w, int h, TXWindow* parent_,
int borderWidth)
: dpy(dpy_), xPad(3), yPad(3), bevel(2), parent(parent_), width_(w),
- height_(h), eventHandler(0), dwc(0), eventMask(0), toplevel_(false)
+ height_(h), eventHandler(nullptr), dwc(nullptr), eventMask(0),
+ toplevel_(false)
{
sizeHints.flags = 0;
XSetWindowAttributes attr;
@@ -266,7 +267,8 @@ TXWindow::TXWindow(Display* dpy_, int w, int h, TXWindow* parent_,
attr.border_pixel = 0;
Window par = parent ? parent->win() : DefaultRootWindow(dpy);
win_ = XCreateWindow(dpy, par, 0, 0, width_, height_, borderWidth,
- CopyFromParent, CopyFromParent, CopyFromParent,
+ CopyFromParent, CopyFromParent,
+ (Visual*)CopyFromParent,
CWBackPixel | CWBorderPixel, &attr);
if (parent) map();
@@ -292,7 +294,7 @@ void TXWindow::toplevel(const char* name, TXDeleteWindowCallback* dwc_,
if (!windowClass) windowClass = defaultWindowClass;
classHint.res_name = (char*)name;
classHint.res_class = (char*)windowClass;
- XSetWMProperties(dpy, win(), 0, 0, argv, argc,
+ XSetWMProperties(dpy, win(), nullptr, nullptr, argv, argc,
&sizeHints, &wmHints, &classHint);
XStoreName(dpy, win(), name);
XSetIconName(dpy, win(), name);
@@ -443,7 +445,7 @@ void TXWindow::handleXEvent(XEvent* ev)
break;
}
}
- selectionNotify(&ev->xselection, 0, 0, 0, 0);
+ selectionNotify(&ev->xselection, 0, 0, 0, nullptr);
break;
case SelectionRequest:
diff --git a/unix/tx/TXWindow.h b/unix/tx/TXWindow.h
index 223c07a8..9f2a30cb 100644
--- a/unix/tx/TXWindow.h
+++ b/unix/tx/TXWindow.h
@@ -65,7 +65,8 @@ public:
// background (currently grey). It is mapped by default if it has a parent.
// If no parent is specified its parent is the root window and it will remain
// unmapped.
- TXWindow(Display* dpy_, int width=1, int height=1, TXWindow* parent_=0,
+ TXWindow(Display* dpy_, int width=1, int height=1,
+ TXWindow* parent_=nullptr,
int borderWidth=0);
virtual ~TXWindow();
@@ -73,8 +74,9 @@ public:
// window-manager-related properties are set on the window. The given
// TXDeleteWindowCallback is notified when the window is "deleted" (cloesd)
// by the user.
- void toplevel(const char* name, TXDeleteWindowCallback* dwc=0,
- int argc=0, char** argv=0, const char* windowClass=0,
+ void toplevel(const char* name, TXDeleteWindowCallback* dwc=nullptr,
+ int argc=0, char** argv=nullptr,
+ const char* windowClass=nullptr,
bool iconic=false);
// setMaxSize() tells the window manager the maximum size to allow a
@@ -181,7 +183,7 @@ public:
// strEmptyToNull() returns the string it's given but turns an empty string
// into null, which can be useful for passing rfb parameters to Xlib calls.
- static char* strEmptyToNull(char* s) { return s && s[0] ? s : 0; }
+ static char* strEmptyToNull(char* s) { return s && s[0] ? s : nullptr; }
// The following are default values for various things.
static unsigned long black, white;
diff --git a/unix/vncconfig/QueryConnectDialog.cxx b/unix/vncconfig/QueryConnectDialog.cxx
index e725de7d..aa1b78ad 100644
--- a/unix/vncconfig/QueryConnectDialog.cxx
+++ b/unix/vncconfig/QueryConnectDialog.cxx
@@ -25,12 +25,12 @@
#include "QueryConnectDialog.h"
#include "vncExt.h"
-QueryConnectDialog::QueryConnectDialog(Display* dpy,
+QueryConnectDialog::QueryConnectDialog(Display* dpy_,
const char* address_,
const char* user_,
int timeout_,
QueryResultCallback* cb)
- : TXDialog(dpy, 300, 100, "VNC Server : Accept Connection?"),
+ : TXDialog(dpy_, 300, 100, "VNC Server : Accept Connection?"),
addressLbl(dpy, "Host:",this),
address(dpy, address_, this),
userLbl(dpy, "User:", this),
diff --git a/unix/vncconfig/QueryConnectDialog.h b/unix/vncconfig/QueryConnectDialog.h
index dcf64e40..5763e1ce 100644
--- a/unix/vncconfig/QueryConnectDialog.h
+++ b/unix/vncconfig/QueryConnectDialog.h
@@ -40,10 +40,10 @@ class QueryConnectDialog : public TXDialog, public TXEventHandler,
QueryConnectDialog(Display* dpy, const char* address_,
const char* user_, int timeout_,
QueryResultCallback* cb);
- void handleEvent(TXWindow*, XEvent* ) { }
- void deleteWindow(TXWindow*);
- void buttonActivate(TXButton* b);
- void handleTimeout(rfb::Timer* t);
+ void handleEvent(TXWindow*, XEvent* ) override { }
+ void deleteWindow(TXWindow*) override;
+ void buttonActivate(TXButton* b) override;
+ void handleTimeout(rfb::Timer* t) override;
private:
void refreshTimeout();
TXLabel addressLbl, address, userLbl, user, timeoutLbl, timeout;
diff --git a/unix/vncconfig/vncconfig.cxx b/unix/vncconfig/vncconfig.cxx
index 30d04ca6..ab7c6315 100644
--- a/unix/vncconfig/vncconfig.cxx
+++ b/unix/vncconfig/vncconfig.cxx
@@ -62,14 +62,14 @@ BoolParameter iconic("iconic", "Start with window iconified", 0);
#define SET_PRIMARY "SetPrimary"
#define SEND_PRIMARY "SendPrimary"
-char* programName = 0;
+char* programName = nullptr;
Display* dpy;
int vncExtEventBase, vncExtErrorBase;
-static bool getBoolParam(Display* dpy, const char* param) {
+static bool getBoolParam(Display* dpy_, const char* param) {
char* data;
int len;
- if (XVncExtGetParam(dpy, param, &data, &len)) {
+ if (XVncExtGetParam(dpy_, param, &data, &len)) {
if (strcmp(data,"1") == 0) return true;
}
return false;
@@ -80,13 +80,13 @@ class VncConfigWindow : public TXWindow, public TXEventHandler,
public TXCheckboxCallback,
public QueryResultCallback {
public:
- VncConfigWindow(Display* dpy)
- : TXWindow(dpy, 300, 100),
- acceptClipboard(dpy, "Accept clipboard from viewers", this, false, this),
- setPrimaryCB(dpy, "Also set primary selection", this, false, this),
- sendClipboard(dpy, "Send clipboard to viewers", this, false, this),
- sendPrimaryCB(dpy, "Send primary selection to viewers", this,false,this),
- queryConnectDialog(0)
+ VncConfigWindow(Display* dpy_)
+ : TXWindow(dpy_, 300, 100),
+ acceptClipboard(dpy_, "Accept clipboard from viewers", this, false, this),
+ setPrimaryCB(dpy_, "Also set primary selection", this, false, this),
+ sendClipboard(dpy_, "Send clipboard to viewers", this, false, this),
+ sendPrimaryCB(dpy_, "Send primary selection to viewers", this,false,this),
+ queryConnectDialog(nullptr)
{
int y = yPad;
acceptClipboard.move(xPad, y);
@@ -104,18 +104,18 @@ public:
sendPrimaryCB.disabled(!sendClipboard.checked());
y += sendPrimaryCB.height();
setEventHandler(this);
- toplevel("VNC config", this, 0, 0, 0, iconic);
+ toplevel("VNC config", this, 0, nullptr, nullptr, iconic);
XVncExtSelectInput(dpy, win(), VncExtQueryConnectMask);
}
// handleEvent()
- virtual void handleEvent(TXWindow* /*w*/, XEvent* ev) {
+ void handleEvent(TXWindow* /*w*/, XEvent* ev) override {
if (ev->type == vncExtEventBase + VncExtQueryConnectNotify) {
vlog.debug("query connection event");
if (queryConnectDialog)
delete queryConnectDialog;
- queryConnectDialog = 0;
+ queryConnectDialog = nullptr;
char* qcAddress;
char* qcUser;
int qcTimeout;
@@ -134,12 +134,12 @@ public:
}
// TXDeleteWindowCallback method
- virtual void deleteWindow(TXWindow* /*w*/) {
+ void deleteWindow(TXWindow* /*w*/) override {
exit(1);
}
// TXCheckboxCallback method
- virtual void checkboxSelect(TXCheckbox* checkbox) {
+ void checkboxSelect(TXCheckbox* checkbox) override {
if (checkbox == &acceptClipboard) {
XVncExtSetParam(dpy, (acceptClipboard.checked()
? ACCEPT_CUT_TEXT "=1" : ACCEPT_CUT_TEXT "=0"));
@@ -158,10 +158,10 @@ public:
}
// QueryResultCallback interface
- virtual void queryApproved() {
+ void queryApproved() override {
XVncExtApproveConnect(dpy, queryConnectId, 1);
}
- virtual void queryRejected() {
+ void queryRejected() override {
XVncExtApproveConnect(dpy, queryConnectId, 0);
}
@@ -278,8 +278,8 @@ int main(int argc, char** argv)
} else if (strcmp(argv[i], "-list") == 0) {
int nParams;
char** list = XVncExtListParams(dpy, &nParams);
- for (int i = 0; i < nParams; i++) {
- printf("%s\n",list[i]);
+ for (int n = 0; n < nParams; n++) {
+ printf("%s\n",list[n]);
}
XVncExtFreeParamList(list);
} else if (strcmp(argv[i], "-set") == 0) {
@@ -306,7 +306,7 @@ int main(int argc, char** argv)
while (true) {
struct timeval tv;
- struct timeval* tvp = 0;
+ struct timeval* tvp = nullptr;
// Process any incoming X events
TXWindow::handleXEvents(dpy);
@@ -329,7 +329,7 @@ int main(int argc, char** argv)
fd_set rfds;
FD_ZERO(&rfds);
FD_SET(ConnectionNumber(dpy), &rfds);
- int n = select(FD_SETSIZE, &rfds, 0, 0, tvp);
+ int n = select(FD_SETSIZE, &rfds, nullptr, nullptr, tvp);
if (n < 0) throw rdr::SystemException("select",errno);
}
diff --git a/unix/vncpasswd/vncpasswd.cxx b/unix/vncpasswd/vncpasswd.cxx
index 30091a3d..877ebcbd 100644
--- a/unix/vncpasswd/vncpasswd.cxx
+++ b/unix/vncpasswd/vncpasswd.cxx
@@ -72,7 +72,7 @@ static const char* getpassword(const char* prompt) {
result[strlen(result)-1] = 0;
return buf;
}
- return 0;
+ return nullptr;
}
// Reads passwords from stdin and prints encrypted passwords to stdout.
@@ -81,7 +81,7 @@ static int encrypt_pipe() {
// We support a maximum of two passwords right now
for (i = 0;i < 2;i++) {
- const char *result = getpassword(NULL);
+ const char *result = getpassword(nullptr);
if (!result)
break;
@@ -102,7 +102,7 @@ static int encrypt_pipe() {
static std::vector<uint8_t> readpassword() {
while (true) {
const char *passwd = getpassword("Password:");
- if (passwd == NULL) {
+ if (passwd == nullptr) {
perror("getpassword error");
exit(1);
}
@@ -117,7 +117,7 @@ static std::vector<uint8_t> readpassword() {
}
passwd = getpassword("Verify:");
- if (passwd == NULL) {
+ if (passwd == nullptr) {
perror("getpass error");
exit(1);
}
@@ -158,7 +158,7 @@ int main(int argc, char** argv)
if (fname[0] == '\0') {
const char *configDir = os::getvncconfigdir();
- if (configDir == NULL) {
+ if (configDir == nullptr) {
fprintf(stderr, "Can't obtain VNC config directory\n");
exit(1);
}
@@ -175,7 +175,7 @@ int main(int argc, char** argv)
fprintf(stderr, "Would you like to enter a view-only password (y/n)? ");
char yesno[3];
- if (fgets(yesno, 3, stdin) != NULL && (yesno[0] == 'y' || yesno[0] == 'Y')) {
+ if (fgets(yesno, 3, stdin) != nullptr && (yesno[0] == 'y' || yesno[0] == 'Y')) {
obfuscatedReadOnly = readpassword();
} else {
fprintf(stderr, "A view-only password is not used\n");
diff --git a/unix/x0vncserver/Geometry.cxx b/unix/x0vncserver/Geometry.cxx
index 3f7f2863..28e71be4 100644
--- a/unix/x0vncserver/Geometry.cxx
+++ b/unix/x0vncserver/Geometry.cxx
@@ -71,7 +71,7 @@ Rect Geometry::parseString(const char *arg) const
{
Rect result; // empty by default
- if (arg != NULL && strlen(arg) > 0) {
+ if (arg != nullptr && strlen(arg) > 0) {
int w, h;
int x = 0, y = 0;
char sign_x[2] = "+";
diff --git a/unix/x0vncserver/Image.cxx b/unix/x0vncserver/Image.cxx
index 755da787..c2026134 100644
--- a/unix/x0vncserver/Image.cxx
+++ b/unix/x0vncserver/Image.cxx
@@ -63,13 +63,13 @@ ImageCleanup imageCleanup;
static rfb::LogWriter vlog("Image");
Image::Image(Display *d)
- : xim(NULL), dpy(d)
+ : xim(nullptr), dpy(d)
{
imageCleanup.images.push_back(this);
}
Image::Image(Display *d, int width, int height)
- : xim(NULL), dpy(d)
+ : xim(nullptr), dpy(d)
{
imageCleanup.images.push_back(this);
Init(width, height);
@@ -85,10 +85,11 @@ void Image::Init(int width, int height)
}
xim = XCreateImage(dpy, vis, DefaultDepth(dpy, DefaultScreen(dpy)),
- ZPixmap, 0, 0, width, height, BitmapPad(dpy), 0);
+ ZPixmap, 0, nullptr, width, height,
+ BitmapPad(dpy), 0);
xim->data = (char *)malloc(xim->bytes_per_line * xim->height);
- if (xim->data == NULL) {
+ if (xim->data == nullptr) {
vlog.error("malloc() failed");
exit(1);
}
@@ -99,7 +100,7 @@ Image::~Image()
imageCleanup.images.remove(this);
// XDestroyImage will free xim->data if necessary
- if (xim != NULL)
+ if (xim != nullptr)
XDestroyImage(xim);
}
@@ -217,12 +218,12 @@ static int ShmCreationXErrorHandler(Display* /*dpy*/,
}
ShmImage::ShmImage(Display *d)
- : Image(d), shminfo(NULL)
+ : Image(d), shminfo(nullptr)
{
}
ShmImage::ShmImage(Display *d, int width, int height)
- : Image(d), shminfo(NULL)
+ : Image(d), shminfo(nullptr)
{
Init(width, height);
}
@@ -241,7 +242,7 @@ void ShmImage::Init(int width, int height, const XVisualInfo *vinfo)
Visual *visual;
int depth;
- if (vinfo == NULL) {
+ if (vinfo == nullptr) {
visual = DefaultVisual(dpy, DefaultScreen(dpy));
depth = DefaultDepth(dpy, DefaultScreen(dpy));
} else {
@@ -256,12 +257,12 @@ void ShmImage::Init(int width, int height, const XVisualInfo *vinfo)
shminfo = new XShmSegmentInfo;
- xim = XShmCreateImage(dpy, visual, depth, ZPixmap, 0, shminfo,
+ xim = XShmCreateImage(dpy, visual, depth, ZPixmap, nullptr, shminfo,
width, height);
- if (xim == NULL) {
+ if (xim == nullptr) {
vlog.error("XShmCreateImage() failed");
delete shminfo;
- shminfo = NULL;
+ shminfo = nullptr;
return;
}
@@ -273,22 +274,22 @@ void ShmImage::Init(int width, int height, const XVisualInfo *vinfo)
vlog.error("shmget() failed (%d bytes requested)",
int(xim->bytes_per_line * xim->height));
XDestroyImage(xim);
- xim = NULL;
+ xim = nullptr;
delete shminfo;
- shminfo = NULL;
+ shminfo = nullptr;
return;
}
- shminfo->shmaddr = xim->data = (char *)shmat(shminfo->shmid, 0, 0);
+ shminfo->shmaddr = xim->data = (char *)shmat(shminfo->shmid, nullptr, 0);
if (shminfo->shmaddr == (char *)-1) {
perror("shmat");
vlog.error("shmat() failed (%d bytes requested)",
int(xim->bytes_per_line * xim->height));
- shmctl(shminfo->shmid, IPC_RMID, 0);
+ shmctl(shminfo->shmid, IPC_RMID, nullptr);
XDestroyImage(xim);
- xim = NULL;
+ xim = nullptr;
delete shminfo;
- shminfo = NULL;
+ shminfo = nullptr;
return;
}
@@ -301,21 +302,21 @@ void ShmImage::Init(int width, int height, const XVisualInfo *vinfo)
if (caughtShmError) {
vlog.error("XShmAttach() failed");
shmdt(shminfo->shmaddr);
- shmctl(shminfo->shmid, IPC_RMID, 0);
+ shmctl(shminfo->shmid, IPC_RMID, nullptr);
XDestroyImage(xim);
- xim = NULL;
+ xim = nullptr;
delete shminfo;
- shminfo = NULL;
+ shminfo = nullptr;
return;
}
}
ShmImage::~ShmImage()
{
- if (shminfo != NULL) {
+ if (shminfo != nullptr) {
XShmDetach(dpy, shminfo);
shmdt(shminfo->shmaddr);
- shmctl(shminfo->shmid, IPC_RMID, 0);
+ shmctl(shminfo->shmid, IPC_RMID, nullptr);
delete shminfo;
}
}
@@ -354,13 +355,13 @@ ImageFactory::~ImageFactory()
Image *ImageFactory::newImage(Display *d, int width, int height)
{
- Image *image = NULL;
+ Image *image = nullptr;
// Now, try to use shared memory image.
if (mayUseShm) {
image = new ShmImage(d, width, height);
- if (image->xim != NULL) {
+ if (image->xim != nullptr) {
return image;
}
diff --git a/unix/x0vncserver/Image.h b/unix/x0vncserver/Image.h
index bf62e7d0..a89a26ad 100644
--- a/unix/x0vncserver/Image.h
+++ b/unix/x0vncserver/Image.h
@@ -98,20 +98,20 @@ public:
ShmImage(Display *d, int width, int height);
virtual ~ShmImage();
- virtual const char *className() const {
+ const char *className() const override {
return "ShmImage";
}
- virtual const char *classDesc() const {
+ const char *classDesc() const override {
return "shared memory image";
}
- virtual void get(Window wnd, int x = 0, int y = 0);
- virtual void get(Window wnd, int x, int y, int w, int h,
- int dst_x = 0, int dst_y = 0);
+ void get(Window wnd, int x = 0, int y = 0) override;
+ void get(Window wnd, int x, int y, int w, int h,
+ int dst_x = 0, int dst_y = 0) override;
protected:
- void Init(int width, int height, const XVisualInfo *vinfo = NULL);
+ void Init(int width, int height, const XVisualInfo *vinfo = nullptr);
XShmSegmentInfo *shminfo;
diff --git a/unix/x0vncserver/XDesktop.cxx b/unix/x0vncserver/XDesktop.cxx
index 55ea9667..4286c541 100644
--- a/unix/x0vncserver/XDesktop.cxx
+++ b/unix/x0vncserver/XDesktop.cxx
@@ -26,6 +26,8 @@
#include <signal.h>
#include <unistd.h>
+#include <algorithm>
+
#include <network/Socket.h>
#include <rfb/LogWriter.h>
@@ -80,11 +82,11 @@ static const char * ledNames[XDESKTOP_N_LEDS] = {
};
XDesktop::XDesktop(Display* dpy_, Geometry *geometry_)
- : dpy(dpy_), geometry(geometry_), pb(0), server(0),
- queryConnectDialog(0), queryConnectSock(0),
+ : dpy(dpy_), geometry(geometry_), pb(nullptr), server(nullptr),
+ queryConnectDialog(nullptr), queryConnectSock(nullptr),
oldButtonMask(0), haveXtest(false), haveDamage(false),
maxButtons(0), running(false), ledMasks(), ledState(0),
- codeMap(0), codeMapLen(0)
+ codeMap(nullptr), codeMapLen(0)
{
int major, minor;
@@ -108,7 +110,7 @@ XDesktop::XDesktop(Display* dpy_, Geometry *geometry_)
Bool on;
a = XInternAtom(dpy, ledNames[i], True);
- if (!a || !XkbGetNamedIndicator(dpy, a, &shift, &on, NULL, NULL))
+ if (!a || !XkbGetNamedIndicator(dpy, a, &shift, &on, nullptr, nullptr))
continue;
ledMasks[i] = 1u << shift;
@@ -283,7 +285,7 @@ void XDesktop::stop() {
#ifdef HAVE_XTEST
// Delete added keycodes
- deleteAddedKeysyms(dpy);
+ deleteAddedKeysyms();
#endif
#ifdef HAVE_XDAMAGE
@@ -292,12 +294,12 @@ void XDesktop::stop() {
#endif
delete queryConnectDialog;
- queryConnectDialog = 0;
+ queryConnectDialog = nullptr;
- server->setPixelBuffer(0);
+ server->setPixelBuffer(nullptr);
delete pb;
- pb = 0;
+ pb = nullptr;
}
void XDesktop::terminate() {
@@ -316,15 +318,13 @@ void XDesktop::queryConnection(network::Socket* sock,
// Someone already querying?
if (queryConnectSock) {
std::list<network::Socket*> sockets;
- std::list<network::Socket*>::iterator i;
// Check if this socket is still valid
server->getSockets(&sockets);
- for (i = sockets.begin(); i != sockets.end(); i++) {
- if (*i == queryConnectSock) {
- server->approveConnection(sock, false, "Another connection is currently being queried.");
- return;
- }
+ if (std::find(sockets.begin(), sockets.end(),
+ queryConnectSock) != sockets.end()) {
+ server->approveConnection(sock, false, "Another connection is currently being queried.");
+ return;
}
}
@@ -368,7 +368,7 @@ void XDesktop::pointerEvent(const Point& pos, int buttonMask) {
}
#ifdef HAVE_XTEST
-KeyCode XDesktop::XkbKeysymToKeycode(Display* dpy, KeySym keysym) {
+KeyCode XDesktop::XkbKeysymToKeycode(KeySym keysym) {
XkbDescPtr xkb;
XkbStateRec state;
unsigned int mods;
@@ -401,12 +401,12 @@ KeyCode XDesktop::XkbKeysymToKeycode(Display* dpy, KeySym keysym) {
// Shift+Tab is usually ISO_Left_Tab, but RFB hides this fact. Do
// another attempt if we failed the initial lookup
if ((keycode == 0) && (keysym == XK_Tab) && (mods & ShiftMask))
- return XkbKeysymToKeycode(dpy, XK_ISO_Left_Tab);
+ return XkbKeysymToKeycode(XK_ISO_Left_Tab);
return keycode;
}
-KeyCode XDesktop::addKeysym(Display* dpy, KeySym keysym)
+KeyCode XDesktop::addKeysym(KeySym keysym)
{
int types[1];
unsigned int key;
@@ -460,7 +460,7 @@ KeyCode XDesktop::addKeysym(Display* dpy, KeySym keysym)
return 0;
}
-void XDesktop::deleteAddedKeysyms(Display* dpy) {
+void XDesktop::deleteAddedKeysyms() {
XkbDescPtr xkb;
xkb = XkbGetMap(dpy, XkbAllComponentsMask, XkbUseCoreKbd);
@@ -476,10 +476,10 @@ void XDesktop::deleteAddedKeysyms(Display* dpy) {
for (it = addedKeysyms.begin(); it != addedKeysyms.end(); it++) {
if (XkbKeyNumGroups(xkb, it->second) != 0) {
// Check if we are removing keysym we added ourself
- if (XkbKeysymToKeycode(dpy, it->first) != it->second)
+ if (XkbKeysymToKeycode(it->first) != it->second)
continue;
- XkbChangeTypesOfKey(xkb, it->second, 0, XkbGroup1Mask, NULL, &changes);
+ XkbChangeTypesOfKey(xkb, it->second, 0, XkbGroup1Mask, nullptr, &changes);
if (it->second < lowestKeyCode)
lowestKeyCode = it->second;
@@ -501,19 +501,19 @@ void XDesktop::deleteAddedKeysyms(Display* dpy) {
addedKeysyms.clear();
}
-KeyCode XDesktop::keysymToKeycode(Display* dpy, KeySym keysym) {
+KeyCode XDesktop::keysymToKeycode(KeySym keysym) {
int keycode = 0;
// XKeysymToKeycode() doesn't respect state, so we have to use
// something slightly more complex
- keycode = XkbKeysymToKeycode(dpy, keysym);
+ keycode = XkbKeysymToKeycode(keysym);
if (keycode != 0)
return keycode;
// TODO: try to further guess keycode with all possible mods as Xvnc does
- keycode = addKeysym(dpy, keysym);
+ keycode = addKeysym(keysym);
if (keycode == 0)
vlog.error("Failure adding new keysym 0x%lx", keysym);
@@ -538,7 +538,7 @@ void XDesktop::keyEvent(uint32_t keysym, uint32_t xtcode, bool down) {
if (pressedKeys.find(keysym) != pressedKeys.end())
keycode = pressedKeys[keysym];
else {
- keycode = keysymToKeycode(dpy, keysym);
+ keycode = keysymToKeycode(keysym);
}
}
@@ -931,7 +931,7 @@ bool XDesktop::handleGlobalEvent(XEvent* ev) {
if (cev->window == cev->root)
return false;
- server->setCursor(0, 0, Point(), NULL);
+ server->setCursor(0, 0, Point(), nullptr);
return true;
#endif
}
@@ -942,8 +942,8 @@ bool XDesktop::handleGlobalEvent(XEvent* ev) {
void XDesktop::queryApproved()
{
assert(isRunning());
- server->approveConnection(queryConnectSock, true, 0);
- queryConnectSock = 0;
+ server->approveConnection(queryConnectSock, true, nullptr);
+ queryConnectSock = nullptr;
}
void XDesktop::queryRejected()
@@ -951,7 +951,7 @@ void XDesktop::queryRejected()
assert(isRunning());
server->approveConnection(queryConnectSock, false,
"Connection rejected by local user");
- queryConnectSock = 0;
+ queryConnectSock = nullptr;
}
#ifdef HAVE_XFIXES
@@ -960,7 +960,7 @@ bool XDesktop::setCursor()
XFixesCursorImage *cim;
cim = XFixesGetCursorImage(dpy);
- if (cim == NULL)
+ if (cim == nullptr)
return false;
// Copied from XserverDesktop::setCursor() in
diff --git a/unix/x0vncserver/XDesktop.h b/unix/x0vncserver/XDesktop.h
index fc230e5b..125ddeb0 100644
--- a/unix/x0vncserver/XDesktop.h
+++ b/unix/x0vncserver/XDesktop.h
@@ -47,25 +47,25 @@ public:
virtual ~XDesktop();
void poll();
// -=- SDesktop interface
- virtual void init(rfb::VNCServer* vs);
- virtual void start();
- virtual void stop();
- virtual void terminate();
+ void init(rfb::VNCServer* vs) override;
+ void start() override;
+ void stop() override;
+ void terminate() override;
bool isRunning();
- virtual void queryConnection(network::Socket* sock,
- const char* userName);
- virtual void pointerEvent(const rfb::Point& pos, int buttonMask);
- virtual void keyEvent(uint32_t keysym, uint32_t xtcode, bool down);
- virtual void clientCutText(const char* str);
- virtual unsigned int setScreenLayout(int fb_width, int fb_height,
- const rfb::ScreenSet& layout);
+ void queryConnection(network::Socket* sock,
+ const char* userName) override;
+ void pointerEvent(const rfb::Point& pos, int buttonMask) override;
+ void keyEvent(uint32_t keysym, uint32_t xtcode, bool down) override;
+ void clientCutText(const char* str) override;
+ unsigned int setScreenLayout(int fb_width, int fb_height,
+ const rfb::ScreenSet& layout) override;
// -=- TXGlobalEventHandler interface
- virtual bool handleGlobalEvent(XEvent* ev);
+ bool handleGlobalEvent(XEvent* ev) override;
// -=- QueryResultCallback interface
- virtual void queryApproved();
- virtual void queryRejected();
+ void queryApproved() override;
+ void queryRejected() override;
protected:
Display* dpy;
@@ -101,10 +101,10 @@ protected:
protected:
#ifdef HAVE_XTEST
- KeyCode XkbKeysymToKeycode(Display* dpy, KeySym keysym);
- KeyCode addKeysym(Display* dpy, KeySym keysym);
- void deleteAddedKeysyms(Display* dpy);
- KeyCode keysymToKeycode(Display* dpy, KeySym keysym);
+ KeyCode XkbKeysymToKeycode(KeySym keysym);
+ KeyCode addKeysym(KeySym keysym);
+ void deleteAddedKeysyms();
+ KeyCode keysymToKeycode(KeySym keysym);
#endif
#ifdef HAVE_XFIXES
bool setCursor();
diff --git a/unix/x0vncserver/XPixelBuffer.cxx b/unix/x0vncserver/XPixelBuffer.cxx
index b7506513..0e24cc51 100644
--- a/unix/x0vncserver/XPixelBuffer.cxx
+++ b/unix/x0vncserver/XPixelBuffer.cxx
@@ -35,7 +35,7 @@ using namespace rfb;
XPixelBuffer::XPixelBuffer(Display *dpy, ImageFactory &factory,
const Rect &rect)
: FullFramePixelBuffer(),
- m_poller(0),
+ m_poller(nullptr),
m_dpy(dpy),
m_image(factory.newImage(dpy, rect.width(), rect.height())),
m_offsetLeft(rect.tl.x),
diff --git a/unix/x0vncserver/XPixelBuffer.h b/unix/x0vncserver/XPixelBuffer.h
index 18c85fe2..7556e6ef 100644
--- a/unix/x0vncserver/XPixelBuffer.h
+++ b/unix/x0vncserver/XPixelBuffer.h
@@ -45,7 +45,7 @@ public:
inline void poll(rfb::VNCServer *server) { m_poller->poll(server); }
// Override PixelBuffer::grabRegion().
- virtual void grabRegion(const rfb::Region& region);
+ void grabRegion(const rfb::Region& region) override;
protected:
PollingManager *m_poller;
diff --git a/unix/x0vncserver/x0vncserver.cxx b/unix/x0vncserver/x0vncserver.cxx
index ffaf5788..49c95137 100644
--- a/unix/x0vncserver/x0vncserver.cxx
+++ b/unix/x0vncserver/x0vncserver.cxx
@@ -90,10 +90,10 @@ static const char* defaultDesktopName()
return "";
struct passwd* pwent = getpwuid(getuid());
- if (pwent == NULL)
+ if (pwent == nullptr)
return "";
- int len = snprintf(NULL, 0, "%s@%s", pwent->pw_name, hostname.data());
+ int len = snprintf(nullptr, 0, "%s@%s", pwent->pw_name, hostname.data());
if (len < 0)
return "";
@@ -154,19 +154,19 @@ class FileTcpFilter : public TcpFilter
public:
FileTcpFilter(const char *fname)
- : TcpFilter("-"), fileName(NULL), lastModTime(0)
+ : TcpFilter("-"), fileName(nullptr), lastModTime(0)
{
- if (fname != NULL)
+ if (fname != nullptr)
fileName = strdup((char *)fname);
}
virtual ~FileTcpFilter()
{
- if (fileName != NULL)
+ if (fileName != nullptr)
free(fileName);
}
- virtual bool verifyConnection(Socket* s)
+ bool verifyConnection(Socket* s) override
{
if (!reloadRules()) {
vlog.error("Could not read IP filtering rules: rejecting all clients");
@@ -182,7 +182,7 @@ protected:
bool reloadRules()
{
- if (fileName == NULL)
+ if (fileName == nullptr)
return true;
struct stat st;
@@ -192,7 +192,7 @@ protected:
if (st.st_mtime != lastModTime) {
// Actually reload only if the file was modified
FILE *fp = fopen(fileName, "r");
- if (fp == NULL)
+ if (fp == nullptr)
return false;
// Remove all the rules from the parent class
@@ -225,14 +225,14 @@ private:
bool readLine(char *buf, int bufSize, FILE *fp)
{
- if (fp == NULL || buf == NULL || bufSize == 0)
+ if (fp == nullptr || buf == nullptr || bufSize == 0)
return false;
- if (fgets(buf, bufSize, fp) == NULL)
+ if (fgets(buf, bufSize, fp) == nullptr)
return false;
char *ptr = strchr(buf, '\n');
- if (ptr != NULL) {
+ if (ptr != nullptr) {
*ptr = '\0'; // remove newline at the end
} else {
if (!feof(fp)) {
@@ -353,7 +353,7 @@ int main(int argc, char** argv)
const char *addr = interface;
if (strcasecmp(addr, "all") == 0)
- addr = 0;
+ addr = nullptr;
if (localhostOnly)
createLocalTcpListeners(&tcp_listeners, (int)rfbport);
else
@@ -368,10 +368,8 @@ int main(int argc, char** argv)
FileTcpFilter fileTcpFilter(hostsFile);
if (strlen(hostsFile) != 0)
- for (std::list<SocketListener*>::iterator i = listeners.begin();
- i != listeners.end();
- i++)
- (*i)->setFilter(&fileTcpFilter);
+ for (SocketListener* listener : listeners)
+ listener->setFilter(&fileTcpFilter);
}
if (listeners.empty()) {
@@ -395,10 +393,8 @@ int main(int argc, char** argv)
FD_ZERO(&wfds);
FD_SET(ConnectionNumber(dpy), &rfds);
- for (std::list<SocketListener*>::iterator i = listeners.begin();
- i != listeners.end();
- i++)
- FD_SET((*i)->getFd(), &rfds);
+ for (SocketListener* listener : listeners)
+ FD_SET(listener->getFd(), &rfds);
server.getSockets(&sockets);
int clients_connected = 0;
@@ -436,8 +432,8 @@ int main(int argc, char** argv)
// Do the wait...
sched.sleepStarted();
- int n = select(FD_SETSIZE, &rfds, &wfds, 0,
- wait_ms ? &tv : NULL);
+ int n = select(FD_SETSIZE, &rfds, &wfds, nullptr,
+ wait_ms ? &tv : nullptr);
sched.sleepFinished();
if (n < 0) {
@@ -450,11 +446,9 @@ int main(int argc, char** argv)
}
// Accept new VNC connections
- for (std::list<SocketListener*>::iterator i = listeners.begin();
- i != listeners.end();
- i++) {
- if (FD_ISSET((*i)->getFd(), &rfds)) {
- Socket* sock = (*i)->accept();
+ for (SocketListener* listener : listeners) {
+ if (FD_ISSET(listener->getFd(), &rfds)) {
+ Socket* sock = listener->accept();
if (sock) {
server.addSocket(sock);
} else {
@@ -494,11 +488,8 @@ int main(int argc, char** argv)
TXWindow::handleXEvents(dpy);
// Run listener destructors; remove UNIX sockets etc
- for (std::list<SocketListener*>::iterator i = listeners.begin();
- i != listeners.end();
- i++) {
- delete *i;
- }
+ for (SocketListener* listener : listeners)
+ delete listener;
vlog.info("Terminated");
return 0;
diff --git a/unix/xserver/hw/vnc/Makefile.am b/unix/xserver/hw/vnc/Makefile.am
index f9372183..d344c85d 100644
--- a/unix/xserver/hw/vnc/Makefile.am
+++ b/unix/xserver/hw/vnc/Makefile.am
@@ -14,6 +14,8 @@ AM_CPPFLAGS = \
-I$(TIGERVNC_SRCDIR)/unix/common \
$(DIX_CFLAGS)
+AM_CXXFLAGS = -std=gnu++11
+
noinst_LTLIBRARIES = libvnccommon.la
HDRS = vncExtInit.h vncHooks.h \
diff --git a/unix/xserver/hw/vnc/RFBGlue.cc b/unix/xserver/hw/vnc/RFBGlue.cc
index 25431b65..2cbee35c 100644
--- a/unix/xserver/hw/vnc/RFBGlue.cc
+++ b/unix/xserver/hw/vnc/RFBGlue.cc
@@ -51,7 +51,7 @@ void vncLogError(const char *name, const char *format, ...)
LogWriter *vlog;
va_list ap;
vlog = LogWriter::getLogWriter(name);
- if (vlog == NULL)
+ if (vlog == nullptr)
return;
va_start(ap, format);
vlog->verror(format, ap);
@@ -63,7 +63,7 @@ void vncLogStatus(const char *name, const char *format, ...)
LogWriter *vlog;
va_list ap;
vlog = LogWriter::getLogWriter(name);
- if (vlog == NULL)
+ if (vlog == nullptr)
return;
va_start(ap, format);
vlog->vstatus(format, ap);
@@ -75,7 +75,7 @@ void vncLogInfo(const char *name, const char *format, ...)
LogWriter *vlog;
va_list ap;
vlog = LogWriter::getLogWriter(name);
- if (vlog == NULL)
+ if (vlog == nullptr)
return;
va_start(ap, format);
vlog->vinfo(format, ap);
@@ -87,7 +87,7 @@ void vncLogDebug(const char *name, const char *format, ...)
LogWriter *vlog;
va_list ap;
vlog = LogWriter::getLogWriter(name);
- if (vlog == NULL)
+ if (vlog == nullptr)
return;
va_start(ap, format);
vlog->vdebug(format, ap);
@@ -96,12 +96,12 @@ void vncLogDebug(const char *name, const char *format, ...)
int vncSetParam(const char *name, const char *value)
{
- if (value != NULL)
+ if (value != nullptr)
return rfb::Configuration::setParam(name, value);
else {
VoidParameter *param;
param = rfb::Configuration::getParam(name);
- if (param == NULL)
+ if (param == nullptr)
return false;
return param->setParam();
}
@@ -118,11 +118,11 @@ char* vncGetParam(const char *name)
// Hack to avoid exposing password!
if (strcasecmp(name, "Password") == 0)
- return NULL;
+ return nullptr;
param = rfb::Configuration::getParam(name);
- if (param == NULL)
- return NULL;
+ if (param == nullptr)
+ return nullptr;
return strdup(param->getValueStr().c_str());
}
@@ -132,8 +132,8 @@ const char* vncGetParamDesc(const char *name)
rfb::VoidParameter *param;
param = rfb::Configuration::getParam(name);
- if (param == NULL)
- return NULL;
+ if (param == nullptr)
+ return nullptr;
return param->getDescription();
}
@@ -144,11 +144,11 @@ int vncIsParamBool(const char *name)
BoolParameter *bparam;
param = rfb::Configuration::getParam(name);
- if (param == NULL)
+ if (param == nullptr)
return false;
bparam = dynamic_cast<BoolParameter*>(param);
- if (bparam == NULL)
+ if (bparam == nullptr)
return false;
return true;
@@ -179,8 +179,8 @@ char *vncGetParamList(void)
}
data = (char*)malloc(len + 1);
- if (data == NULL)
- return NULL;
+ if (data == nullptr)
+ return nullptr;
ptr = data;
for (ParameterIterator i; i.param; i.next()) {
@@ -227,7 +227,7 @@ char* vncConvertLF(const char* src, size_t bytes)
try {
return strdup(convertLF(src, bytes).c_str());
} catch (...) {
- return NULL;
+ return nullptr;
}
}
@@ -236,7 +236,7 @@ char* vncLatin1ToUTF8(const char* src, size_t bytes)
try {
return strdup(latin1ToUTF8(src, bytes).c_str());
} catch (...) {
- return NULL;
+ return nullptr;
}
}
@@ -245,7 +245,7 @@ char* vncUTF8ToLatin1(const char* src, size_t bytes)
try {
return strdup(utf8ToLatin1(src, bytes).c_str());
} catch (...) {
- return NULL;
+ return nullptr;
}
}
diff --git a/unix/xserver/hw/vnc/XserverDesktop.cc b/unix/xserver/hw/vnc/XserverDesktop.cc
index d4ee16b8..0c2b5bf9 100644
--- a/unix/xserver/hw/vnc/XserverDesktop.cc
+++ b/unix/xserver/hw/vnc/XserverDesktop.cc
@@ -80,7 +80,7 @@ XserverDesktop::XserverDesktop(int screenIndex_,
void* fbptr, int stride_)
: screenIndex(screenIndex_),
server(0), listeners(listeners_),
- shadowFramebuffer(NULL),
+ shadowFramebuffer(nullptr),
queryConnectId(0), queryConnectTimer(this)
{
format = pf;
@@ -88,11 +88,8 @@ XserverDesktop::XserverDesktop(int screenIndex_,
server = new VNCServerST(name, this);
setFramebuffer(width, height, fbptr, stride_);
- for (std::list<SocketListener*>::iterator i = listeners.begin();
- i != listeners.end();
- i++) {
- vncSetNotifyFd((*i)->getFd(), screenIndex, true, false);
- }
+ for (SocketListener* listener : listeners)
+ vncSetNotifyFd(listener->getFd(), screenIndex, true, false);
}
XserverDesktop::~XserverDesktop()
@@ -123,7 +120,7 @@ void XserverDesktop::setFramebuffer(int w, int h, void* fbptr, int stride_)
if (shadowFramebuffer) {
delete [] shadowFramebuffer;
- shadowFramebuffer = NULL;
+ shadowFramebuffer = nullptr;
}
if (!fbptr) {
@@ -521,7 +518,7 @@ void XserverDesktop::handleClipboardData(const char* data_)
void XserverDesktop::grabRegion(const rfb::Region& region)
{
- if (shadowFramebuffer == NULL)
+ if (shadowFramebuffer == nullptr)
return;
std::vector<rfb::Rect> rects;
diff --git a/unix/xserver/hw/vnc/XserverDesktop.h b/unix/xserver/hw/vnc/XserverDesktop.h
index e604295b..3b0f869f 100644
--- a/unix/xserver/hw/vnc/XserverDesktop.h
+++ b/unix/xserver/hw/vnc/XserverDesktop.h
@@ -91,21 +91,21 @@ public:
const char* rejectMsg=0);
// rfb::SDesktop callbacks
- virtual void init(rfb::VNCServer* vs);
- virtual void terminate();
- virtual void queryConnection(network::Socket* sock,
- const char* userName);
- virtual void pointerEvent(const rfb::Point& pos, int buttonMask);
- virtual void keyEvent(uint32_t keysym, uint32_t keycode, bool down);
- virtual unsigned int setScreenLayout(int fb_width, int fb_height,
- const rfb::ScreenSet& layout);
- virtual void frameTick(uint64_t msc);
- virtual void handleClipboardRequest();
- virtual void handleClipboardAnnounce(bool available);
- virtual void handleClipboardData(const char* data);
+ void init(rfb::VNCServer* vs) override;
+ void terminate() override;
+ void queryConnection(network::Socket* sock,
+ const char* userName) override;
+ void pointerEvent(const rfb::Point& pos, int buttonMask) override;
+ void keyEvent(uint32_t keysym, uint32_t keycode, bool down) override;
+ unsigned int setScreenLayout(int fb_width, int fb_height,
+ const rfb::ScreenSet& layout) override;
+ void frameTick(uint64_t msc) override;
+ void handleClipboardRequest() override;
+ void handleClipboardAnnounce(bool available) override;
+ void handleClipboardData(const char* data) override;
// rfb::PixelBuffer callbacks
- virtual void grabRegion(const rfb::Region& r);
+ void grabRegion(const rfb::Region& r) override;
protected:
bool handleListenerEvent(int fd,
@@ -115,7 +115,7 @@ protected:
rfb::VNCServer* sockserv,
bool read, bool write);
- virtual void handleTimeout(rfb::Timer* t);
+ void handleTimeout(rfb::Timer* t) override;
private:
diff --git a/unix/xserver/hw/vnc/vncExtInit.cc b/unix/xserver/hw/vnc/vncExtInit.cc
index 4003e768..073b07e2 100644
--- a/unix/xserver/hw/vnc/vncExtInit.cc
+++ b/unix/xserver/hw/vnc/vncExtInit.cc
@@ -114,10 +114,10 @@ static const char* defaultDesktopName()
return "";
struct passwd* pwent = getpwuid(getuid());
- if (pwent == NULL)
+ if (pwent == nullptr)
return "";
- size_t len = snprintf(NULL, 0, "%s@%s", pwent->pw_name, hostname.data());
+ size_t len = snprintf(nullptr, 0, "%s@%s", pwent->pw_name, hostname.data());
if (len < 0)
return "";
@@ -286,7 +286,7 @@ void vncExtensionClose(void)
try {
for (int scr = 0; scr < vncGetScreenCount(); scr++) {
delete desktop[scr];
- desktop[scr] = NULL;
+ desktop[scr] = nullptr;
}
} catch (rdr::Exception& e) {
vncFatalError("vncExtInit: %s\n",e.str());
diff --git a/vncviewer/BaseTouchHandler.cxx b/vncviewer/BaseTouchHandler.cxx
index 1bcf66c9..6552634b 100644
--- a/vncviewer/BaseTouchHandler.cxx
+++ b/vncviewer/BaseTouchHandler.cxx
@@ -40,7 +40,7 @@ static const unsigned DOUBLE_TAP_THRESHOLD = 50;
BaseTouchHandler::BaseTouchHandler()
{
- gettimeofday(&lastTapTime, NULL);
+ gettimeofday(&lastTapTime, nullptr);
}
BaseTouchHandler::~BaseTouchHandler()
@@ -188,7 +188,7 @@ void BaseTouchHandler::handleTapEvent(const GestureEvent& ev,
} else {
firstDoubleTapEvent = ev;
}
- gettimeofday(&lastTapTime, NULL);
+ gettimeofday(&lastTapTime, nullptr);
fakeMotionEvent(newEv);
fakeButtonEvent(true, buttonEvent, newEv);
diff --git a/vncviewer/CConn.cxx b/vncviewer/CConn.cxx
index 82c4af41..31f5b74d 100644
--- a/vncviewer/CConn.cxx
+++ b/vncviewer/CConn.cxx
@@ -72,8 +72,8 @@ static const PixelFormat mediumColourPF(8, 8, false, true,
// Time new bandwidth estimates are weighted against (in ms)
static const unsigned bpsEstimateWindow = 1000;
-CConn::CConn(const char* vncServerName, network::Socket* socket=NULL)
- : serverPort(0), desktop(NULL), updateCount(0), pixelCount(0),
+CConn::CConn(const char* vncServerName, network::Socket* socket=nullptr)
+ : serverPort(0), desktop(nullptr), updateCount(0), pixelCount(0),
lastServerEncoding((unsigned int)-1), bpsEstimate(20000000)
{
setShared(::shared);
@@ -90,10 +90,10 @@ CConn::CConn(const char* vncServerName, network::Socket* socket=NULL)
if (!noJpeg)
setQualityLevel(::qualityLevel);
- if(sock == NULL) {
+ if(sock == nullptr) {
try {
#ifndef WIN32
- if (strchr(vncServerName, '/') != NULL) {
+ if (strchr(vncServerName, '/') != nullptr) {
sock = new network::UnixSocket(vncServerName);
serverHost = sock->getPeerAddress();
vlog.info(_("Connected to socket %s"), serverHost.c_str());
@@ -346,7 +346,7 @@ void CConn::framebufferUpdateStart()
CConnection::framebufferUpdateStart();
// For bandwidth estimate
- gettimeofday(&updateStartTime, NULL);
+ gettimeofday(&updateStartTime, nullptr);
updateStartPos = sock->inStream().pos();
// Update the screen prematurely for very slow updates
@@ -367,7 +367,7 @@ void CConn::framebufferUpdateEnd()
updateCount++;
// Calculate bandwidth everything managed to maintain during this update
- gettimeofday(&now, NULL);
+ gettimeofday(&now, nullptr);
elapsed = (now.tv_sec - updateStartTime.tv_sec) * 1000000;
elapsed += now.tv_usec - updateStartTime.tv_usec;
if (elapsed == 0)
diff --git a/vncviewer/CConn.h b/vncviewer/CConn.h
index 835699e5..fcaf49f6 100644
--- a/vncviewer/CConn.h
+++ b/vncviewer/CConn.h
@@ -45,37 +45,40 @@ public:
static void socketEvent(FL_SOCKET fd, void *data);
// CConnection callback methods
- void initDone();
+ void initDone() override;
- void setDesktopSize(int w, int h);
+ void setDesktopSize(int w, int h) override;
void setExtendedDesktopSize(unsigned reason, unsigned result,
- int w, int h, const rfb::ScreenSet& layout);
+ int w, int h,
+ const rfb::ScreenSet& layout) override;
- void setName(const char* name);
+ void setName(const char* name) override;
- void setColourMapEntries(int firstColour, int nColours, uint16_t* rgbs);
+ void setColourMapEntries(int firstColour, int nColours,
+ uint16_t* rgbs) override;
- void bell();
+ void bell() override;
- void framebufferUpdateStart();
- void framebufferUpdateEnd();
- bool dataRect(const rfb::Rect& r, int encoding);
+ void framebufferUpdateStart() override;
+ void framebufferUpdateEnd() override;
+ bool dataRect(const rfb::Rect& r, int encoding) override;
void setCursor(int width, int height, const rfb::Point& hotspot,
- const uint8_t* data);
- void setCursorPos(const rfb::Point& pos);
+ const uint8_t* data) override;
+ void setCursorPos(const rfb::Point& pos) override;
- void fence(uint32_t flags, unsigned len, const uint8_t data[]);
+ void fence(uint32_t flags, unsigned len,
+ const uint8_t data[]) override;
- void setLEDState(unsigned int state);
+ void setLEDState(unsigned int state) override;
- virtual void handleClipboardRequest();
- virtual void handleClipboardAnnounce(bool available);
- virtual void handleClipboardData(const char* data);
+ void handleClipboardRequest() override;
+ void handleClipboardAnnounce(bool available) override;
+ void handleClipboardData(const char* data) override;
private:
- void resizeFramebuffer();
+ void resizeFramebuffer() override;
void autoSelectFormatAndEncoding();
void updatePixelFormat();
diff --git a/vncviewer/DesktopWindow.cxx b/vncviewer/DesktopWindow.cxx
index 7d7ae7c3..b0f79933 100644
--- a/vncviewer/DesktopWindow.cxx
+++ b/vncviewer/DesktopWindow.cxx
@@ -81,18 +81,18 @@ static std::set<DesktopWindow *> instances;
DesktopWindow::DesktopWindow(int w, int h, const char *name,
const rfb::PixelFormat& serverPF,
CConn* cc_)
- : Fl_Window(w, h), cc(cc_), offscreen(NULL), overlay(NULL),
+ : Fl_Window(w, h), cc(cc_), offscreen(nullptr), overlay(nullptr),
firstUpdate(true),
delayedFullscreen(false), delayedDesktopSize(false),
keyboardGrabbed(false), mouseGrabbed(false),
statsLastUpdates(0), statsLastPixels(0), statsLastPosition(0),
- statsGraph(NULL)
+ statsGraph(nullptr)
{
Fl_Group* group;
// Dummy group to prevent FLTK from moving our widgets around
group = new Fl_Group(0, 0, w, h);
- group->resizable(NULL);
+ group->resizable(nullptr);
resizable(group);
viewport = new Viewport(w, h, serverPF, cc);
@@ -342,9 +342,9 @@ void DesktopWindow::resizeFramebuffer(int new_w, int new_h)
XGetWindowProperty(fl_display, fl_xid(this), net_wm_state, 0, 1024, False, XA_ATOM, &type, &format, &nitems, &remain, (unsigned char**)&atoms);
- for (unsigned long i = 0;i < nitems;i++) {
- if ((atoms[i] == net_wm_state_maximized_vert) ||
- (atoms[i] == net_wm_state_maximized_horz)) {
+ for (unsigned long n = 0;n < nitems;n++) {
+ if ((atoms[n] == net_wm_state_maximized_vert) ||
+ (atoms[n] == net_wm_state_maximized_horz)) {
maximized = true;
break;
}
@@ -438,7 +438,7 @@ void DesktopWindow::draw()
#if !defined(__APPLE__)
// Adjust offscreen surface dimensions
- if ((offscreen == NULL) ||
+ if ((offscreen == nullptr) ||
(offscreen->width() != w()) || (offscreen->height() != h())) {
delete offscreen;
offscreen = new Surface(w(), h());
@@ -513,8 +513,8 @@ void DesktopWindow::draw()
windowRect.setXYWH(x(), y(), w(), h());
bool foundEnclosedScreen = false;
- for (int i = 0; i < Fl::screen_count(); i++) {
- Fl::screen_xywh(sx, sy, sw, sh, i);
+ for (int idx = 0; idx < Fl::screen_count(); idx++) {
+ Fl::screen_xywh(sx, sy, sw, sh, idx);
// The screen with the smallest index that are enclosed by
// the viewport will be used for showing the overlay.
@@ -632,10 +632,10 @@ void DesktopWindow::resize(int x, int y, int w, int h)
}
if (resize_req) {
- for (int i = 0;i < Fl::screen_count();i++) {
+ for (int idx = 0;idx < Fl::screen_count();idx++) {
int sx, sy, sw, sh;
- Fl::screen_xywh(sx, sy, sw, sh, i);
+ Fl::screen_xywh(sx, sy, sw, sh, idx);
// We can't trust x and y if the window isn't mapped as the
// window manager might adjust those numbers
@@ -786,7 +786,7 @@ void DesktopWindow::setOverlay(const char* text, ...)
overlay = new Surface(image);
overlayAlpha = 0;
- gettimeofday(&overlayStart, NULL);
+ gettimeofday(&overlayStart, nullptr);
delete image;
delete [] buffer;
@@ -814,7 +814,7 @@ void DesktopWindow::updateOverlay(void *data)
Fl::add_timeout(1.0/60, updateOverlay, self);
} else {
delete self->overlay;
- self->overlay = NULL;
+ self->overlay = nullptr;
}
self->damage(FL_DAMAGE_USER1);
@@ -891,7 +891,7 @@ int DesktopWindow::fltkDispatch(int event, Fl_Window *win)
// FLTK keeps spamming bogus FL_MOVE events if _any_ X event is
// received with the mouse pointer outside our windows
// https://github.com/fltk/fltk/issues/76
- if ((event == FL_MOVE) && (win == NULL))
+ if ((event == FL_MOVE) && (win == nullptr))
return 0;
ret = Fl::handle_(event, win);
@@ -977,9 +977,8 @@ void DesktopWindow::fullscreen_on()
std::set<int> selected = fullScreenSelectedMonitors.getParam();
monitors.insert(selected.begin(), selected.end());
} else {
- for (int i = 0; i < Fl::screen_count(); i++) {
- monitors.insert(i);
- }
+ for (int idx = 0; idx < Fl::screen_count(); idx++)
+ monitors.insert(idx);
}
// If no monitors were found in the selected monitors case, we want
@@ -1332,7 +1331,6 @@ void DesktopWindow::remoteResize(int width, int height)
layout.begin()->dimensions.br.x = width;
layout.begin()->dimensions.br.y = height;
} else {
- int i;
uint32_t id;
int sx, sy, sw, sh;
rfb::Rect viewport_rect, screen_rect;
@@ -1348,8 +1346,8 @@ void DesktopWindow::remoteResize(int width, int height)
// FIXME: We should really track screens better so we can handle
// a resized one.
//
- for (i = 0;i < Fl::screen_count();i++) {
- Fl::screen_xywh(sx, sy, sw, sh, i);
+ for (int idx = 0;idx < Fl::screen_count();idx++) {
+ Fl::screen_xywh(sx, sy, sw, sh, idx);
// Check that the screen is fully inside the framebuffer
screen_rect.setXYWH(sx, sy, sw, sh);
@@ -1658,7 +1656,7 @@ void DesktopWindow::handleStatsTimeout(void *data)
self->stats[statsCount-1].pps = (pixels - self->statsLastPixels) * 1000 / elapsed;
self->stats[statsCount-1].bps = (pos - self->statsLastPosition) * 1000 / elapsed;
- gettimeofday(&self->statsLastTime, NULL);
+ gettimeofday(&self->statsLastTime, nullptr);
self->statsLastUpdates = updates;
self->statsLastPixels = pixels;
self->statsLastPosition = pos;
diff --git a/vncviewer/DesktopWindow.h b/vncviewer/DesktopWindow.h
index fd622c6d..ce7960ce 100644
--- a/vncviewer/DesktopWindow.h
+++ b/vncviewer/DesktopWindow.h
@@ -71,11 +71,11 @@ public:
void handleClipboardData(const char* data);
// Fl_Window callback methods
- virtual void show();
- virtual void draw();
- virtual void resize(int x, int y, int w, int h);
+ void show() override;
+ void draw() override;
+ void resize(int x, int y, int w, int h) override;
- virtual int handle(int event);
+ int handle(int event) override;
void fullscreen_on();
diff --git a/vncviewer/EmulateMB.h b/vncviewer/EmulateMB.h
index 77fdec66..caf3c32a 100644
--- a/vncviewer/EmulateMB.h
+++ b/vncviewer/EmulateMB.h
@@ -31,7 +31,7 @@ public:
protected:
virtual void sendPointerEvent(const rfb::Point& pos, int buttonMask)=0;
- virtual void handleTimeout(rfb::Timer *t);
+ void handleTimeout(rfb::Timer *t) override;
private:
void sendAction(const rfb::Point& pos, int buttonMask, int action);
diff --git a/vncviewer/GestureHandler.cxx b/vncviewer/GestureHandler.cxx
index ed99555e..121ceecf 100644
--- a/vncviewer/GestureHandler.cxx
+++ b/vncviewer/GestureHandler.cxx
@@ -95,7 +95,7 @@ void GestureHandler::handleTouchBegin(int id, double x, double y)
return;
}
- gettimeofday(&ght.started, NULL);
+ gettimeofday(&ght.started, nullptr);
ght.active = true;
ght.lastX = ght.firstX = x;
ght.lastY = ght.firstY = y;
@@ -238,7 +238,7 @@ void GestureHandler::handleTouchEnd(int id)
longpressTimer.stop();
if (!waitingRelease) {
- gettimeofday(&releaseStart, NULL);
+ gettimeofday(&releaseStart, nullptr);
waitingRelease = true;
// Can't be a tap that requires more touches than we current have
@@ -375,19 +375,19 @@ void GestureHandler::pushEvent(GestureEventType t)
// For most gesture events the current (average) position is the
// most useful
- getPosition(NULL, NULL, &avgX, &avgY);
+ getPosition(nullptr, nullptr, &avgX, &avgY);
// However we have a slight distance to detect gestures, so for the
// first gesture event we want to use the first positions we saw
if (t == GestureBegin)
- getPosition(&avgX, &avgY, NULL, NULL);
+ getPosition(&avgX, &avgY, nullptr, nullptr);
// For these gestures, we always want the event coordinates
// to be where the gesture began, not the current touch location.
switch (state) {
case GH_TWODRAG:
case GH_PINCH:
- getPosition(&avgX, &avgY, NULL, NULL);
+ getPosition(&avgX, &avgY, nullptr, nullptr);
break;
}
@@ -398,9 +398,9 @@ void GestureHandler::pushEvent(GestureEventType t)
if (state == GH_PINCH) {
if (t == GestureBegin)
getAverageDistance(&gev.magnitudeX, &gev.magnitudeY,
- NULL, NULL);
+ nullptr, nullptr);
else
- getAverageDistance(NULL, NULL,
+ getAverageDistance(nullptr, nullptr,
&gev.magnitudeX, &gev.magnitudeY);
} else if (state == GH_TWODRAG) {
if (t == GestureBegin)
diff --git a/vncviewer/GestureHandler.h b/vncviewer/GestureHandler.h
index b07454df..2b31703a 100644
--- a/vncviewer/GestureHandler.h
+++ b/vncviewer/GestureHandler.h
@@ -42,12 +42,12 @@ class GestureHandler : public rfb::Timer::Callback {
private:
bool hasDetectedGesture();
- virtual void handleTimeout(rfb::Timer* t);
+ void handleTimeout(rfb::Timer* t) override;
void longpressTimeout();
void twoTouchTimeout();
void pushEvent(GestureEventType t);
- GestureEventGesture stateToGesture(unsigned char state);
+ static GestureEventGesture stateToGesture(unsigned char state);
void getPosition(double *firstX, double *firstY,
double *lastX, double *lastY);
diff --git a/vncviewer/MonitorIndicesParameter.cxx b/vncviewer/MonitorIndicesParameter.cxx
index dcc762a3..957ade06 100644
--- a/vncviewer/MonitorIndicesParameter.cxx
+++ b/vncviewer/MonitorIndicesParameter.cxx
@@ -71,24 +71,22 @@ std::set<int> MonitorIndicesParameter::getParam()
return indices;
}
-bool MonitorIndicesParameter::setParam(const char* value)
+bool MonitorIndicesParameter::setParam(const char* v)
{
- int index;
std::set<int> indices;
- if (!parseIndices(value, &indices, true)) {
+ if (!parseIndices(v, &indices, true)) {
vlog.error(_("Invalid configuration specified for %s"), name);
return false;
}
- for (std::set<int>::iterator it = indices.begin(); it != indices.end(); it++) {
- index = *it + 1;
-
+ for (int index : indices) {
+ index += 1;
if (index <= 0 || index > Fl::screen_count())
vlog.error(_("Monitor index %d does not exist"), index);
}
- return StringParameter::setParam(value);
+ return StringParameter::setParam(v);
}
bool MonitorIndicesParameter::setParam(std::set<int> indices)
@@ -111,16 +109,14 @@ bool MonitorIndicesParameter::setParam(std::set<int> indices)
int bytesWritten = 0;
char const * separator = "";
- for (std::set<int>::iterator index = configIndices.begin();
- index != configIndices.end();
- index++)
+ for (int configIndex : configIndices)
{
bytesWritten += snprintf(
buf+bytesWritten,
BUF_MAX_LEN-bytesWritten,
"%s%u",
separator,
- (*index)+1
+ configIndex+1
);
separator = ",";
@@ -134,7 +130,7 @@ static bool parseNumber(std::string number, std::set<int> *indices)
if (number.size() <= 0)
return false;
- int v = strtol(number.c_str(), NULL, 0);
+ int v = strtol(number.c_str(), nullptr, 0);
if (v <= 0)
return false;
diff --git a/vncviewer/MonitorIndicesParameter.h b/vncviewer/MonitorIndicesParameter.h
index 58e55e43..d91c84fe 100644
--- a/vncviewer/MonitorIndicesParameter.h
+++ b/vncviewer/MonitorIndicesParameter.h
@@ -29,15 +29,15 @@ public:
MonitorIndicesParameter(const char* name_, const char* desc_, const char* v);
std::set<int> getParam();
bool setParam(std::set<int> indices);
- bool setParam(const char* value);
+ bool setParam(const char* v) override;
private:
typedef struct {
int x, y, w, h;
int fltkIndex;
} Monitor;
- bool parseIndices(const char* value, std::set<int> *indices,
- bool complain=false);
+ static bool parseIndices(const char* value, std::set<int> *indices,
+ bool complain=false);
std::vector<MonitorIndicesParameter::Monitor> fetchMonitors();
static int compare(const void*, const void*);
};
diff --git a/vncviewer/OptionsDialog.cxx b/vncviewer/OptionsDialog.cxx
index 3c293fac..e04065ec 100644
--- a/vncviewer/OptionsDialog.cxx
+++ b/vncviewer/OptionsDialog.cxx
@@ -123,7 +123,7 @@ OptionsDialog::~OptionsDialog()
void OptionsDialog::showDialog(void)
{
- static OptionsDialog *dialog = NULL;
+ static OptionsDialog *dialog = nullptr;
if (!dialog)
dialog = new OptionsDialog();
@@ -218,10 +218,8 @@ void OptionsDialog::loadOptions(void)
Security security(SecurityClient::secTypes);
list<uint8_t> secTypes;
- list<uint8_t>::iterator iter;
list<uint32_t> secTypesExt;
- list<uint32_t>::iterator iterExt;
encNoneCheckbox->value(false);
#ifdef HAVE_GNUTLS
@@ -237,8 +235,8 @@ void OptionsDialog::loadOptions(void)
authPlainCheckbox->value(false);
secTypes = security.GetEnabledSecTypes();
- for (iter = secTypes.begin(); iter != secTypes.end(); ++iter) {
- switch (*iter) {
+ for (uint8_t type : secTypes) {
+ switch (type) {
case secTypeNone:
encNoneCheckbox->value(true);
authNoneCheckbox->value(true);
@@ -251,8 +249,8 @@ void OptionsDialog::loadOptions(void)
}
secTypesExt = security.GetEnabledExtSecTypes();
- for (iterExt = secTypesExt.begin(); iterExt != secTypesExt.end(); ++iterExt) {
- switch (*iterExt) {
+ for (uint32_t type : secTypesExt) {
+ switch (type) {
case secTypePlain:
encNoneCheckbox->value(true);
authPlainCheckbox->value(true);
@@ -330,9 +328,9 @@ void OptionsDialog::loadOptions(void)
menuKeyChoice->value(0);
menuKeyBuf = menuKey;
- for (int i = 0; i < getMenuKeySymbolCount(); i++)
- if (!strcmp(getMenuKeySymbols()[i].name, menuKeyBuf))
- menuKeyChoice->value(i + 1);
+ for (int idx = 0; idx < getMenuKeySymbolCount(); idx++)
+ if (!strcmp(getMenuKeySymbols()[idx].name, menuKeyBuf))
+ menuKeyChoice->value(idx + 1);
/* Display */
if (!fullScreen) {
@@ -577,7 +575,7 @@ void OptionsDialog::createCompressionPage(int tx, int ty, int tw, int th)
encodingGroup->end();
/* Needed for resize to work sanely */
- encodingGroup->resizable(NULL);
+ encodingGroup->resizable(nullptr);
encodingGroup->size(encodingGroup->w(), ty - encodingGroup->y());
col1_ty = ty;
@@ -629,7 +627,7 @@ void OptionsDialog::createCompressionPage(int tx, int ty, int tw, int th)
colorlevelGroup->end();
/* Needed for resize to work sanely */
- colorlevelGroup->resizable(NULL);
+ colorlevelGroup->resizable(nullptr);
colorlevelGroup->size(colorlevelGroup->w(),
ty - colorlevelGroup->y());
col2_ty = ty;
@@ -745,7 +743,7 @@ void OptionsDialog::createSecurityPage(int tx, int ty, int tw, int th)
encryptionGroup->end();
/* Needed for resize to work sanely */
- encryptionGroup->resizable(NULL);
+ encryptionGroup->resizable(nullptr);
encryptionGroup->size(encryptionGroup->w(),
ty - encryptionGroup->y());
@@ -787,7 +785,7 @@ void OptionsDialog::createSecurityPage(int tx, int ty, int tw, int th)
authenticationGroup->end();
/* Needed for resize to work sanely */
- authenticationGroup->resizable(NULL);
+ authenticationGroup->resizable(nullptr);
authenticationGroup->size(authenticationGroup->w(),
ty - authenticationGroup->y());
@@ -847,7 +845,7 @@ void OptionsDialog::createInputPage(int tx, int ty, int tw, int th)
mouseGroup->end();
/* Needed for resize to work sanely */
- mouseGroup->resizable(NULL);
+ mouseGroup->resizable(nullptr);
mouseGroup->size(mouseGroup->w(), ty - mouseGroup->y());
/* Back to normal */
@@ -873,9 +871,9 @@ void OptionsDialog::createInputPage(int tx, int ty, int tw, int th)
menuKeyChoice = new Fl_Choice(LBLLEFT(tx, ty, 150, CHOICE_HEIGHT, _("Menu key")));
- fltk_menu_add(menuKeyChoice, _("None"), 0, NULL, (void*)0, FL_MENU_DIVIDER);
- for (int i = 0; i < getMenuKeySymbolCount(); i++)
- fltk_menu_add(menuKeyChoice, getMenuKeySymbols()[i].name, 0, NULL, 0, 0);
+ fltk_menu_add(menuKeyChoice, _("None"), 0, nullptr, nullptr, FL_MENU_DIVIDER);
+ for (int idx = 0; idx < getMenuKeySymbolCount(); idx++)
+ fltk_menu_add(menuKeyChoice, getMenuKeySymbols()[idx].name, 0, nullptr, nullptr, 0);
ty += CHOICE_HEIGHT + TIGHT_MARGIN;
}
@@ -883,7 +881,7 @@ void OptionsDialog::createInputPage(int tx, int ty, int tw, int th)
keyboardGroup->end();
/* Needed for resize to work sanely */
- keyboardGroup->resizable(NULL);
+ keyboardGroup->resizable(nullptr);
keyboardGroup->size(keyboardGroup->w(), ty - keyboardGroup->y());
/* Back to normal */
@@ -935,7 +933,7 @@ void OptionsDialog::createInputPage(int tx, int ty, int tw, int th)
clipboardGroup->end();
/* Needed for resize to work sanely */
- clipboardGroup->resizable(NULL);
+ clipboardGroup->resizable(nullptr);
clipboardGroup->size(clipboardGroup->w(), ty - clipboardGroup->y());
/* Back to normal */
@@ -1013,7 +1011,7 @@ void OptionsDialog::createDisplayPage(int tx, int ty, int tw, int th)
displayModeGroup->end();
/* Needed for resize to work sanely */
- displayModeGroup->resizable(NULL);
+ displayModeGroup->resizable(nullptr);
displayModeGroup->size(displayModeGroup->w(),
ty - displayModeGroup->y());
diff --git a/vncviewer/OptionsDialog.h b/vncviewer/OptionsDialog.h
index be08620d..f6ca89b1 100644
--- a/vncviewer/OptionsDialog.h
+++ b/vncviewer/OptionsDialog.h
@@ -42,10 +42,10 @@ protected:
public:
static void showDialog(void);
- static void addCallback(OptionsCallback *cb, void *data = NULL);
+ static void addCallback(OptionsCallback *cb, void *data = nullptr);
static void removeCallback(OptionsCallback *cb);
- void show(void);
+ void show(void) override;
protected:
void loadOptions(void);
diff --git a/vncviewer/PlatformPixelBuffer.cxx b/vncviewer/PlatformPixelBuffer.cxx
index 2c91c704..bcb4cb23 100644
--- a/vncviewer/PlatformPixelBuffer.cxx
+++ b/vncviewer/PlatformPixelBuffer.cxx
@@ -41,16 +41,16 @@ static rfb::LogWriter vlog("PlatformPixelBuffer");
PlatformPixelBuffer::PlatformPixelBuffer(int width, int height) :
FullFramePixelBuffer(rfb::PixelFormat(32, 24, false, true,
255, 255, 255, 16, 8, 0),
- 0, 0, NULL, 0),
+ 0, 0, nullptr, 0),
Surface(width, height)
#if !defined(WIN32) && !defined(__APPLE__)
- , shminfo(NULL), xim(NULL)
+ , shminfo(nullptr), xim(nullptr)
#endif
{
#if !defined(WIN32) && !defined(__APPLE__)
if (!setupShm(width, height)) {
- xim = XCreateImage(fl_display, CopyFromParent, 32,
- ZPixmap, 0, 0, width, height, 32, 0);
+ xim = XCreateImage(fl_display, (Visual*)CopyFromParent, 32,
+ ZPixmap, 0, nullptr, width, height, 32, 0);
if (!xim)
throw rdr::Exception("XCreateImage");
@@ -78,15 +78,15 @@ PlatformPixelBuffer::~PlatformPixelBuffer()
vlog.debug("Freeing shared memory XImage");
XShmDetach(fl_display, shminfo);
shmdt(shminfo->shmaddr);
- shmctl(shminfo->shmid, IPC_RMID, 0);
+ shmctl(shminfo->shmid, IPC_RMID, nullptr);
delete shminfo;
- shminfo = NULL;
+ shminfo = nullptr;
}
// XDestroyImage() will free(xim->data) if appropriate
if (xim)
XDestroyImage(xim);
- xim = NULL;
+ xim = nullptr;
#endif
}
@@ -113,7 +113,7 @@ rfb::Rect PlatformPixelBuffer::getDamage(void)
GC gc;
- gc = XCreateGC(fl_display, pixmap, 0, NULL);
+ gc = XCreateGC(fl_display, pixmap, 0, nullptr);
if (shminfo) {
XShmPutImage(fl_display, pixmap, gc, xim,
r.tl.x, r.tl.y, r.tl.x, r.tl.y,
@@ -147,7 +147,7 @@ bool PlatformPixelBuffer::setupShm(int width, int height)
int major, minor;
Bool pixmaps;
XErrorHandler old_handler;
- const char *display_name = XDisplayName (NULL);
+ const char *display_name = XDisplayName(nullptr);
/* Don't use MIT-SHM on remote displays */
if (*display_name && *display_name != ':')
@@ -158,8 +158,8 @@ bool PlatformPixelBuffer::setupShm(int width, int height)
shminfo = new XShmSegmentInfo;
- xim = XShmCreateImage(fl_display, CopyFromParent, 32,
- ZPixmap, 0, shminfo, width, height);
+ xim = XShmCreateImage(fl_display, (Visual*)CopyFromParent, 32,
+ ZPixmap, nullptr, shminfo, width, height);
if (!xim)
goto free_shminfo;
@@ -169,8 +169,8 @@ bool PlatformPixelBuffer::setupShm(int width, int height)
if (shminfo->shmid == -1)
goto free_xim;
- shminfo->shmaddr = xim->data = (char*)shmat(shminfo->shmid, 0, 0);
- shmctl(shminfo->shmid, IPC_RMID, 0); // to avoid memory leakage
+ shminfo->shmaddr = xim->data = (char*)shmat(shminfo->shmid, nullptr, 0);
+ shmctl(shminfo->shmid, IPC_RMID, nullptr); // to avoid memory leakage
if (shminfo->shmaddr == (char *)-1)
goto free_xim;
@@ -202,11 +202,11 @@ free_shmaddr:
free_xim:
XDestroyImage(xim);
- xim = NULL;
+ xim = nullptr;
free_shminfo:
delete shminfo;
- shminfo = NULL;
+ shminfo = nullptr;
return 0;
}
diff --git a/vncviewer/PlatformPixelBuffer.h b/vncviewer/PlatformPixelBuffer.h
index ec439f64..24763d46 100644
--- a/vncviewer/PlatformPixelBuffer.h
+++ b/vncviewer/PlatformPixelBuffer.h
@@ -40,7 +40,7 @@ public:
PlatformPixelBuffer(int width, int height);
~PlatformPixelBuffer();
- virtual void commitBufferRW(const rfb::Rect& r);
+ void commitBufferRW(const rfb::Rect& r) override;
rfb::Rect getDamage(void);
diff --git a/vncviewer/ServerDialog.cxx b/vncviewer/ServerDialog.cxx
index 4d57b5fb..3bce2b51 100644
--- a/vncviewer/ServerDialog.cxx
+++ b/vncviewer/ServerDialog.cxx
@@ -110,7 +110,7 @@ ServerDialog::ServerDialog()
y += BUTTON_HEIGHT + INNER_MARGIN;
/* Needed for resize to work sanely */
- resizable(NULL);
+ resizable(nullptr);
h(y-INNER_MARGIN+OUTER_MARGIN);
callback(this->handleCancel, this);
@@ -146,7 +146,7 @@ void ServerDialog::run(const char* servername, char *newservername)
while (dialog.shown()) Fl::wait();
- if (dialog.serverName->value() == NULL) {
+ if (dialog.serverName->value() == nullptr) {
newservername[0] = '\0';
return;
}
@@ -180,7 +180,7 @@ void ServerDialog::handleLoad(Fl_Widget* /*widget*/, void* data)
Fl::wait();
// Did the user hit cancel?
- if (file_chooser->value() == NULL) {
+ if (file_chooser->value() == nullptr) {
delete(file_chooser);
return;
}
@@ -223,7 +223,7 @@ void ServerDialog::handleSaveAs(Fl_Widget* /*widget*/, void* data)
Fl::wait();
// Did the user hit cancel?
- if (file_chooser->value() == NULL) {
+ if (file_chooser->value() == nullptr) {
delete(file_chooser);
return;
}
@@ -237,7 +237,7 @@ void ServerDialog::handleSaveAs(Fl_Widget* /*widget*/, void* data)
// The file already exists.
fclose(f);
int overwrite_choice = fl_choice(_("%s already exists. Do you want to overwrite?"),
- _("Overwrite"), _("No"), NULL, filename);
+ _("Overwrite"), _("No"), nullptr, filename);
if (overwrite_choice == 1) {
// If the user doesn't want to overwrite:
@@ -284,7 +284,7 @@ void ServerDialog::handleConnect(Fl_Widget* /*widget*/, void *data)
dialog->hide();
try {
- saveViewerParameters(NULL, servername);
+ saveViewerParameters(nullptr, servername);
} catch (Exception& e) {
vlog.error("%s", e.str());
fl_alert(_("Unable to save the default configuration:\n\n%s"),
@@ -316,7 +316,7 @@ void ServerDialog::loadServerHistory()
#endif
const char* stateDir = os::getvncstatedir();
- if (stateDir == NULL)
+ if (stateDir == nullptr)
throw Exception(_("Could not obtain the state directory path"));
char filepath[PATH_MAX];
@@ -382,7 +382,7 @@ void ServerDialog::saveServerHistory()
#endif
const char* stateDir = os::getvncstatedir();
- if (stateDir == NULL)
+ if (stateDir == nullptr)
throw Exception(_("Could not obtain the state directory path"));
char filepath[PATH_MAX];
@@ -395,8 +395,8 @@ void ServerDialog::saveServerHistory()
filepath, strerror(errno));
// Save the last X elements to the config file.
- for(size_t i=0; i < serverHistory.size() && i <= SERVER_HISTORY_SIZE; i++)
- fprintf(f, "%s\n", serverHistory[i].c_str());
+ for(size_t idx=0; idx < serverHistory.size() && idx <= SERVER_HISTORY_SIZE; idx++)
+ fprintf(f, "%s\n", serverHistory[idx].c_str());
fclose(f);
}
diff --git a/vncviewer/Surface.h b/vncviewer/Surface.h
index 1cb87f50..60e452b1 100644
--- a/vncviewer/Surface.h
+++ b/vncviewer/Surface.h
@@ -41,11 +41,15 @@ public:
void clear(unsigned char r, unsigned char g, unsigned char b, unsigned char a=255);
- void draw(int src_x, int src_y, int x, int y, int w, int h);
- void draw(Surface* dst, int src_x, int src_y, int x, int y, int w, int h);
+ void draw(int src_x, int src_y, int dst_x, int dst_y,
+ int dst_w, int dst_h);
+ void draw(Surface* dst, int src_x, int src_y, int dst_x, int dst_y,
+ int dst_w, int dst_h);
- void blend(int src_x, int src_y, int x, int y, int w, int h, int a=255);
- void blend(Surface* dst, int src_x, int src_y, int x, int y, int w, int h, int a=255);
+ void blend(int src_x, int src_y, int dst_x, int dst_y,
+ int dst_w, int dst_h, int a=255);
+ void blend(Surface* dst, int src_x, int src_y, int dst_x, int dst_y,
+ int dst_w, int dst_h, int a=255);
protected:
void alloc();
diff --git a/vncviewer/Surface_OSX.cxx b/vncviewer/Surface_OSX.cxx
index 445c9e6c..673f37e9 100644
--- a/vncviewer/Surface_OSX.cxx
+++ b/vncviewer/Surface_OSX.cxx
@@ -44,8 +44,8 @@ static CGImageRef create_image(CGColorSpaceRef lut,
CGImageRef image;
- provider = CGDataProviderCreateWithData(NULL, data,
- w * h * 4, NULL);
+ provider = CGDataProviderCreateWithData(nullptr, data,
+ w * h * 4, nullptr);
if (!provider)
throw rdr::Exception("CGDataProviderCreateWithData");
@@ -58,7 +58,8 @@ static CGImageRef create_image(CGColorSpaceRef lut,
image = CGImageCreate(w, h, 8, 32, w * 4, lut,
alpha | kCGBitmapByteOrder32Little,
- provider, NULL, false, kCGRenderingIntentDefault);
+ provider, nullptr, false,
+ kCGRenderingIntentDefault);
CGDataProviderRelease(provider);
if (!image)
throw rdr::Exception("CGImageCreate");
@@ -136,7 +137,8 @@ void Surface::clear(unsigned char r, unsigned char g, unsigned char b, unsigned
}
}
-void Surface::draw(int src_x, int src_y, int x, int y, int w, int h)
+void Surface::draw(int src_x, int src_y, int dst_x, int dst_y,
+ int dst_w, int dst_h)
{
CGColorSpaceRef lut;
@@ -147,32 +149,34 @@ void Surface::draw(int src_x, int src_y, int x, int y, int w, int h)
CGContextConcatCTM(fl_gc, CGAffineTransformInvert(CGContextGetCTM(fl_gc)));
// macOS Coordinates are from bottom left, not top left
- y = Fl_Window::current()->h() - (y + h);
+ dst_y = Fl_Window::current()->h() - (dst_y + dst_h);
lut = cocoa_win_color_space(Fl_Window::current());
render(fl_gc, lut, data, kCGBlendModeCopy, 1.0,
- src_x, src_y, width(), height(), x, y, w, h);
+ src_x, src_y, width(), height(), dst_x, dst_y, dst_w, dst_h);
CGColorSpaceRelease(lut);
CGContextRestoreGState(fl_gc);
}
-void Surface::draw(Surface* dst, int src_x, int src_y, int x, int y, int w, int h)
+void Surface::draw(Surface* dst, int src_x, int src_y,
+ int dst_x, int dst_y, int dst_w, int dst_h)
{
CGContextRef bitmap;
bitmap = make_bitmap(dst->width(), dst->height(), dst->data);
// macOS Coordinates are from bottom left, not top left
- y = dst->height() - (y + h);
+ dst_y = dst->height() - (dst_y + dst_h);
render(bitmap, srgb, data, kCGBlendModeCopy, 1.0,
- src_x, src_y, width(), height(), x, y, w, h);
+ src_x, src_y, width(), height(), dst_x, dst_y, dst_w, dst_h);
CGContextRelease(bitmap);
}
-void Surface::blend(int src_x, int src_y, int x, int y, int w, int h, int a)
+void Surface::blend(int src_x, int src_y, int dst_x, int dst_y,
+ int dst_w, int dst_h, int a)
{
CGColorSpaceRef lut;
@@ -183,27 +187,28 @@ void Surface::blend(int src_x, int src_y, int x, int y, int w, int h, int a)
CGContextConcatCTM(fl_gc, CGAffineTransformInvert(CGContextGetCTM(fl_gc)));
// macOS Coordinates are from bottom left, not top left
- y = Fl_Window::current()->h() - (y + h);
+ dst_y = Fl_Window::current()->h() - (dst_y + dst_h);
lut = cocoa_win_color_space(Fl_Window::current());
render(fl_gc, lut, data, kCGBlendModeNormal, (CGFloat)a/255.0,
- src_x, src_y, width(), height(), x, y, w, h);
+ src_x, src_y, width(), height(), dst_x, dst_y, dst_w, dst_h);
CGColorSpaceRelease(lut);
CGContextRestoreGState(fl_gc);
}
-void Surface::blend(Surface* dst, int src_x, int src_y, int x, int y, int w, int h, int a)
+void Surface::blend(Surface* dst, int src_x, int src_y,
+ int dst_x, int dst_y, int dst_w, int dst_h, int a)
{
CGContextRef bitmap;
bitmap = make_bitmap(dst->width(), dst->height(), dst->data);
// macOS Coordinates are from bottom left, not top left
- y = dst->height() - (y + h);
+ dst_y = dst->height() - (dst_y + dst_h);
render(bitmap, srgb, data, kCGBlendModeNormal, (CGFloat)a/255.0,
- src_x, src_y, width(), height(), x, y, w, h);
+ src_x, src_y, width(), height(), dst_x, dst_y, dst_w, dst_h);
CGContextRelease(bitmap);
}
diff --git a/vncviewer/Surface_Win32.cxx b/vncviewer/Surface_Win32.cxx
index d438fa12..46a2b055 100644
--- a/vncviewer/Surface_Win32.cxx
+++ b/vncviewer/Surface_Win32.cxx
@@ -50,7 +50,8 @@ void Surface::clear(unsigned char r, unsigned char g, unsigned char b, unsigned
}
}
-void Surface::draw(int src_x, int src_y, int x, int y, int w, int h)
+void Surface::draw(int src_x, int src_y, int dst_x, int dst_y,
+ int dst_w, int dst_h)
{
HDC dc;
@@ -61,7 +62,8 @@ void Surface::draw(int src_x, int src_y, int x, int y, int w, int h)
if (!SelectObject(dc, bitmap))
throw rdr::SystemException("SelectObject", GetLastError());
- if (!BitBlt(fl_gc, x, y, w, h, dc, src_x, src_y, SRCCOPY)) {
+ if (!BitBlt(fl_gc, dst_x, dst_y, dst_w, dst_h,
+ dc, src_x, src_y, SRCCOPY)) {
// If the desktop we're rendering to is inactive (like when the screen
// is locked or the UAC is active), then GDI calls will randomly fail.
// This is completely undocumented so we have no idea how best to deal
@@ -74,11 +76,12 @@ void Surface::draw(int src_x, int src_y, int x, int y, int w, int h)
DeleteDC(dc);
}
-void Surface::draw(Surface* dst, int src_x, int src_y, int x, int y, int w, int h)
+void Surface::draw(Surface* dst, int src_x, int src_y,
+ int dst_x, int dst_y, int dst_w, int dst_h)
{
HDC origdc, dstdc;
- dstdc = CreateCompatibleDC(NULL);
+ dstdc = CreateCompatibleDC(nullptr);
if (!dstdc)
throw rdr::SystemException("CreateCompatibleDC", GetLastError());
@@ -87,29 +90,31 @@ void Surface::draw(Surface* dst, int src_x, int src_y, int x, int y, int w, int
origdc = fl_gc;
fl_gc = dstdc;
- draw(src_x, src_y, x, y, w, h);
+ draw(src_x, src_y, dst_x, dst_y, dst_w, dst_h);
fl_gc = origdc;
DeleteDC(dstdc);
}
void Surface::blend(int /*src_x*/, int /*src_y*/,
- int /*x*/, int /*y*/, int /*w*/, int /*h*/,
+ int /*dst_x*/, int /*dst_y*/,
+ int /*dst_w*/, int /*dst_h*/,
int /*a*/)
{
// Compositing doesn't work properly for window DC:s
assert(false);
}
-void Surface::blend(Surface* dst, int src_x, int src_y, int x, int y, int w, int h, int a)
+void Surface::blend(Surface* dst, int src_x, int src_y,
+ int dst_x, int dst_y, int dst_w, int dst_h, int a)
{
HDC dstdc, srcdc;
BLENDFUNCTION blend;
- dstdc = CreateCompatibleDC(NULL);
+ dstdc = CreateCompatibleDC(nullptr);
if (!dstdc)
throw rdr::SystemException("CreateCompatibleDC", GetLastError());
- srcdc = CreateCompatibleDC(NULL);
+ srcdc = CreateCompatibleDC(nullptr);
if (!srcdc)
throw rdr::SystemException("CreateCompatibleDC", GetLastError());
@@ -123,7 +128,8 @@ void Surface::blend(Surface* dst, int src_x, int src_y, int x, int y, int w, int
blend.SourceConstantAlpha = a;
blend.AlphaFormat = AC_SRC_ALPHA;
- if (!AlphaBlend(dstdc, x, y, w, h, srcdc, src_x, src_y, w, h, blend)) {
+ if (!AlphaBlend(dstdc, dst_x, dst_y, dst_w, dst_h,
+ srcdc, src_x, src_y, dst_w, dst_h, blend)) {
// If the desktop we're rendering to is inactive (like when the screen
// is locked or the UAC is active), then GDI calls will randomly fail.
// This is completely undocumented so we have no idea how best to deal
@@ -152,8 +158,8 @@ void Surface::alloc()
bih.biHeight = -height(); // Negative to get top-down
bih.biCompression = BI_RGB;
- bitmap = CreateDIBSection(NULL, (BITMAPINFO*)&bih,
- DIB_RGB_COLORS, (void**)&data, NULL, 0);
+ bitmap = CreateDIBSection(nullptr, (BITMAPINFO*)&bih,
+ DIB_RGB_COLORS, (void**)&data, nullptr, 0);
if (!bitmap)
throw rdr::SystemException("CreateDIBSection", GetLastError());
}
diff --git a/vncviewer/Surface_X11.cxx b/vncviewer/Surface_X11.cxx
index 7725cb5b..d27fcd26 100644
--- a/vncviewer/Surface_X11.cxx
+++ b/vncviewer/Surface_X11.cxx
@@ -43,20 +43,22 @@ void Surface::clear(unsigned char r, unsigned char g, unsigned char b, unsigned
0, 0, width(), height());
}
-void Surface::draw(int src_x, int src_y, int x, int y, int w, int h)
+void Surface::draw(int src_x, int src_y, int dst_x, int dst_y,
+ int dst_w, int dst_h)
{
Picture winPict;
- winPict = XRenderCreatePicture(fl_display, fl_window, visFormat, 0, NULL);
+ winPict = XRenderCreatePicture(fl_display, fl_window, visFormat, 0, nullptr);
XRenderComposite(fl_display, PictOpSrc, picture, None, winPict,
- src_x, src_y, 0, 0, x, y, w, h);
+ src_x, src_y, 0, 0, dst_x, dst_y, dst_w, dst_h);
XRenderFreePicture(fl_display, winPict);
}
-void Surface::draw(Surface* dst, int src_x, int src_y, int x, int y, int w, int h)
+void Surface::draw(Surface* dst, int src_x, int src_y,
+ int dst_x, int dst_y, int dst_w, int dst_h)
{
XRenderComposite(fl_display, PictOpSrc, picture, None, dst->picture,
- src_x, src_y, 0, 0, x, y, w, h);
+ src_x, src_y, 0, 0, dst_x, dst_y, dst_w, dst_h);
}
static Picture alpha_mask(int a)
@@ -86,27 +88,29 @@ static Picture alpha_mask(int a)
return pict;
}
-void Surface::blend(int src_x, int src_y, int x, int y, int w, int h, int a)
+void Surface::blend(int src_x, int src_y, int dst_x, int dst_y,
+ int dst_w, int dst_h, int a)
{
Picture winPict, alpha;
- winPict = XRenderCreatePicture(fl_display, fl_window, visFormat, 0, NULL);
+ winPict = XRenderCreatePicture(fl_display, fl_window, visFormat, 0, nullptr);
alpha = alpha_mask(a);
XRenderComposite(fl_display, PictOpOver, picture, alpha, winPict,
- src_x, src_y, 0, 0, x, y, w, h);
+ src_x, src_y, 0, 0, dst_x, dst_y, dst_w, dst_h);
XRenderFreePicture(fl_display, winPict);
if (alpha != None)
XRenderFreePicture(fl_display, alpha);
}
-void Surface::blend(Surface* dst, int src_x, int src_y, int x, int y, int w, int h, int a)
+void Surface::blend(Surface* dst, int src_x, int src_y,
+ int dst_x, int dst_y, int dst_w, int dst_h, int a)
{
Picture alpha;
alpha = alpha_mask(a);
XRenderComposite(fl_display, PictOpOver, picture, alpha, dst->picture,
- src_x, src_y, 0, 0, x, y, w, h);
+ src_x, src_y, 0, 0, dst_x, dst_y, dst_w, dst_h);
if (alpha != None)
XRenderFreePicture(fl_display, alpha);
}
@@ -154,7 +158,7 @@ void Surface::alloc()
if (!format)
throw rdr::Exception("XRenderFindFormat");
- picture = XRenderCreatePicture(fl_display, pixmap, format, 0, NULL);
+ picture = XRenderCreatePicture(fl_display, pixmap, format, 0, nullptr);
visFormat = XRenderFindVisualFormat(fl_display, fl_visual->visual);
}
@@ -177,8 +181,8 @@ void Surface::update(const Fl_RGB_Image* image)
assert(image->w() == width());
assert(image->h() == height());
- img = XCreateImage(fl_display, CopyFromParent, 32,
- ZPixmap, 0, NULL, width(), height(),
+ img = XCreateImage(fl_display, (Visual*)CopyFromParent, 32,
+ ZPixmap, 0, nullptr, width(), height(),
32, 0);
if (!img)
throw rdr::Exception("XCreateImage");
@@ -224,7 +228,7 @@ void Surface::update(const Fl_RGB_Image* image)
in += image->ld() - image->w() * image->d();
}
- gc = XCreateGC(fl_display, pixmap, 0, NULL);
+ gc = XCreateGC(fl_display, pixmap, 0, nullptr);
XPutImage(fl_display, pixmap, gc, img,
0, 0, 0, 0, img->width, img->height);
XFreeGC(fl_display, gc);
diff --git a/vncviewer/UserDialog.cxx b/vncviewer/UserDialog.cxx
index 7f8b3c8e..958b9d66 100644
--- a/vncviewer/UserDialog.cxx
+++ b/vncviewer/UserDialog.cxx
@@ -55,10 +55,10 @@ using namespace rfb;
static Fl_Pixmap secure_icon(secure);
static Fl_Pixmap insecure_icon(insecure);
-static int ret_val = 0;
+static long ret_val = 0;
-static void button_cb(Fl_Widget *widget, void *val) {
- ret_val = (fl_intptr_t)val;
+static void button_cb(Fl_Widget *widget, long val) {
+ ret_val = val;
widget->window()->hide();
}
@@ -70,7 +70,7 @@ UserDialog::~UserDialog()
{
}
-void UserDialog::getUserPasswd(bool secure, std::string* user,
+void UserDialog::getUserPasswd(bool secure_, std::string* user,
std::string* password)
{
const char *passwordFileName(passwordFile);
@@ -116,12 +116,12 @@ void UserDialog::getUserPasswd(bool secure, std::string* user,
int x, y;
win = new Fl_Window(410, 0, _("VNC authentication"));
- win->callback(button_cb,(void *)0);
+ win->callback(button_cb, 0);
banner = new Fl_Box(0, 0, win->w(), 20);
banner->align(FL_ALIGN_CENTER|FL_ALIGN_INSIDE|FL_ALIGN_IMAGE_NEXT_TO_TEXT);
banner->box(FL_FLAT_BOX);
- if (secure) {
+ if (secure_) {
banner->label(_("This connection is secure"));
banner->color(FL_GREEN);
banner->image(secure_icon);
@@ -156,7 +156,7 @@ void UserDialog::getUserPasswd(bool secure, std::string* user,
* Compiler is not bright enough to understand that
* username won't be used further down...
*/
- username = NULL;
+ username = nullptr;
}
y += INPUT_LABEL_OFFSET;
@@ -171,12 +171,12 @@ void UserDialog::getUserPasswd(bool secure, std::string* user,
x -= BUTTON_WIDTH;
button = new Fl_Return_Button(x, y, BUTTON_WIDTH,
BUTTON_HEIGHT, fl_ok);
- button->callback(button_cb, (void*)0);
+ button->callback(button_cb, 0);
x -= INNER_MARGIN;
x -= BUTTON_WIDTH;
button = new Fl_Button(x, y, BUTTON_WIDTH, BUTTON_HEIGHT, fl_cancel);
- button->callback(button_cb, (void*)1);
+ button->callback(button_cb, 1);
button->shortcut(FL_Escape);
x -= INNER_MARGIN;
@@ -221,9 +221,9 @@ bool UserDialog::showMsgBox(int flags, const char* title, const char* text)
switch (flags & 0xf) {
case M_OKCANCEL:
- return fl_choice("%s", NULL, fl_ok, fl_cancel, buffer) == 1;
+ return fl_choice("%s", nullptr, fl_ok, fl_cancel, buffer) == 1;
case M_YESNO:
- return fl_choice("%s", NULL, fl_yes, fl_no, buffer) == 1;
+ return fl_choice("%s", nullptr, fl_yes, fl_no, buffer) == 1;
case M_OK:
default:
if (((flags & 0xf0) == M_ICONERROR) ||
diff --git a/vncviewer/UserDialog.h b/vncviewer/UserDialog.h
index 913af841..db4e7c45 100644
--- a/vncviewer/UserDialog.h
+++ b/vncviewer/UserDialog.h
@@ -32,11 +32,11 @@ public:
// UserPasswdGetter callbacks
void getUserPasswd(bool secure, std::string* user,
- std::string* password);
+ std::string* password) override;
// UserMsgBox callbacks
- bool showMsgBox(int flags, const char* title, const char* text);
+ bool showMsgBox(int flags, const char* title, const char* text) override;
};
#endif
diff --git a/vncviewer/Viewport.cxx b/vncviewer/Viewport.cxx
index 5dd5f7ef..032fd322 100644
--- a/vncviewer/Viewport.cxx
+++ b/vncviewer/Viewport.cxx
@@ -116,13 +116,13 @@ static const WORD SCAN_FAKE = 0xaa;
#endif
Viewport::Viewport(int w, int h, const rfb::PixelFormat& /*serverPF*/, CConn* cc_)
- : Fl_Widget(0, 0, w, h), cc(cc_), frameBuffer(NULL),
+ : Fl_Widget(0, 0, w, h), cc(cc_), frameBuffer(nullptr),
lastPointerPos(0, 0), lastButtonMask(0),
#ifdef WIN32
altGrArmed(false),
#endif
firstLEDState(true), pendingClientClipboard(false),
- menuCtrlKey(false), menuAltKey(false), cursor(NULL)
+ menuCtrlKey(false), menuAltKey(false), cursor(nullptr)
{
#if !defined(WIN32) && !defined(__APPLE__)
XkbDescPtr xkb;
@@ -188,7 +188,7 @@ Viewport::Viewport(int w, int h, const rfb::PixelFormat& /*serverPF*/, CConn* cc
OptionsDialog::addCallback(handleOptions, this);
// Make sure we have an initial blank cursor set
- setCursor(0, 0, rfb::Point(0, 0), NULL);
+ setCursor(0, 0, rfb::Point(0, 0), nullptr);
}
@@ -329,9 +329,9 @@ void Viewport::handleClipboardData(const char* data)
Fl::copy(data, len, 1);
}
-void Viewport::setLEDState(unsigned int state)
+void Viewport::setLEDState(unsigned int ledState)
{
- vlog.debug("Got server LED state: 0x%08x", state);
+ vlog.debug("Got server LED state: 0x%08x", ledState);
// The first message is just considered to be the server announcing
// support for this extension. We will push our state to sync up the
@@ -355,7 +355,7 @@ void Viewport::setLEDState(unsigned int state)
memset(input, 0, sizeof(input));
count = 0;
- if (!!(state & ledCapsLock) != !!(GetKeyState(VK_CAPITAL) & 0x1)) {
+ if (!!(ledState & ledCapsLock) != !!(GetKeyState(VK_CAPITAL) & 0x1)) {
input[count].type = input[count+1].type = INPUT_KEYBOARD;
input[count].ki.wVk = input[count+1].ki.wVk = VK_CAPITAL;
input[count].ki.wScan = input[count+1].ki.wScan = SCAN_FAKE;
@@ -364,7 +364,7 @@ void Viewport::setLEDState(unsigned int state)
count += 2;
}
- if (!!(state & ledNumLock) != !!(GetKeyState(VK_NUMLOCK) & 0x1)) {
+ if (!!(ledState & ledNumLock) != !!(GetKeyState(VK_NUMLOCK) & 0x1)) {
input[count].type = input[count+1].type = INPUT_KEYBOARD;
input[count].ki.wVk = input[count+1].ki.wVk = VK_NUMLOCK;
input[count].ki.wScan = input[count+1].ki.wScan = SCAN_FAKE;
@@ -373,7 +373,7 @@ void Viewport::setLEDState(unsigned int state)
count += 2;
}
- if (!!(state & ledScrollLock) != !!(GetKeyState(VK_SCROLL) & 0x1)) {
+ if (!!(ledState & ledScrollLock) != !!(GetKeyState(VK_SCROLL) & 0x1)) {
input[count].type = input[count+1].type = INPUT_KEYBOARD;
input[count].ki.wVk = input[count+1].ki.wVk = VK_SCROLL;
input[count].ki.wScan = input[count+1].ki.wScan = SCAN_FAKE;
@@ -391,13 +391,13 @@ void Viewport::setLEDState(unsigned int state)
#elif defined(__APPLE__)
int ret;
- ret = cocoa_set_caps_lock_state(state & ledCapsLock);
+ ret = cocoa_set_caps_lock_state(ledState & ledCapsLock);
if (ret != 0) {
vlog.error(_("Failed to update keyboard LED state: %d"), ret);
return;
}
- ret = cocoa_set_num_lock_state(state & ledNumLock);
+ ret = cocoa_set_num_lock_state(ledState & ledNumLock);
if (ret != 0) {
vlog.error(_("Failed to update keyboard LED state: %d"), ret);
return;
@@ -414,17 +414,17 @@ void Viewport::setLEDState(unsigned int state)
affect = values = 0;
affect |= LockMask;
- if (state & ledCapsLock)
+ if (ledState & ledCapsLock)
values |= LockMask;
mask = getModifierMask(XK_Num_Lock);
affect |= mask;
- if (state & ledNumLock)
+ if (ledState & ledNumLock)
values |= mask;
mask = getModifierMask(XK_Scroll_Lock);
affect |= mask;
- if (state & ledScrollLock)
+ if (ledState & ledScrollLock)
values |= mask;
ret = XkbLockModifiers(fl_display, XkbUseCoreKbd, affect, values);
@@ -435,21 +435,21 @@ void Viewport::setLEDState(unsigned int state)
void Viewport::pushLEDState()
{
- unsigned int state;
+ unsigned int ledState;
// Server support?
if (cc->server.ledState() == ledUnknown)
return;
- state = 0;
+ ledState = 0;
#if defined(WIN32)
if (GetKeyState(VK_CAPITAL) & 0x1)
- state |= ledCapsLock;
+ ledState |= ledCapsLock;
if (GetKeyState(VK_NUMLOCK) & 0x1)
- state |= ledNumLock;
+ ledState |= ledNumLock;
if (GetKeyState(VK_SCROLL) & 0x1)
- state |= ledScrollLock;
+ ledState |= ledScrollLock;
#elif defined(__APPLE__)
int ret;
bool on;
@@ -460,7 +460,7 @@ void Viewport::pushLEDState()
return;
}
if (on)
- state |= ledCapsLock;
+ ledState |= ledCapsLock;
ret = cocoa_get_num_lock_state(&on);
if (ret != 0) {
@@ -468,10 +468,10 @@ void Viewport::pushLEDState()
return;
}
if (on)
- state |= ledNumLock;
+ ledState |= ledNumLock;
// No support for Scroll Lock //
- state |= (cc->server.ledState() & ledScrollLock);
+ ledState |= (cc->server.ledState() & ledScrollLock);
#else
unsigned int mask;
@@ -486,28 +486,28 @@ void Viewport::pushLEDState()
}
if (xkbState.locked_mods & LockMask)
- state |= ledCapsLock;
+ ledState |= ledCapsLock;
mask = getModifierMask(XK_Num_Lock);
if (xkbState.locked_mods & mask)
- state |= ledNumLock;
+ ledState |= ledNumLock;
mask = getModifierMask(XK_Scroll_Lock);
if (xkbState.locked_mods & mask)
- state |= ledScrollLock;
+ ledState |= ledScrollLock;
#endif
- if ((state & ledCapsLock) != (cc->server.ledState() & ledCapsLock)) {
+ if ((ledState & ledCapsLock) != (cc->server.ledState() & ledCapsLock)) {
vlog.debug("Inserting fake CapsLock to get in sync with server");
handleKeyPress(0x3a, XK_Caps_Lock);
handleKeyRelease(0x3a);
}
- if ((state & ledNumLock) != (cc->server.ledState() & ledNumLock)) {
+ if ((ledState & ledNumLock) != (cc->server.ledState() & ledNumLock)) {
vlog.debug("Inserting fake NumLock to get in sync with server");
handleKeyPress(0x45, XK_Num_Lock);
handleKeyRelease(0x45);
}
- if ((state & ledScrollLock) != (cc->server.ledState() & ledScrollLock)) {
+ if ((ledState & ledScrollLock) != (cc->server.ledState() & ledScrollLock)) {
vlog.debug("Inserting fake ScrollLock to get in sync with server");
handleKeyPress(0x46, XK_Scroll_Lock);
handleKeyRelease(0x46);
@@ -702,7 +702,7 @@ unsigned int Viewport::getModifierMask(unsigned int keysym)
mask = 0;
xkb = XkbGetMap(fl_display, XkbAllComponentsMask, XkbUseCoreKbd);
- if (xkb == NULL)
+ if (xkb == nullptr)
return 0;
for (keycode = xkb->min_key_code; keycode <= xkb->max_key_code; keycode++) {
@@ -722,7 +722,7 @@ unsigned int Viewport::getModifierMask(unsigned int keysym)
goto out;
act = XkbKeyAction(xkb, keycode, 0);
- if (act == NULL)
+ if (act == nullptr)
goto out;
if (act->type != XkbSA_LockMods)
goto out;
@@ -1164,7 +1164,7 @@ int Viewport::handleSystemEvent(void *event, void *data)
if (keycode == 0)
keycode = 0x100 | xevent->xkey.keycode;
- XLookupString(&xevent->xkey, &str, 1, &keysym, NULL);
+ XLookupString(&xevent->xkey, &str, 1, &keysym, nullptr);
if (keysym == NoSymbol) {
vlog.error(_("No symbol for key code %d (in the current state)"),
(int)xevent->xkey.keycode);
@@ -1222,52 +1222,56 @@ void Viewport::resolveAltGrDetection(bool isAltGrSequence)
}
#endif
+// FIXME: gcc confuses ID_DISCONNECT with NULL
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
void Viewport::initContextMenu()
{
contextMenu->clear();
fltk_menu_add(contextMenu, p_("ContextMenu|", "Disconn&ect"),
- 0, NULL, (void*)ID_DISCONNECT, FL_MENU_DIVIDER);
+ 0, nullptr, (void*)ID_DISCONNECT, FL_MENU_DIVIDER);
fltk_menu_add(contextMenu, p_("ContextMenu|", "&Full screen"),
- 0, NULL, (void*)ID_FULLSCREEN,
+ 0, nullptr, (void*)ID_FULLSCREEN,
FL_MENU_TOGGLE | (window()->fullscreen_active()?FL_MENU_VALUE:0));
fltk_menu_add(contextMenu, p_("ContextMenu|", "Minimi&ze"),
- 0, NULL, (void*)ID_MINIMIZE, 0);
+ 0, nullptr, (void*)ID_MINIMIZE, 0);
fltk_menu_add(contextMenu, p_("ContextMenu|", "Resize &window to session"),
- 0, NULL, (void*)ID_RESIZE,
+ 0, nullptr, (void*)ID_RESIZE,
(window()->fullscreen_active()?FL_MENU_INACTIVE:0) |
FL_MENU_DIVIDER);
fltk_menu_add(contextMenu, p_("ContextMenu|", "&Ctrl"),
- 0, NULL, (void*)ID_CTRL,
+ 0, nullptr, (void*)ID_CTRL,
FL_MENU_TOGGLE | (menuCtrlKey?FL_MENU_VALUE:0));
fltk_menu_add(contextMenu, p_("ContextMenu|", "&Alt"),
- 0, NULL, (void*)ID_ALT,
+ 0, nullptr, (void*)ID_ALT,
FL_MENU_TOGGLE | (menuAltKey?FL_MENU_VALUE:0));
if (menuKeySym) {
char sendMenuKey[64];
snprintf(sendMenuKey, 64, p_("ContextMenu|", "Send %s"), (const char *)menuKey);
- fltk_menu_add(contextMenu, sendMenuKey, 0, NULL, (void*)ID_MENUKEY, 0);
- fltk_menu_add(contextMenu, "Secret shortcut menu key", menuKeyFLTK, NULL,
+ fltk_menu_add(contextMenu, sendMenuKey, 0, nullptr, (void*)ID_MENUKEY, 0);
+ fltk_menu_add(contextMenu, "Secret shortcut menu key",
+ menuKeyFLTK, nullptr,
(void*)ID_MENUKEY, FL_MENU_INVISIBLE);
}
fltk_menu_add(contextMenu, p_("ContextMenu|", "Send Ctrl-Alt-&Del"),
- 0, NULL, (void*)ID_CTRLALTDEL, FL_MENU_DIVIDER);
+ 0, nullptr, (void*)ID_CTRLALTDEL, FL_MENU_DIVIDER);
fltk_menu_add(contextMenu, p_("ContextMenu|", "&Refresh screen"),
- 0, NULL, (void*)ID_REFRESH, FL_MENU_DIVIDER);
+ 0, nullptr, (void*)ID_REFRESH, FL_MENU_DIVIDER);
fltk_menu_add(contextMenu, p_("ContextMenu|", "&Options..."),
- 0, NULL, (void*)ID_OPTIONS, 0);
+ 0, nullptr, (void*)ID_OPTIONS, 0);
fltk_menu_add(contextMenu, p_("ContextMenu|", "Connection &info..."),
- 0, NULL, (void*)ID_INFO, 0);
+ 0, nullptr, (void*)ID_INFO, 0);
fltk_menu_add(contextMenu, p_("ContextMenu|", "About &TigerVNC viewer..."),
- 0, NULL, (void*)ID_ABOUT, 0);
+ 0, nullptr, (void*)ID_ABOUT, 0);
}
-
+#pragma GCC diagnostic pop
void Viewport::popupContextMenu()
{
@@ -1297,7 +1301,7 @@ void Viewport::popupContextMenu()
if (Fl::belowmouse())
window()->cursor(cursor, cursorHotspot.x, cursorHotspot.y);
- if (m == NULL)
+ if (m == nullptr)
return;
switch (m->argument()) {
diff --git a/vncviewer/Viewport.h b/vncviewer/Viewport.h
index 4b674aa1..d936c708 100644
--- a/vncviewer/Viewport.h
+++ b/vncviewer/Viewport.h
@@ -63,14 +63,14 @@ public:
// Fl_Widget callback methods
- void draw();
+ void draw() override;
- void resize(int x, int y, int w, int h);
+ void resize(int x, int y, int w, int h) override;
- int handle(int event);
+ int handle(int event) override;
protected:
- virtual void sendPointerEvent(const rfb::Point& pos, int buttonMask);
+ void sendPointerEvent(const rfb::Point& pos, int buttonMask) override;
private:
bool hasFocus();
diff --git a/vncviewer/Win32TouchHandler.cxx b/vncviewer/Win32TouchHandler.cxx
index d6dc7aa4..e21768f9 100644
--- a/vncviewer/Win32TouchHandler.cxx
+++ b/vncviewer/Win32TouchHandler.cxx
@@ -37,13 +37,13 @@ static const DWORD MOUSEMOVE_FLAGS = MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE |
static const unsigned SINGLE_PAN_THRESHOLD = 50;
-Win32TouchHandler::Win32TouchHandler(HWND hWnd) :
- hWnd(hWnd), gesturesConfigured(false), gestureActive(false),
+Win32TouchHandler::Win32TouchHandler(HWND hWnd_) :
+ hWnd(hWnd_), gesturesConfigured(false), gestureActive(false),
ignoringGesture(false), fakeButtonMask(0)
{
// If window is registered as touch we can not receive gestures,
// this should not happen
- if (IsTouchWindow(hWnd, NULL))
+ if (IsTouchWindow(hWnd, nullptr))
throw rfb::Exception(_("Window is registered for touch instead of gestures"));
// We will not receive any touch/gesture events if this service
diff --git a/vncviewer/Win32TouchHandler.h b/vncviewer/Win32TouchHandler.h
index 05039c88..a0554ccd 100644
--- a/vncviewer/Win32TouchHandler.h
+++ b/vncviewer/Win32TouchHandler.h
@@ -35,11 +35,11 @@ class Win32TouchHandler: public BaseTouchHandler {
bool isSinglePan(GESTUREINFO gi);
protected:
- virtual void fakeMotionEvent(const GestureEvent origEvent);
- virtual void fakeButtonEvent(bool press, int button,
- const GestureEvent origEvent);
- virtual void fakeKeyEvent(bool press, int keycode,
- const GestureEvent origEvent);
+ void fakeMotionEvent(const GestureEvent origEvent) override;
+ void fakeButtonEvent(bool press, int button,
+ const GestureEvent origEvent) override;
+ void fakeKeyEvent(bool press, int keycode,
+ const GestureEvent origEvent) override;
private:
void pushFakeEvent(UINT Msg, WPARAM wParam, LPARAM lParam);
diff --git a/vncviewer/XInputTouchHandler.cxx b/vncviewer/XInputTouchHandler.cxx
index 6203bda5..2b2e02c6 100644
--- a/vncviewer/XInputTouchHandler.cxx
+++ b/vncviewer/XInputTouchHandler.cxx
@@ -43,8 +43,8 @@ static rfb::LogWriter vlog("XInputTouchHandler");
static bool grabbed = false;
-XInputTouchHandler::XInputTouchHandler(Window wnd)
- : wnd(wnd), fakeStateMask(0)
+XInputTouchHandler::XInputTouchHandler(Window wnd_)
+ : wnd(wnd_), fakeStateMask(0)
{
XIEventMask eventmask;
unsigned char flags[XIMaskLen(XI_LASTEVENT)] = { 0 };
@@ -97,7 +97,7 @@ bool XInputTouchHandler::grabPointer()
// We grab for the same events as the window is currently interested in
curmasks = XIGetSelectedEvents(fl_display, wnd, &num_masks);
- if (curmasks == NULL) {
+ if (curmasks == nullptr) {
if (num_masks == -1)
vlog.error(_("Unable to get X Input 2 event mask for window 0x%08lx"), wnd);
else
@@ -314,7 +314,7 @@ void XInputTouchHandler::preparePointerEvent(XEvent* dst, const GestureEvent src
{
Window root, child;
int rootX, rootY;
- XkbStateRec state;
+ XkbStateRec xkbState;
// We don't have a real event to steal things from, so we'll have
// to fake these events based on the current state of things
@@ -324,7 +324,7 @@ void XInputTouchHandler::preparePointerEvent(XEvent* dst, const GestureEvent src
src.eventX,
src.eventY,
&rootX, &rootY, &child);
- XkbGetState(fl_display, XkbUseCoreKbd, &state);
+ XkbGetState(fl_display, XkbUseCoreKbd, &xkbState);
// XButtonEvent and XMotionEvent are almost identical, so we
// don't have to care which it is for these fields
@@ -338,8 +338,8 @@ void XInputTouchHandler::preparePointerEvent(XEvent* dst, const GestureEvent src
dst->xbutton.y = src.eventY;
dst->xbutton.x_root = rootX;
dst->xbutton.y_root = rootY;
- dst->xbutton.state = state.mods;
- dst->xbutton.state |= ((state.ptr_buttons >> 1) & 0x1f) << 8;
+ dst->xbutton.state = xkbState.mods;
+ dst->xbutton.state |= ((xkbState.ptr_buttons >> 1) & 0x1f) << 8;
dst->xbutton.same_screen = True;
}
@@ -390,7 +390,7 @@ void XInputTouchHandler::fakeKeyEvent(bool press, int keysym,
Window root, child;
int rootX, rootY;
- XkbStateRec state;
+ XkbStateRec xkbState;
int modmask;
@@ -399,7 +399,7 @@ void XInputTouchHandler::fakeKeyEvent(bool press, int keysym,
origEvent.eventX,
origEvent.eventY,
&rootX, &rootY, &child);
- XkbGetState(fl_display, XkbUseCoreKbd, &state);
+ XkbGetState(fl_display, XkbUseCoreKbd, &xkbState);
KeyCode kc = XKeysymToKeycode(fl_display, keysym);
@@ -418,8 +418,8 @@ void XInputTouchHandler::fakeKeyEvent(bool press, int keysym,
fakeEvent.xkey.y = origEvent.eventY;
fakeEvent.xkey.x_root = rootX;
fakeEvent.xkey.y_root = rootY;
- fakeEvent.xkey.state = state.mods;
- fakeEvent.xkey.state |= ((state.ptr_buttons >> 1) & 0x1f) << 8;
+ fakeEvent.xkey.state = xkbState.mods;
+ fakeEvent.xkey.state |= ((xkbState.ptr_buttons >> 1) & 0x1f) << 8;
fakeEvent.xkey.same_screen = True;
// Apply our fake mask
diff --git a/vncviewer/XInputTouchHandler.h b/vncviewer/XInputTouchHandler.h
index 6360b974..897c55ae 100644
--- a/vncviewer/XInputTouchHandler.h
+++ b/vncviewer/XInputTouchHandler.h
@@ -39,13 +39,13 @@ class XInputTouchHandler: public BaseTouchHandler, GestureHandler {
const XIDeviceEvent* origEvent);
void preparePointerEvent(XEvent* dst, const GestureEvent src);
- virtual void fakeMotionEvent(const GestureEvent origEvent);
- virtual void fakeButtonEvent(bool press, int button,
- const GestureEvent origEvent);
- virtual void fakeKeyEvent(bool press, int keycode,
- const GestureEvent origEvent);
+ void fakeMotionEvent(const GestureEvent origEvent) override;
+ void fakeButtonEvent(bool press, int button,
+ const GestureEvent origEvent) override;
+ void fakeKeyEvent(bool press, int keycode,
+ const GestureEvent origEvent) override;
- virtual void handleGestureEvent(const GestureEvent& event);
+ void handleGestureEvent(const GestureEvent& event) override;
private:
void pushFakeEvent(XEvent* event);
diff --git a/vncviewer/cocoa.mm b/vncviewer/cocoa.mm
index d801a106..a355b484 100644
--- a/vncviewer/cocoa.mm
+++ b/vncviewer/cocoa.mm
@@ -301,7 +301,7 @@ static NSString *key_translate(UInt16 keyCode, UInt32 modifierFlags)
const UCKeyboardLayout *layout;
OSStatus err;
- layout = NULL;
+ layout = nullptr;
TISInputSourceRef keyboard;
CFDataRef uchr;
@@ -309,11 +309,11 @@ static NSString *key_translate(UInt16 keyCode, UInt32 modifierFlags)
keyboard = TISCopyCurrentKeyboardLayoutInputSource();
uchr = (CFDataRef)TISGetInputSourceProperty(keyboard,
kTISPropertyUnicodeKeyLayoutData);
- if (uchr == NULL)
+ if (uchr == nullptr)
return nil;
layout = (const UCKeyboardLayout*)CFDataGetBytePtr(uchr);
- if (layout == NULL)
+ if (layout == nullptr)
return nil;
UInt32 dead_state;
diff --git a/vncviewer/fltk/Fl_Monitor_Arrangement.cxx b/vncviewer/fltk/Fl_Monitor_Arrangement.cxx
index 7c72ff68..02011e1f 100644
--- a/vncviewer/fltk/Fl_Monitor_Arrangement.cxx
+++ b/vncviewer/fltk/Fl_Monitor_Arrangement.cxx
@@ -379,7 +379,7 @@ std::string Fl_Monitor_Arrangement::get_monitor_name(int m)
Fl::screen_xywh(x, y, w, h, m);
- EnumDisplayMonitors(NULL, NULL, EnumDisplayMonitorsCallback,
+ EnumDisplayMonitors(nullptr, nullptr, EnumDisplayMonitorsCallback,
(LPARAM)&sys_monitors);
for (iter = sys_monitors.begin(); iter != sys_monitors.end(); ++iter) {
@@ -441,11 +441,11 @@ std::string Fl_Monitor_Arrangement::get_monitor_name(int m)
info = IODisplayCreateInfoDictionary(CGDisplayIOServicePort(displayID),
kIODisplayOnlyPreferredName);
- if (info == NULL)
+ if (info == nullptr)
return "";
dict = (CFDictionaryRef) CFDictionaryGetValue(info, CFSTR(kDisplayProductName));
- if (dict == NULL) {
+ if (dict == nullptr) {
CFRelease(info);
return "";
}
@@ -454,7 +454,7 @@ std::string Fl_Monitor_Arrangement::get_monitor_name(int m)
if (dict_len > 0) {
CFTypeRef * names = new CFTypeRef[dict_len];
- CFDictionaryGetKeysAndValues(dict, NULL, (const void **) names);
+ CFDictionaryGetKeysAndValues(dict, nullptr, (const void **) names);
if (names[0]) {
@@ -496,7 +496,7 @@ std::string Fl_Monitor_Arrangement::get_monitor_name(int m)
std::string name;
fl_open_display();
- assert(fl_display != NULL);
+ assert(fl_display != nullptr);
Fl::screen_xywh(x, y, w, h, m);
if (!XQueryExtension(fl_display, "RANDR", &xi_major, &ev, &err))
diff --git a/vncviewer/fltk/Fl_Monitor_Arrangement.h b/vncviewer/fltk/Fl_Monitor_Arrangement.h
index c71dd199..d8bf582b 100644
--- a/vncviewer/fltk/Fl_Monitor_Arrangement.h
+++ b/vncviewer/fltk/Fl_Monitor_Arrangement.h
@@ -45,7 +45,7 @@ public:
int value(std::set<int> indices);
protected:
- virtual void draw();
+ void draw() override;
private:
const Fl_Color AVAILABLE_COLOR;
diff --git a/vncviewer/fltk/Fl_Navigation.cxx b/vncviewer/fltk/Fl_Navigation.cxx
index 603c69ce..d3117aae 100644
--- a/vncviewer/fltk/Fl_Navigation.cxx
+++ b/vncviewer/fltk/Fl_Navigation.cxx
@@ -72,7 +72,7 @@ Fl_Widget *Fl_Navigation::value()
return pages->child(i);
}
- return NULL;
+ return nullptr;
}
int Fl_Navigation::value(Fl_Widget *newpage)
@@ -145,7 +145,7 @@ void Fl_Navigation::update_labels()
int i, offset;
labels->clear();
- labels->resizable(NULL);
+ labels->resizable(nullptr);
if (!pages->children())
return;
diff --git a/vncviewer/fltk/Fl_Navigation.h b/vncviewer/fltk/Fl_Navigation.h
index 7f5e44ac..44515691 100644
--- a/vncviewer/fltk/Fl_Navigation.h
+++ b/vncviewer/fltk/Fl_Navigation.h
@@ -38,7 +38,7 @@ public:
void client_area(int &rx, int &ry, int &rw, int &rh, int lw);
- virtual void draw();
+ void draw() override;
// Delegation to underlying widget
void begin();
diff --git a/vncviewer/fltk/theme.cxx b/vncviewer/fltk/theme.cxx
index 22e04dc6..2b37fb6e 100644
--- a/vncviewer/fltk/theme.cxx
+++ b/vncviewer/fltk/theme.cxx
@@ -313,10 +313,10 @@ void init_theme()
CTFontRef font;
CFStringRef name;
- font = CTFontCreateUIFontForLanguage(kCTFontSystemFontType, 0.0, NULL);
- if (font != NULL) {
+ font = CTFontCreateUIFontForLanguage(kCTFontSystemFontType, 0.0, nullptr);
+ if (font != nullptr) {
name = CTFontCopyFullName(font);
- if (name != NULL) {
+ if (name != nullptr) {
CFStringGetCString(name, font_name, sizeof(font_name),
kCFStringEncodingUTF8);
diff --git a/vncviewer/fltk/util.h b/vncviewer/fltk/util.h
index 87765396..9ce3c7aa 100644
--- a/vncviewer/fltk/util.h
+++ b/vncviewer/fltk/util.h
@@ -97,7 +97,7 @@ static inline size_t fltk_menu_escape(const char *in, char *out, size_t maxlen)
/* Helper to add menu entries safely */
static inline void fltk_menu_add(Fl_Menu_ *menu, const char *text,
int shortcut, Fl_Callback *cb,
- void *data = 0, int flags = 0)
+ void *data=nullptr, int flags=0)
{
char buffer[1024];
diff --git a/vncviewer/gettext.h b/vncviewer/gettext.h
index 768a6995..09473d97 100644
--- a/vncviewer/gettext.h
+++ b/vncviewer/gettext.h
@@ -120,7 +120,7 @@
pgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
#else
# define pgettext(Msgctxt, Msgid) \
- pgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
+ pgettext_aux (nullptr, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
#endif
#define dpgettext(Domainname, Msgctxt, Msgid) \
pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
@@ -131,7 +131,7 @@
npgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
#else
# define npgettext(Msgctxt, Msgid, MsgidPlural, N) \
- npgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
+ npgettext_aux (nullptr, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
#endif
#define dnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
@@ -197,7 +197,7 @@ npgettext_aux (const char *domain,
#endif
#define pgettext_expr(Msgctxt, Msgid) \
- dcpgettext_expr (NULL, Msgctxt, Msgid, LC_MESSAGES)
+ dcpgettext_expr (nullptr, Msgctxt, Msgid, LC_MESSAGES)
#define dpgettext_expr(Domainname, Msgctxt, Msgid) \
dcpgettext_expr (Domainname, Msgctxt, Msgid, LC_MESSAGES)
@@ -224,7 +224,7 @@ dcpgettext_expr (const char *domain,
(msgctxt_len + msgid_len <= sizeof (buf)
? buf
: (char *) malloc (msgctxt_len + msgid_len));
- if (msg_ctxt_id != NULL)
+ if (msg_ctxt_id != nullptr)
#endif
{
int found_translation;
@@ -244,7 +244,7 @@ dcpgettext_expr (const char *domain,
}
#define npgettext_expr(Msgctxt, Msgid, MsgidPlural, N) \
- dcnpgettext_expr (NULL, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
+ dcnpgettext_expr (nullptr, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
#define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
dcnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
@@ -272,7 +272,7 @@ dcnpgettext_expr (const char *domain,
(msgctxt_len + msgid_len <= sizeof (buf)
? buf
: (char *) malloc (msgctxt_len + msgid_len));
- if (msg_ctxt_id != NULL)
+ if (msg_ctxt_id != nullptr)
#endif
{
int found_translation;
diff --git a/vncviewer/parameters.cxx b/vncviewer/parameters.cxx
index 15ea4ee8..a03623db 100644
--- a/vncviewer/parameters.cxx
+++ b/vncviewer/parameters.cxx
@@ -214,7 +214,7 @@ static VoidParameter* readOnlyParameterArray[] = {
};
// Encoding Table
-static struct {
+static const struct EscapeMap {
const char first;
const char second;
} replaceMap[] = { { '\n', 'n' },
@@ -230,15 +230,15 @@ static bool encodeValue(const char* val, char* dest, size_t destSize) {
// Check for sequences which will need encoding
normalCharacter = true;
- for (size_t j = 0; j < sizeof(replaceMap)/sizeof(replaceMap[0]); j++) {
+ for (EscapeMap esc : replaceMap) {
- if (val[i] == replaceMap[j].first) {
+ if (val[i] == esc.first) {
dest[pos] = '\\';
pos++;
if (pos >= destSize)
return false;
- dest[pos] = replaceMap[j].second;
+ dest[pos] = esc.second;
normalCharacter = false;
break;
}
@@ -269,9 +269,9 @@ static bool decodeValue(const char* val, char* dest, size_t destSize) {
bool escapedCharacter;
escapedCharacter = false;
- for (size_t j = 0; j < sizeof(replaceMap)/sizeof(replaceMap[0]); j++) {
- if (val[i+1] == replaceMap[j].second) {
- dest[pos] = replaceMap[j].first;
+ for (EscapeMap esc : replaceMap) {
+ if (val[i+1] == esc.second) {
+ dest[pos] = esc.first;
escapedCharacter = true;
i++;
break;
@@ -350,7 +350,7 @@ static bool getKeyString(const char* _name, char* dest, size_t destSize, HKEY* h
value = new WCHAR[destSize];
valuesize = destSize;
- LONG res = RegQueryValueExW(*hKey, name, 0, NULL, (LPBYTE)value, &valuesize);
+ LONG res = RegQueryValueExW(*hKey, name, nullptr, nullptr, (LPBYTE)value, &valuesize);
if (res != ERROR_SUCCESS){
delete [] value;
if (res != ERROR_FILE_NOT_FOUND)
@@ -388,7 +388,7 @@ static bool getKeyInt(const char* _name, int* dest, HKEY* hKey) {
if (size >= buffersize)
throw Exception(_("The name of the parameter is too large"));
- LONG res = RegQueryValueExW(*hKey, name, 0, NULL, (LPBYTE)&value, &dwordsize);
+ LONG res = RegQueryValueExW(*hKey, name, nullptr, nullptr, (LPBYTE)&value, &dwordsize);
if (res != ERROR_SUCCESS){
if (res != ERROR_FILE_NOT_FOUND)
throw rdr::SystemException("RegQueryValueExW", res);
@@ -420,9 +420,9 @@ static void removeValue(const char* _name, HKEY* hKey) {
void saveHistoryToRegKey(const vector<string>& serverHistory) {
HKEY hKey;
LONG res = RegCreateKeyExW(HKEY_CURRENT_USER,
- L"Software\\TigerVNC\\vncviewer\\history", 0, NULL,
- REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
- &hKey, NULL);
+ L"Software\\TigerVNC\\vncviewer\\history", 0, nullptr,
+ REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, nullptr,
+ &hKey, nullptr);
if (res != ERROR_SUCCESS)
throw rdr::SystemException(_("Failed to create registry key"), res);
@@ -452,9 +452,9 @@ static void saveToReg(const char* servername) {
HKEY hKey;
LONG res = RegCreateKeyExW(HKEY_CURRENT_USER,
- L"Software\\TigerVNC\\vncviewer", 0, NULL,
- REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
- &hKey, NULL);
+ L"Software\\TigerVNC\\vncviewer", 0, nullptr,
+ REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, nullptr,
+ &hKey, nullptr);
if (res != ERROR_SUCCESS)
throw rdr::SystemException(_("Failed to create registry key"), res);
@@ -468,11 +468,11 @@ static void saveToReg(const char* servername) {
for (size_t i = 0; i < sizeof(parameterArray)/sizeof(VoidParameter*); i++) {
try {
- if (dynamic_cast<StringParameter*>(parameterArray[i]) != NULL) {
+ if (dynamic_cast<StringParameter*>(parameterArray[i]) != nullptr) {
setKeyString(parameterArray[i]->getName(), *(StringParameter*)parameterArray[i], &hKey);
- } else if (dynamic_cast<IntParameter*>(parameterArray[i]) != NULL) {
+ } else if (dynamic_cast<IntParameter*>(parameterArray[i]) != nullptr) {
setKeyInt(parameterArray[i]->getName(), (int)*(IntParameter*)parameterArray[i], &hKey);
- } else if (dynamic_cast<BoolParameter*>(parameterArray[i]) != NULL) {
+ } else if (dynamic_cast<BoolParameter*>(parameterArray[i]) != nullptr) {
setKeyInt(parameterArray[i]->getName(), (int)*(BoolParameter*)parameterArray[i], &hKey);
} else {
throw Exception(_("Unknown parameter type"));
@@ -553,13 +553,13 @@ static void getParametersFromReg(VoidParameter* parameters[],
for (size_t i = 0; i < parameters_len/sizeof(VoidParameter*); i++) {
try {
- if (dynamic_cast<StringParameter*>(parameters[i]) != NULL) {
+ if (dynamic_cast<StringParameter*>(parameters[i]) != nullptr) {
if (getKeyString(parameters[i]->getName(), stringValue, buffersize, hKey))
parameters[i]->setParam(stringValue);
- } else if (dynamic_cast<IntParameter*>(parameters[i]) != NULL) {
+ } else if (dynamic_cast<IntParameter*>(parameters[i]) != nullptr) {
if (getKeyInt(parameters[i]->getName(), &intValue, hKey))
((IntParameter*)parameters[i])->setParam(intValue);
- } else if (dynamic_cast<BoolParameter*>(parameters[i]) != NULL) {
+ } else if (dynamic_cast<BoolParameter*>(parameters[i]) != nullptr) {
if (getKeyInt(parameters[i]->getName(), &intValue, hKey))
((BoolParameter*)parameters[i])->setParam(intValue);
} else {
@@ -583,7 +583,7 @@ static char* loadFromReg() {
if (res != ERROR_SUCCESS) {
if (res == ERROR_FILE_NOT_FOUND) {
// The key does not exist, defaults will be used.
- return NULL;
+ return nullptr;
}
throw rdr::SystemException(_("Failed to open registry key"), res);
@@ -622,7 +622,7 @@ void saveViewerParameters(const char *filename, const char *servername) {
char encodingBuffer[buffersize];
// Write to the registry or a predefined file if no filename was specified.
- if(filename == NULL) {
+ if(filename == nullptr) {
#ifdef _WIN32
saveToReg(servername);
@@ -630,7 +630,7 @@ void saveViewerParameters(const char *filename, const char *servername) {
#endif
const char* configDir = os::getvncconfigdir();
- if (configDir == NULL)
+ if (configDir == nullptr)
throw Exception(_("Could not obtain the config directory path"));
snprintf(filepath, sizeof(filepath), "%s/default.tigervnc", configDir);
@@ -654,24 +654,24 @@ void saveViewerParameters(const char *filename, const char *servername) {
}
fprintf(f, "ServerName=%s\n", encodingBuffer);
- for (size_t i = 0; i < sizeof(parameterArray)/sizeof(VoidParameter*); i++) {
- if (dynamic_cast<StringParameter*>(parameterArray[i]) != NULL) {
- if (!encodeValue(*(StringParameter*)parameterArray[i],
+ for (VoidParameter* param : parameterArray) {
+ if (dynamic_cast<StringParameter*>(param) != nullptr) {
+ if (!encodeValue(*(StringParameter*)param,
encodingBuffer, buffersize)) {
fclose(f);
throw Exception(_("Failed to save \"%s\": %s"),
- parameterArray[i]->getName(),
+ param->getName(),
_("Could not encode parameter"));
}
- fprintf(f, "%s=%s\n", ((StringParameter*)parameterArray[i])->getName(), encodingBuffer);
- } else if (dynamic_cast<IntParameter*>(parameterArray[i]) != NULL) {
- fprintf(f, "%s=%d\n", ((IntParameter*)parameterArray[i])->getName(), (int)*(IntParameter*)parameterArray[i]);
- } else if (dynamic_cast<BoolParameter*>(parameterArray[i]) != NULL) {
- fprintf(f, "%s=%d\n", ((BoolParameter*)parameterArray[i])->getName(), (int)*(BoolParameter*)parameterArray[i]);
+ fprintf(f, "%s=%s\n", ((StringParameter*)param)->getName(), encodingBuffer);
+ } else if (dynamic_cast<IntParameter*>(param) != nullptr) {
+ fprintf(f, "%s=%d\n", ((IntParameter*)param)->getName(), (int)*(IntParameter*)param);
+ } else if (dynamic_cast<BoolParameter*>(param) != nullptr) {
+ fprintf(f, "%s=%d\n", ((BoolParameter*)param)->getName(), (int)*(BoolParameter*)param);
} else {
fclose(f);
throw Exception(_("Failed to save \"%s\": %s"),
- parameterArray[i]->getName(),
+ param->getName(),
_("Unknown parameter type"));
}
}
@@ -688,7 +688,7 @@ static bool findAndSetViewerParameterFromValue(
// Find and set the correct parameter
for (size_t i = 0; i < parameters_len/sizeof(VoidParameter*); i++) {
- if (dynamic_cast<StringParameter*>(parameters[i]) != NULL) {
+ if (dynamic_cast<StringParameter*>(parameters[i]) != nullptr) {
if (strcasecmp(line, ((StringParameter*)parameters[i])->getName()) == 0) {
if(!decodeValue(value, decodingBuffer, sizeof(decodingBuffer)))
throw Exception(_("Invalid format or too large value"));
@@ -696,13 +696,13 @@ static bool findAndSetViewerParameterFromValue(
return false;
}
- } else if (dynamic_cast<IntParameter*>(parameters[i]) != NULL) {
+ } else if (dynamic_cast<IntParameter*>(parameters[i]) != nullptr) {
if (strcasecmp(line, ((IntParameter*)parameters[i])->getName()) == 0) {
((IntParameter*)parameters[i])->setParam(atoi(value));
return false;
}
- } else if (dynamic_cast<BoolParameter*>(parameters[i]) != NULL) {
+ } else if (dynamic_cast<BoolParameter*>(parameters[i]) != nullptr) {
if (strcasecmp(line, ((BoolParameter*)parameters[i])->getName()) == 0) {
((BoolParameter*)parameters[i])->setParam(atoi(value));
return false;
@@ -727,14 +727,14 @@ char* loadViewerParameters(const char *filename) {
memset(servername, '\0', sizeof(servername));
// Load from the registry or a predefined file if no filename was specified.
- if(filename == NULL) {
+ if(filename == nullptr) {
#ifdef _WIN32
return loadFromReg();
#endif
const char* configDir = os::getvncconfigdir();
- if (configDir == NULL)
+ if (configDir == nullptr)
throw Exception(_("Could not obtain the config directory path"));
snprintf(filepath, sizeof(filepath), "%s/default.tigervnc", configDir);
@@ -746,7 +746,7 @@ char* loadViewerParameters(const char *filename) {
FILE* f = fopen(filepath, "r");
if (!f) {
if (!filename)
- return NULL; // Use defaults.
+ return nullptr; // Use defaults.
throw Exception(_("Could not open \"%s\": %s"),
filepath, strerror(errno));
}
@@ -797,7 +797,7 @@ char* loadViewerParameters(const char *filename) {
// Find the parameter value
char *value = strchr(line, '=');
- if (value == NULL) {
+ if (value == nullptr) {
vlog.error(_("Failed to read line %d in file %s: %s"),
lineNr, filepath, _("Invalid format"));
continue;
@@ -836,7 +836,8 @@ char* loadViewerParameters(const char *filename) {
vlog.error(_("Failed to read line %d in file %s: %s"),
lineNr, filepath, _("Unknown parameter"));
}
- fclose(f); f=0;
-
+ fclose(f);
+ f = nullptr;
+
return servername;
}
diff --git a/vncviewer/parameters.h b/vncviewer/parameters.h
index 1dd9aca2..df7bc420 100644
--- a/vncviewer/parameters.h
+++ b/vncviewer/parameters.h
@@ -80,7 +80,7 @@ extern rfb::BoolParameter reconnectOnError;
extern rfb::StringParameter via;
#endif
-void saveViewerParameters(const char *filename, const char *servername=NULL);
+void saveViewerParameters(const char *filename, const char *servername=nullptr);
char* loadViewerParameters(const char *filename);
#ifdef _WIN32
diff --git a/vncviewer/touch.cxx b/vncviewer/touch.cxx
index d4f4098a..1efd3e46 100644
--- a/vncviewer/touch.cxx
+++ b/vncviewer/touch.cxx
@@ -103,7 +103,7 @@ static void x11_change_touch_ownership(bool enable)
for (iter = handlers.begin(); iter != handlers.end(); ++iter) {
curmasks = XIGetSelectedEvents(fl_display, iter->first, &num_masks);
- if (curmasks == NULL) {
+ if (curmasks == nullptr) {
if (num_masks == -1)
vlog.error(_("Unable to get X Input 2 event mask for window 0x%08lx"), iter->first);
continue;
@@ -267,7 +267,7 @@ void enable_touch()
vlog.error(_("X Input 2.2 (or newer) is not available. Touch gestures will not be supported."));
#endif
- Fl::add_system_handler(handleTouchEvent, NULL);
+ Fl::add_system_handler(handleTouchEvent, nullptr);
}
void disable_touch()
diff --git a/vncviewer/vncviewer.cxx b/vncviewer/vncviewer.cxx
index 366327fa..6ddff947 100644
--- a/vncviewer/vncviewer.cxx
+++ b/vncviewer/vncviewer.cxx
@@ -86,11 +86,11 @@ using namespace rfb;
char vncServerName[VNCSERVERNAMELEN] = { '\0' };
-static const char *argv0 = NULL;
+static const char *argv0 = nullptr;
static bool inMainloop = false;
static bool exitMainloop = false;
-static char *exitError = NULL;
+static char *exitError = nullptr;
static bool fatalError = false;
static const char *about_text()
@@ -117,7 +117,7 @@ void abort_vncviewer(const char *error, ...)
// Prioritise the first error we get as that is probably the most
// relevant one.
- if (exitError == NULL) {
+ if (exitError == nullptr) {
va_list ap;
va_start(ap, error);
@@ -130,7 +130,7 @@ void abort_vncviewer(const char *error, ...)
exitMainloop = true;
else {
// We're early in the startup. Assume we can just exit().
- if (alertOnFatalError && (exitError != NULL))
+ if (alertOnFatalError && (exitError != nullptr))
fl_alert("%s", exitError);
exit(EXIT_FAILURE);
}
@@ -142,7 +142,7 @@ void abort_connection(const char *error, ...)
// Prioritise the first error we get as that is probably the most
// relevant one.
- if (exitError == NULL) {
+ if (exitError == nullptr) {
va_list ap;
va_start(ap, error);
@@ -200,22 +200,22 @@ static void mainloop(const char* vncserver, network::Socket* sock)
delete cc;
if (fatalError) {
- assert(exitError != NULL);
+ assert(exitError != nullptr);
if (alertOnFatalError)
fl_alert("%s", exitError);
break;
}
- if (exitError == NULL)
+ if (exitError == nullptr)
break;
- if(reconnectOnError && (sock == NULL)) {
+ if(reconnectOnError && (sock == nullptr)) {
int ret;
ret = fl_choice(_("%s\n\n"
"Attempt to reconnect?"),
- NULL, fl_yes, fl_no, exitError);
+ nullptr, fl_yes, fl_no, exitError);
free(exitError);
- exitError = NULL;
+ exitError = nullptr;
if (ret == 1)
continue;
else
@@ -250,7 +250,7 @@ static void new_connection_cb(Fl_Widget* /*widget*/, void* /*data*/)
return;
argv[0] = argv0;
- argv[1] = NULL;
+ argv[1] = nullptr;
execvp(argv[0], (char * const *)argv);
@@ -273,16 +273,16 @@ static const char* getlocaledir()
static char localebuf[PATH_MAX];
char *slash;
- GetModuleFileName(NULL, localebuf, sizeof(localebuf));
+ GetModuleFileName(nullptr, localebuf, sizeof(localebuf));
slash = strrchr(localebuf, '\\');
- if (slash == NULL)
- return NULL;
+ if (slash == nullptr)
+ return nullptr;
*slash = '\0';
if ((strlen(localebuf) + strlen("\\locale")) >= sizeof(localebuf))
- return NULL;
+ return nullptr;
strcat(localebuf, "\\locale");
@@ -296,13 +296,13 @@ static const char* getlocaledir()
static char localebuf[PATH_MAX];
bundle = CFBundleGetMainBundle();
- if (bundle == NULL)
- return NULL;
+ if (bundle == nullptr)
+ return nullptr;
localeurl = CFBundleCopyResourceURL(bundle, CFSTR("locale"),
- NULL, NULL);
- if (localeurl == NULL)
- return NULL;
+ nullptr, nullptr);
+ if (localeurl == nullptr)
+ return nullptr;
localestr = CFURLCopyFileSystemPath(localeurl, kCFURLPOSIXPathStyle);
@@ -311,7 +311,7 @@ static const char* getlocaledir()
ret = CFStringGetCString(localestr, localebuf, sizeof(localebuf),
kCFStringEncodingUTF8);
if (!ret)
- return NULL;
+ return nullptr;
return localebuf;
#else
@@ -331,11 +331,13 @@ static void init_fltk()
#ifdef WIN32
HICON lg, sm;
- lg = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON),
+ lg = (HICON)LoadImage(GetModuleHandle(nullptr),
+ MAKEINTRESOURCE(IDI_ICON),
IMAGE_ICON, GetSystemMetrics(SM_CXICON),
GetSystemMetrics(SM_CYICON),
LR_DEFAULTCOLOR | LR_SHARED);
- sm = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON),
+ sm = (HICON)LoadImage(GetModuleHandle(nullptr),
+ MAKEINTRESOURCE(IDI_ICON),
IMAGE_ICON, GetSystemMetrics(SM_CXSMICON),
GetSystemMetrics(SM_CYSMICON),
LR_DEFAULTCOLOR | LR_SHARED);
@@ -350,12 +352,12 @@ static void init_fltk()
count = 0;
// FIXME: Follow icon theme specification
- for (size_t i = 0;i < sizeof(icon_sizes)/sizeof(icon_sizes[0]);i++) {
+ for (int icon_size : icon_sizes) {
char icon_path[PATH_MAX];
bool exists;
sprintf(icon_path, "%s/icons/hicolor/%dx%d/apps/tigervnc.png",
- CMAKE_INSTALL_FULL_DATADIR, icon_sizes[i], icon_sizes[i]);
+ CMAKE_INSTALL_FULL_DATADIR, icon_size, icon_size);
struct stat st;
if (stat(icon_path, &st) != 0)
@@ -412,7 +414,7 @@ static void init_fltk()
Fl_Mac_App_Menu::hide_others = _("Hide Others");
Fl_Mac_App_Menu::show = _("Show All");
- fl_mac_set_about(about_callback, NULL);
+ fl_mac_set_about(about_callback, nullptr);
Fl_Sys_Menu_Bar *menubar;
char buffer[1024];
@@ -421,7 +423,7 @@ static void init_fltk()
// which means we cannot use our generic Fl_Menu_ helpers.
if (fltk_menu_escape(p_("SysMenu|", "&File"),
buffer, sizeof(buffer)) < sizeof(buffer))
- menubar->add(buffer, 0, 0, 0, FL_SUBMENU);
+ menubar->add(buffer, 0, nullptr, nullptr, FL_SUBMENU);
if (fltk_menu_escape(p_("SysMenu|File|", "&New Connection"),
buffer, sizeof(buffer)) < sizeof(buffer))
menubar->insert(1, buffer, FL_COMMAND | 'n', new_connection_cb);
@@ -432,7 +434,7 @@ static void usage(const char *programName)
{
#ifdef WIN32
// If we don't have a console then we need to create one for output
- if (GetConsoleWindow() == NULL) {
+ if (GetConsoleWindow() == nullptr) {
HANDLE handle;
int fd;
@@ -485,17 +487,17 @@ static void usage(const char *programName)
}
static void
-potentiallyLoadConfigurationFile(char *vncServerName)
+potentiallyLoadConfigurationFile(const char *filename)
{
- const bool hasPathSeparator = (strchr(vncServerName, '/') != NULL ||
- (strchr(vncServerName, '\\')) != NULL);
+ const bool hasPathSeparator = (strchr(filename, '/') != nullptr ||
+ (strchr(filename, '\\')) != nullptr);
if (hasPathSeparator) {
#ifndef WIN32
struct stat sb;
// This might be a UNIX socket, we need to check
- if (stat(vncServerName, &sb) == -1) {
+ if (stat(filename, &sb) == -1) {
// Some access problem; let loadViewerParameters() deal with it...
} else {
if ((sb.st_mode & S_IFMT) == S_IFSOCK)
@@ -505,7 +507,7 @@ potentiallyLoadConfigurationFile(char *vncServerName)
try {
const char* newServerName;
- newServerName = loadViewerParameters(vncServerName);
+ newServerName = loadViewerParameters(filename);
// This might be empty, but we still need to clear it so we
// don't try to connect to the filename
strncpy(vncServerName, newServerName, VNCSERVERNAMELEN-1);
@@ -534,7 +536,7 @@ interpretViaParam(char *remoteHost, int *remotePort, int localPort)
{
const int SERVER_PORT_OFFSET = 5900;
char *pos = strchr(vncServerName, ':');
- if (pos == NULL)
+ if (pos == nullptr)
*remotePort = SERVER_PORT_OFFSET;
else {
int portOffset = SERVER_PORT_OFFSET;
@@ -580,7 +582,7 @@ createTunnel(const char *gatewayHost, const char *remoteHost,
cmd = "/usr/bin/ssh -f -L \"$L\":\"$H\":\"$R\" \"$G\" sleep 20";
/* Compatibility with TigerVNC's method. */
cmd2 = strdup(cmd);
- while ((percent = strchr(cmd2, '%')) != NULL)
+ while ((percent = strchr(cmd2, '%')) != nullptr)
*percent = '$';
system(cmd2);
free(cmd2);
@@ -612,7 +614,7 @@ int main(int argc, char** argv)
setlocale(LC_ALL, "");
localedir = getlocaledir();
- if (localedir == NULL)
+ if (localedir == nullptr)
fprintf(stderr, "Failed to determine locale directory\n");
else
bindtextdomain(PACKAGE_NAME, localedir);
@@ -647,8 +649,8 @@ int main(int argc, char** argv)
char defaultServerName[VNCSERVERNAMELEN] = "";
try {
const char* configServerName;
- configServerName = loadViewerParameters(NULL);
- if (configServerName != NULL) {
+ configServerName = loadViewerParameters(nullptr);
+ if (configServerName != nullptr) {
strncpy(defaultServerName, configServerName, VNCSERVERNAMELEN-1);
defaultServerName[VNCSERVERNAMELEN-1] = '\0';
}
@@ -662,8 +664,8 @@ int main(int argc, char** argv)
VoidParameter *param;
param = Configuration::getParam(&argv[i][1]);
- if ((param != NULL) &&
- (dynamic_cast<BoolParameter*>(param) != NULL)) {
+ if ((param != nullptr) &&
+ (dynamic_cast<BoolParameter*>(param) != nullptr)) {
if ((strcasecmp(argv[i+1], "0") == 0) ||
(strcasecmp(argv[i+1], "1") == 0) ||
(strcasecmp(argv[i+1], "true") == 0) ||
@@ -703,7 +705,7 @@ int main(int argc, char** argv)
Fl::display(display);
}
fl_open_display();
- XkbSetDetectableAutoRepeat(fl_display, True, NULL);
+ XkbSetDetectableAutoRepeat(fl_display, True, nullptr);
#endif
init_fltk();
@@ -717,11 +719,11 @@ int main(int argc, char** argv)
char *confdir = strdup(os::getvncconfigdir());
#ifndef WIN32
char *dotdir = strrchr(confdir, '.');
- if (dotdir != NULL && strcmp(dotdir, ".vnc") == 0)
+ if (dotdir != nullptr && strcmp(dotdir, ".vnc") == 0)
vlog.info(_("~/.vnc is deprecated, please consult 'man vncviewer' for paths to migrate to."));
#else
char *vncdir = strrchr(confdir, '\\');
- if (vncdir != NULL && strcmp(vncdir, "vnc") == 0)
+ if (vncdir != nullptr && strcmp(vncdir, "vnc") == 0)
vlog.info(_("%%APPDATA%%\\vnc is deprecated, please switch to the %%APPDATA%%\\TigerVNC location."));
#endif
@@ -745,7 +747,7 @@ int main(int argc, char** argv)
CSecurity::msg = &dlg;
#endif
- Socket *sock = NULL;
+ Socket *sock = nullptr;
#ifndef WIN32
/* Specifying -via and -listen together is nonsense */
@@ -765,22 +767,20 @@ int main(int argc, char** argv)
if (isdigit(vncServerName[0]))
port = atoi(vncServerName);
- createTcpListeners(&listeners, 0, port);
+ createTcpListeners(&listeners, nullptr, port);
if (listeners.empty())
throw Exception(_("Unable to listen for incoming connections"));
vlog.info(_("Listening on port %d"), port);
/* Wait for a connection */
- while (sock == NULL) {
+ while (sock == nullptr) {
fd_set rfds;
FD_ZERO(&rfds);
- for (std::list<SocketListener*>::iterator i = listeners.begin();
- i != listeners.end();
- i++)
- FD_SET((*i)->getFd(), &rfds);
+ for (SocketListener* listener : listeners)
+ FD_SET(listener->getFd(), &rfds);
- int n = select(FD_SETSIZE, &rfds, 0, 0, 0);
+ int n = select(FD_SETSIZE, &rfds, nullptr, nullptr, nullptr);
if (n < 0) {
if (errno == EINTR) {
vlog.debug("Interrupted select() system call");
@@ -790,11 +790,9 @@ int main(int argc, char** argv)
}
}
- for (std::list<SocketListener*>::iterator i = listeners.begin ();
- i != listeners.end();
- i++)
- if (FD_ISSET((*i)->getFd(), &rfds)) {
- sock = (*i)->accept();
+ for (SocketListener* listener : listeners)
+ if (FD_ISSET(listener->getFd(), &rfds)) {
+ sock = listener->accept();
if (sock)
/* Got a connection */
break;
diff --git a/win/rfb_win32/AboutDialog.cxx b/win/rfb_win32/AboutDialog.cxx
index a48a1ea7..a41ceefd 100644
--- a/win/rfb_win32/AboutDialog.cxx
+++ b/win/rfb_win32/AboutDialog.cxx
@@ -32,7 +32,7 @@ static LogWriter vlog("AboutDialog");
AboutDialog AboutDialog::instance;
-AboutDialog::AboutDialog() : Dialog(GetModuleHandle(0)) {
+AboutDialog::AboutDialog() : Dialog(GetModuleHandle(nullptr)) {
}
bool AboutDialog::showDialog() {
diff --git a/win/rfb_win32/AboutDialog.h b/win/rfb_win32/AboutDialog.h
index 705d6b3c..00cf0d42 100644
--- a/win/rfb_win32/AboutDialog.h
+++ b/win/rfb_win32/AboutDialog.h
@@ -33,7 +33,7 @@ namespace rfb {
public:
AboutDialog();
virtual bool showDialog();
- virtual void initDialog();
+ void initDialog() override;
static AboutDialog instance;
diff --git a/win/rfb_win32/CleanDesktop.cxx b/win/rfb_win32/CleanDesktop.cxx
index e69acd7f..d2d6d2d1 100644
--- a/win/rfb_win32/CleanDesktop.cxx
+++ b/win/rfb_win32/CleanDesktop.cxx
@@ -40,9 +40,9 @@ static LogWriter vlog("CleanDesktop");
struct ActiveDesktop {
- ActiveDesktop() : handle(0) {
+ ActiveDesktop() : handle(nullptr) {
// - Contact Active Desktop
- HRESULT result = CoCreateInstance(CLSID_ActiveDesktop, NULL, CLSCTX_INPROC_SERVER,
+ HRESULT result = CoCreateInstance(CLSID_ActiveDesktop, nullptr, CLSCTX_INPROC_SERVER,
IID_IActiveDesktop, (PVOID*)&handle);
if (result != S_OK)
throw rdr::SystemException("failed to contact Active Desktop", result);
@@ -153,7 +153,7 @@ DWORD SysParamsInfo(UINT action, UINT param, PVOID ptr, UINT ini) {
CleanDesktop::CleanDesktop() : restoreActiveDesktop(false),
restoreWallpaper(false),
restoreEffects(false) {
- CoInitialize(0);
+ CoInitialize(nullptr);
}
CleanDesktop::~CleanDesktop() {
@@ -207,7 +207,7 @@ void CleanDesktop::enableWallpaper() {
vlog.debug("restore desktop wallpaper");
// -=- Then restore the standard wallpaper if required
- SysParamsInfo(SPI_SETDESKWALLPAPER, 0, NULL, SPIF_SENDCHANGE);
+ SysParamsInfo(SPI_SETDESKWALLPAPER, 0, nullptr, SPIF_SENDCHANGE);
restoreWallpaper = false;
}
@@ -223,20 +223,20 @@ void CleanDesktop::disableEffects() {
vlog.debug("disable desktop effects");
- SysParamsInfo(SPI_SETFONTSMOOTHING, FALSE, 0, SPIF_SENDCHANGE);
+ SysParamsInfo(SPI_SETFONTSMOOTHING, FALSE, nullptr, SPIF_SENDCHANGE);
if (SysParamsInfo(SPI_GETUIEFFECTS, 0, &uiEffects, 0) == ERROR_CALL_NOT_IMPLEMENTED) {
SysParamsInfo(SPI_GETCOMBOBOXANIMATION, 0, &comboBoxAnim, 0);
SysParamsInfo(SPI_GETGRADIENTCAPTIONS, 0, &gradientCaptions, 0);
SysParamsInfo(SPI_GETHOTTRACKING, 0, &hotTracking, 0);
SysParamsInfo(SPI_GETLISTBOXSMOOTHSCROLLING, 0, &listBoxSmoothScroll, 0);
SysParamsInfo(SPI_GETMENUANIMATION, 0, &menuAnim, 0);
- SysParamsInfo(SPI_SETCOMBOBOXANIMATION, 0, FALSE, SPIF_SENDCHANGE);
- SysParamsInfo(SPI_SETGRADIENTCAPTIONS, 0, FALSE, SPIF_SENDCHANGE);
- SysParamsInfo(SPI_SETHOTTRACKING, 0, FALSE, SPIF_SENDCHANGE);
- SysParamsInfo(SPI_SETLISTBOXSMOOTHSCROLLING, 0, FALSE, SPIF_SENDCHANGE);
- SysParamsInfo(SPI_SETMENUANIMATION, 0, FALSE, SPIF_SENDCHANGE);
+ SysParamsInfo(SPI_SETCOMBOBOXANIMATION, 0, (PVOID)FALSE, SPIF_SENDCHANGE);
+ SysParamsInfo(SPI_SETGRADIENTCAPTIONS, 0, (PVOID)FALSE, SPIF_SENDCHANGE);
+ SysParamsInfo(SPI_SETHOTTRACKING, 0, (PVOID)FALSE, SPIF_SENDCHANGE);
+ SysParamsInfo(SPI_SETLISTBOXSMOOTHSCROLLING, 0, (PVOID)FALSE, SPIF_SENDCHANGE);
+ SysParamsInfo(SPI_SETMENUANIMATION, 0, (PVOID)FALSE, SPIF_SENDCHANGE);
} else {
- SysParamsInfo(SPI_SETUIEFFECTS, 0, FALSE, SPIF_SENDCHANGE);
+ SysParamsInfo(SPI_SETUIEFFECTS, 0, (PVOID)FALSE, SPIF_SENDCHANGE);
// We *always* restore UI effects overall, since there is no Windows GUI to do it
uiEffects = TRUE;
@@ -257,7 +257,7 @@ void CleanDesktop::enableEffects() {
RegKey desktopCfg;
desktopCfg.openKey(HKEY_CURRENT_USER, "Control Panel\\Desktop");
- SysParamsInfo(SPI_SETFONTSMOOTHING, desktopCfg.getInt("FontSmoothing", 0) != 0, 0, SPIF_SENDCHANGE);
+ SysParamsInfo(SPI_SETFONTSMOOTHING, desktopCfg.getInt("FontSmoothing", 0) != 0, nullptr, SPIF_SENDCHANGE);
if (SysParamsInfo(SPI_SETUIEFFECTS, 0, (void*)(intptr_t)uiEffects, SPIF_SENDCHANGE) == ERROR_CALL_NOT_IMPLEMENTED) {
SysParamsInfo(SPI_SETCOMBOBOXANIMATION, 0, (void*)(intptr_t)comboBoxAnim, SPIF_SENDCHANGE);
SysParamsInfo(SPI_SETGRADIENTCAPTIONS, 0, (void*)(intptr_t)gradientCaptions, SPIF_SENDCHANGE);
diff --git a/win/rfb_win32/Clipboard.cxx b/win/rfb_win32/Clipboard.cxx
index d90d0b7a..79115893 100644
--- a/win/rfb_win32/Clipboard.cxx
+++ b/win/rfb_win32/Clipboard.cxx
@@ -39,7 +39,7 @@ static LogWriter vlog("Clipboard");
//
Clipboard::Clipboard()
- : MsgWindow("Clipboard"), notifier(0), next_window(0) {
+ : MsgWindow("Clipboard"), notifier(nullptr), next_window(nullptr) {
next_window = SetClipboardViewer(getHandle());
vlog.debug("registered clipboard handler");
}
@@ -58,7 +58,7 @@ Clipboard::processMessage(UINT msg, WPARAM wParam, LPARAM lParam) {
(long long)wParam, (long long)lParam);
if ((HWND) wParam == next_window)
next_window = (HWND) lParam;
- else if (next_window != 0)
+ else if (next_window != nullptr)
SendMessage(next_window, msg, wParam, lParam);
else
vlog.error("bad clipboard chain change!");
@@ -72,7 +72,7 @@ Clipboard::processMessage(UINT msg, WPARAM wParam, LPARAM lParam) {
} else {
vlog.debug("local clipboard changed by %p", owner);
- if (notifier == NULL)
+ if (notifier == nullptr)
vlog.debug("no clipboard notifier registered");
else
notifier->notifyClipboardChanged(IsClipboardFormatAvailable(CF_UNICODETEXT));
@@ -94,19 +94,19 @@ Clipboard::getClipText() {
// Open the clipboard
if (!OpenClipboard(getHandle()))
- return NULL;
+ return nullptr;
// Get the clipboard data
cliphandle = GetClipboardData(CF_UNICODETEXT);
if (!cliphandle) {
CloseClipboard();
- return NULL;
+ return nullptr;
}
clipdata = (wchar_t*) GlobalLock(cliphandle);
if (!clipdata) {
CloseClipboard();
- return NULL;
+ return nullptr;
}
// Convert it to UTF-8
@@ -121,7 +121,7 @@ Clipboard::getClipText() {
void
Clipboard::setClipText(const char* text) {
- HANDLE clip_handle = 0;
+ HANDLE clip_handle = nullptr;
try {
@@ -147,7 +147,7 @@ Clipboard::setClipText(const char* text) {
// - Set the new clipboard data
if (!SetClipboardData(CF_UNICODETEXT, clip_handle))
throw rdr::SystemException("unable to set Win32 clipboard", GetLastError());
- clip_handle = 0;
+ clip_handle = nullptr;
vlog.debug("set clipboard");
} catch (rdr::Exception& e) {
diff --git a/win/rfb_win32/Clipboard.h b/win/rfb_win32/Clipboard.h
index 588f1086..b66aa5a4 100644
--- a/win/rfb_win32/Clipboard.h
+++ b/win/rfb_win32/Clipboard.h
@@ -57,7 +57,7 @@ namespace rfb {
protected:
// - Internal MsgWindow callback
- virtual LRESULT processMessage(UINT msg, WPARAM wParam, LPARAM lParam);
+ LRESULT processMessage(UINT msg, WPARAM wParam, LPARAM lParam) override;
Notifier* notifier;
HWND next_window;
diff --git a/win/rfb_win32/DIBSectionBuffer.cxx b/win/rfb_win32/DIBSectionBuffer.cxx
index 632c0a4c..aa03315c 100644
--- a/win/rfb_win32/DIBSectionBuffer.cxx
+++ b/win/rfb_win32/DIBSectionBuffer.cxx
@@ -33,11 +33,11 @@ static LogWriter vlog("DIBSectionBuffer");
DIBSectionBuffer::DIBSectionBuffer(HWND window_)
- : bitmap(0), window(window_), device(0) {
+ : bitmap(nullptr), window(window_), device(nullptr) {
}
DIBSectionBuffer::DIBSectionBuffer(HDC device_)
- : bitmap(0), window(0), device(device_) {
+ : bitmap(nullptr), window(nullptr), device(device_) {
}
DIBSectionBuffer::~DIBSectionBuffer() {
@@ -52,8 +52,8 @@ inline void initMaxAndShift(DWORD mask, int* max, int* shift) {
}
void DIBSectionBuffer::initBuffer(const PixelFormat& pf, int w, int h) {
- HBITMAP new_bitmap = 0;
- uint8_t* new_data = 0;
+ HBITMAP new_bitmap = nullptr;
+ uint8_t* new_data = nullptr;
if (!pf.trueColour)
throw rfb::Exception("palette format not supported");
@@ -78,10 +78,10 @@ void DIBSectionBuffer::initBuffer(const PixelFormat& pf, int w, int h) {
// Create a DIBSection to draw into
if (device)
new_bitmap = ::CreateDIBSection(device, (BITMAPINFO*)&bi.bmiHeader, iUsage,
- (void**)&new_data, NULL, 0);
+ (void**)&new_data, nullptr, 0);
else
new_bitmap = ::CreateDIBSection(WindowDC(window), (BITMAPINFO*)&bi.bmiHeader, iUsage,
- (void**)&new_data, NULL, 0);
+ (void**)&new_data, nullptr, 0);
if (!new_bitmap) {
int err = GetLastError();
@@ -112,8 +112,8 @@ void DIBSectionBuffer::initBuffer(const PixelFormat& pf, int w, int h) {
if (bitmap) {
// Delete the old bitmap
DeleteObject(bitmap);
- bitmap = 0;
- setBuffer(0, 0, NULL, 0);
+ bitmap = nullptr;
+ setBuffer(0, 0, nullptr, 0);
}
if (new_bitmap) {
diff --git a/win/rfb_win32/DeviceContext.cxx b/win/rfb_win32/DeviceContext.cxx
index e59672f5..1efc3a59 100644
--- a/win/rfb_win32/DeviceContext.cxx
+++ b/win/rfb_win32/DeviceContext.cxx
@@ -50,10 +50,10 @@ PixelFormat DeviceContext::getPF(HDC dc) {
memset(&bi, 0, sizeof(bi));
bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bi.bmiHeader.biBitCount = 0;
- if (!::GetDIBits(dc, bitmap, 0, 1, NULL, (BITMAPINFO*)&bi, DIB_RGB_COLORS)) {
+ if (!::GetDIBits(dc, bitmap, 0, 1, nullptr, (BITMAPINFO*)&bi, DIB_RGB_COLORS)) {
throw rdr::SystemException("unable to determine device pixel format", GetLastError());
}
- if (!::GetDIBits(dc, bitmap, 0, 1, NULL, (BITMAPINFO*)&bi, DIB_RGB_COLORS)) {
+ if (!::GetDIBits(dc, bitmap, 0, 1, nullptr, (BITMAPINFO*)&bi, DIB_RGB_COLORS)) {
throw rdr::SystemException("unable to determine pixel shifts/palette", GetLastError());
}
@@ -157,7 +157,7 @@ Rect DeviceContext::getClipBox(HDC dc) {
DeviceDC::DeviceDC(const char* deviceName) {
- dc = ::CreateDC("DISPLAY", deviceName, NULL, NULL);
+ dc = ::CreateDC("DISPLAY", deviceName, nullptr, nullptr);
if (!dc)
throw rdr::SystemException("failed to create DeviceDC", GetLastError());
}
diff --git a/win/rfb_win32/DeviceContext.h b/win/rfb_win32/DeviceContext.h
index 0664684b..7e89723c 100644
--- a/win/rfb_win32/DeviceContext.h
+++ b/win/rfb_win32/DeviceContext.h
@@ -35,7 +35,7 @@ namespace rfb {
// and the pixel format, and access to the HDC itself.
class DeviceContext {
public:
- DeviceContext() : dc(0) {}
+ DeviceContext() : dc(nullptr) {}
virtual ~DeviceContext() {}
operator HDC() const {return dc;}
PixelFormat getPF() const;
diff --git a/win/rfb_win32/DeviceFrameBuffer.cxx b/win/rfb_win32/DeviceFrameBuffer.cxx
index 5d866de8..bba1dbdb 100644
--- a/win/rfb_win32/DeviceFrameBuffer.cxx
+++ b/win/rfb_win32/DeviceFrameBuffer.cxx
@@ -122,8 +122,8 @@ void DeviceFrameBuffer::setCursor(HCURSOR hCursor, VNCServer* server)
{
// - If hCursor is null then there is no cursor - clear the old one
- if (hCursor == 0) {
- server->setCursor(0, 0, Point(), NULL);
+ if (hCursor == nullptr) {
+ server->setCursor(0, 0, Point(), nullptr);
return;
}
@@ -223,19 +223,19 @@ void DeviceFrameBuffer::setCursor(HCURSOR hCursor, VNCServer* server)
uint8_t* rwbuffer = buffer.data();
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
- int byte = y * maskInfo.bmWidthBytes + x / 8;
+ int byte_ = y * maskInfo.bmWidthBytes + x / 8;
int bit = 7 - x % 8;
- if (!(andMask[byte] & (1 << bit))) {
+ if (!(andMask[byte_] & (1 << bit))) {
// Valid pixel, so make it opaque
rwbuffer[3] = 0xff;
// Black or white?
- if (xorMask[byte] & (1 << bit))
+ if (xorMask[byte_] & (1 << bit))
rwbuffer[0] = rwbuffer[1] = rwbuffer[2] = 0xff;
else
rwbuffer[0] = rwbuffer[1] = rwbuffer[2] = 0;
- } else if (xorMask[byte] & (1 << bit)) {
+ } else if (xorMask[byte_] & (1 << bit)) {
// Replace any XORed pixels with black, because RFB doesn't support
// XORing of cursors. XORing is used for the I-beam cursor, which is most
// often used over a white background, but also sometimes over a black
diff --git a/win/rfb_win32/DeviceFrameBuffer.h b/win/rfb_win32/DeviceFrameBuffer.h
index c8715724..e9f06cb0 100644
--- a/win/rfb_win32/DeviceFrameBuffer.h
+++ b/win/rfb_win32/DeviceFrameBuffer.h
@@ -69,7 +69,7 @@ namespace rfb {
// - FrameBuffer overrides
virtual void grabRect(const Rect &rect);
- virtual void grabRegion(const Region &region);
+ void grabRegion(const Region &region) override;
// - DeviceFrameBuffer specific methods
diff --git a/win/rfb_win32/Dialog.cxx b/win/rfb_win32/Dialog.cxx
index 8e2c1ee8..432439ce 100644
--- a/win/rfb_win32/Dialog.cxx
+++ b/win/rfb_win32/Dialog.cxx
@@ -48,7 +48,7 @@ static LogWriter plog("PropSheet");
Dialog::Dialog(HINSTANCE inst_)
-: inst(inst_), handle(0), alreadyShowing(false)
+: inst(inst_), handle(nullptr), alreadyShowing(false)
{
}
@@ -60,7 +60,7 @@ Dialog::~Dialog()
bool Dialog::showDialog(const char* resource, HWND owner)
{
if (alreadyShowing) return false;
- handle = 0;
+ handle = nullptr;
alreadyShowing = true;
INT_PTR result = DialogBoxParam(inst, resource, owner,
staticDialogProc, (LPARAM)this);
@@ -151,14 +151,14 @@ BOOL Dialog::dialogProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
}
-PropSheetPage::PropSheetPage(HINSTANCE inst, const char* id) : Dialog(inst), propSheet(0) {
+PropSheetPage::PropSheetPage(HINSTANCE inst_, const char* id) : Dialog(inst_), propSheet(nullptr) {
page.dwSize = sizeof(page);
page.dwFlags = 0; // PSP_USECALLBACK;
page.hInstance = inst;
page.pszTemplate = id;
page.pfnDlgProc = staticPageProc;
page.lParam = (LPARAM)this;
- page.pfnCallback = 0; // staticPageProc;
+ page.pfnCallback = nullptr; // staticPageProc;
}
PropSheetPage::~PropSheetPage() {
@@ -207,7 +207,7 @@ BOOL PropSheetPage::dialogProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam
PropSheet::PropSheet(HINSTANCE inst_, const char* title_, std::list<PropSheetPage*> pages_, HICON icon_)
-: icon(icon_), pages(pages_), inst(inst_), title(title_), handle(0), alreadyShowing(0) {
+: icon(icon_), pages(pages_), inst(inst_), title(title_), handle(nullptr), alreadyShowing(0) {
}
PropSheet::~PropSheet() {
@@ -241,7 +241,7 @@ static int CALLBACK removeCtxtHelp(HWND /*hwnd*/, UINT message, LPARAM lParam) {
}
-bool PropSheet::showPropSheet(HWND owner, bool showApply, bool showCtxtHelp, bool capture) {
+bool PropSheet::showPropSheet(HWND owner_, bool showApply, bool showCtxtHelp, bool capture) {
if (alreadyShowing) return false;
alreadyShowing = true;
int count = pages.size();
@@ -262,7 +262,7 @@ bool PropSheet::showPropSheet(HWND owner, bool showApply, bool showCtxtHelp, boo
header.dwSize = sizeof(PROPSHEETHEADER); // Requires comctl32.dll 4.71 or greater, ie IE 4 or later
header.dwFlags = PSH_MODELESS | (showApply ? 0 : PSH_NOAPPLYNOW) | (showCtxtHelp ? 0 : PSH_USECALLBACK);
header.pfnCallback = removeCtxtHelp;
- header.hwndParent = owner;
+ header.hwndParent = owner_;
header.hInstance = inst;
header.pszCaption = title.c_str();
header.nPages = count;
@@ -274,9 +274,9 @@ bool PropSheet::showPropSheet(HWND owner, bool showApply, bool showCtxtHelp, boo
}
handle = (HWND)PropertySheet(&header);
- if ((handle == 0) || (handle == (HWND)-1))
+ if ((handle == nullptr) || (handle == (HWND)-1))
throw rdr::SystemException("PropertySheet failed", GetLastError());
- centerWindow(handle, owner);
+ centerWindow(handle, owner_);
plog.info("created %p", handle);
(void)capture;
@@ -314,21 +314,21 @@ bool PropSheet::showPropSheet(HWND owner, bool showApply, bool showCtxtHelp, boo
} else {
#endif
try {
- if (owner)
- EnableWindow(owner, FALSE);
+ if (owner_)
+ EnableWindow(owner_, FALSE);
// Run the PropertySheet
MSG msg;
- while (GetMessage(&msg, 0, 0, 0)) {
+ while (GetMessage(&msg, nullptr, 0, 0)) {
if (!PropSheet_IsDialogMessage(handle, &msg))
DispatchMessage(&msg);
if (!PropSheet_GetCurrentPageHwnd(handle))
break;
}
- if (owner)
- EnableWindow(owner, TRUE);
+ if (owner_)
+ EnableWindow(owner_, TRUE);
} catch (...) {
- if (owner)
- EnableWindow(owner, TRUE);
+ if (owner_)
+ EnableWindow(owner_, TRUE);
throw;
}
#ifdef _DIALOG_CAPTURE
@@ -338,13 +338,13 @@ bool PropSheet::showPropSheet(HWND owner, bool showApply, bool showCtxtHelp, boo
plog.info("finished %p", handle);
DestroyWindow(handle);
- handle = 0;
+ handle = nullptr;
alreadyShowing = false;
// Clear up the pages' GDI objects
for (pspi=pages.begin(); pspi!=pages.end(); pspi++)
- (*pspi)->setPropSheet(0);
- delete [] hpages; hpages = 0;
+ (*pspi)->setPropSheet(nullptr);
+ delete [] hpages; hpages = nullptr;
return true;
} catch (rdr::Exception&) {
@@ -352,8 +352,8 @@ bool PropSheet::showPropSheet(HWND owner, bool showApply, bool showCtxtHelp, boo
std::list<PropSheetPage*>::iterator pspi;
for (pspi=pages.begin(); pspi!=pages.end(); pspi++)
- (*pspi)->setPropSheet(0);
- delete [] hpages; hpages = 0;
+ (*pspi)->setPropSheet(nullptr);
+ delete [] hpages; hpages = nullptr;
throw;
}
diff --git a/win/rfb_win32/Dialog.h b/win/rfb_win32/Dialog.h
index d1a8e831..69374bb1 100644
--- a/win/rfb_win32/Dialog.h
+++ b/win/rfb_win32/Dialog.h
@@ -52,7 +52,7 @@ namespace rfb {
// expansion), and owner is an optional window handle - the corresponding
// window is disabled while the dialog box is displayed.
- bool showDialog(const char* resource, HWND owner=0);
+ bool showDialog(const char* resource, HWND owner=nullptr);
// initDialog() is called upon receipt of the WM_INITDIALOG message.
@@ -106,7 +106,7 @@ namespace rfb {
class PropSheet {
public:
- PropSheet(HINSTANCE inst, const char* title, std::list<PropSheetPage*> pages, HICON icon=0);
+ PropSheet(HINSTANCE inst, const char* title, std::list<PropSheetPage*> pages, HICON icon=nullptr);
virtual ~PropSheet();
// Display the PropertySheet
@@ -148,7 +148,7 @@ namespace rfb {
protected:
void setPropSheet(PropSheet* ps) {propSheet = ps;};
static INT_PTR CALLBACK staticPageProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
- virtual BOOL dialogProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
+ BOOL dialogProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) override;
PROPSHEETPAGE page;
PropSheet* propSheet;
};
diff --git a/win/rfb_win32/Handle.h b/win/rfb_win32/Handle.h
index d3baa580..6b88a8f1 100644
--- a/win/rfb_win32/Handle.h
+++ b/win/rfb_win32/Handle.h
@@ -29,7 +29,7 @@ namespace rfb {
class Handle {
public:
- Handle(HANDLE h_=0) : h(h_) {}
+ Handle(HANDLE h_=nullptr) : h(h_) {}
~Handle() {
if (h) CloseHandle(h);
}
diff --git a/win/rfb_win32/IntervalTimer.h b/win/rfb_win32/IntervalTimer.h
index deb2abc6..89cd9312 100644
--- a/win/rfb_win32/IntervalTimer.h
+++ b/win/rfb_win32/IntervalTimer.h
@@ -31,7 +31,7 @@ namespace rfb {
IntervalTimer(HWND hwnd_, int id_)
: hwnd(hwnd_), id(id_), active(false) {
}
- IntervalTimer() : hwnd(0), id(0), active(false) {
+ IntervalTimer() : hwnd(nullptr), id(0), active(false) {
}
~IntervalTimer() {
stop();
@@ -40,7 +40,7 @@ namespace rfb {
void start(int interval_) {
if (!active || interval_ != interval) {
interval = interval_;
- if (!SetTimer(hwnd, id, interval, 0))
+ if (!SetTimer(hwnd, id, interval, nullptr))
throw rdr::SystemException("SetTimer", GetLastError());
active = true;
}
diff --git a/win/rfb_win32/LaunchProcess.cxx b/win/rfb_win32/LaunchProcess.cxx
index 5e702a00..92a68273 100644
--- a/win/rfb_win32/LaunchProcess.cxx
+++ b/win/rfb_win32/LaunchProcess.cxx
@@ -85,11 +85,15 @@ void LaunchProcess::start(HANDLE userToken, bool createConsole) {
BOOL success;
if (userToken != INVALID_HANDLE_VALUE)
success = CreateProcessAsUser(userToken, exePath.c_str(),
- (char*)cmdLine.c_str(), 0, 0, FALSE,
- flags, 0, 0, &sinfo, &procInfo);
+ (char*)cmdLine.c_str(),
+ nullptr, nullptr, FALSE,
+ flags, nullptr, nullptr,
+ &sinfo, &procInfo);
else
- success = CreateProcess(exePath.c_str(), (char*)cmdLine.c_str(), 0,
- 0, FALSE, flags, 0, 0, &sinfo, &procInfo);
+ success = CreateProcess(exePath.c_str(), (char*)cmdLine.c_str(),
+ nullptr, nullptr, FALSE,
+ flags, nullptr, nullptr,
+ &sinfo, &procInfo);
if (!success)
throw rdr::SystemException("unable to launch process", GetLastError());
diff --git a/win/rfb_win32/LocalMem.h b/win/rfb_win32/LocalMem.h
index a99d3241..239e8c1f 100644
--- a/win/rfb_win32/LocalMem.h
+++ b/win/rfb_win32/LocalMem.h
@@ -34,7 +34,7 @@ namespace rfb {
~LocalMem() {LocalFree(ptr);}
operator void*() {return ptr;}
void* takePtr() {
- void* t = ptr; ptr = 0; return t;
+ void* t = ptr; ptr = nullptr; return t;
}
void* ptr;
};
diff --git a/win/rfb_win32/ModuleFileName.h b/win/rfb_win32/ModuleFileName.h
index 9a06f50d..c95ad1f1 100644
--- a/win/rfb_win32/ModuleFileName.h
+++ b/win/rfb_win32/ModuleFileName.h
@@ -25,9 +25,9 @@ namespace rfb {
namespace win32 {
struct ModuleFileName {
- ModuleFileName(HMODULE module=0) {
+ ModuleFileName(HMODULE module=nullptr) {
if (!module)
- module = GetModuleHandle(0);
+ module = GetModuleHandle(nullptr);
if (!GetModuleFileName(module, buf, MAX_PATH))
buf[0] = 0;
}
diff --git a/win/rfb_win32/MonitorInfo.cxx b/win/rfb_win32/MonitorInfo.cxx
index c7217c19..fb4fb3a9 100644
--- a/win/rfb_win32/MonitorInfo.cxx
+++ b/win/rfb_win32/MonitorInfo.cxx
@@ -96,7 +96,7 @@ MonitorInfo::MonitorInfo(const char* devName) {
monitorByNameData data;
data.info = this;
data.monitorName = devName;
- EnumDisplayMonitors(0, 0, &monitorByNameEnumProc, (LPARAM)&data);
+ EnumDisplayMonitors(nullptr, nullptr, &monitorByNameEnumProc, (LPARAM)&data);
}
void MonitorInfo::moveTo(HWND handle) {
@@ -134,7 +134,7 @@ void MonitorInfo::clipTo(HWND handle) {
RECT r;
GetWindowRect(handle, &r);
clipTo(&r);
- SetWindowPos(handle, 0, r.left, r.top, r.right-r.left, r.bottom-r.top,
+ SetWindowPos(handle, nullptr, r.left, r.top, r.right-r.left, r.bottom-r.top,
SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOOWNERZORDER);
}
diff --git a/win/rfb_win32/MsgBox.h b/win/rfb_win32/MsgBox.h
index 25d36383..e831d745 100644
--- a/win/rfb_win32/MsgBox.h
+++ b/win/rfb_win32/MsgBox.h
@@ -36,7 +36,7 @@ namespace rfb {
// Wrapper around Win32 MessageBox()
static int MsgBox(HWND parent, const char* msg, UINT flags) {
- const char* msgType = 0;
+ const char* msgType = nullptr;
UINT tflags = flags & 0x70;
if (tflags == MB_ICONHAND)
msgType = "Error";
diff --git a/win/rfb_win32/MsgWindow.cxx b/win/rfb_win32/MsgWindow.cxx
index 251b2762..30c9373e 100644
--- a/win/rfb_win32/MsgWindow.cxx
+++ b/win/rfb_win32/MsgWindow.cxx
@@ -74,11 +74,11 @@ MsgWindowClass::MsgWindowClass() : classAtom(0) {
wndClass.lpfnWndProc = MsgWindowProc;
wndClass.cbClsExtra = 0;
wndClass.cbWndExtra = 0;
- wndClass.hInstance = instance = GetModuleHandle(0);
- wndClass.hIcon = 0;
- wndClass.hCursor = 0;
- wndClass.hbrBackground = 0;
- wndClass.lpszMenuName = 0;
+ wndClass.hInstance = instance = GetModuleHandle(nullptr);
+ wndClass.hIcon = nullptr;
+ wndClass.hCursor = nullptr;
+ wndClass.hbrBackground = nullptr;
+ wndClass.lpszMenuName = nullptr;
wndClass.lpszClassName = "rfb::win32::MsgWindowClass";
classAtom = RegisterClass(&wndClass);
if (!classAtom) {
@@ -98,11 +98,11 @@ static MsgWindowClass baseClass;
// -=- MsgWindow
//
-MsgWindow::MsgWindow(const char* name_) : name(name_), handle(0) {
+MsgWindow::MsgWindow(const char* name_) : name(name_), handle(nullptr) {
vlog.debug("creating window \"%s\"", name.c_str());
handle = CreateWindow((const char*)(intptr_t)baseClass.classAtom,
- name.c_str(), WS_OVERLAPPED, 0, 0, 10, 10, 0, 0,
- baseClass.instance, this);
+ name.c_str(), WS_OVERLAPPED, 0, 0, 10, 10,
+ nullptr, nullptr, baseClass.instance, this);
if (!handle) {
throw rdr::SystemException("unable to create WMNotifier window instance", GetLastError());
}
diff --git a/win/rfb_win32/RegConfig.cxx b/win/rfb_win32/RegConfig.cxx
index 38ca52f9..770330ce 100644
--- a/win/rfb_win32/RegConfig.cxx
+++ b/win/rfb_win32/RegConfig.cxx
@@ -35,7 +35,10 @@ using namespace rfb::win32;
static LogWriter vlog("RegConfig");
-RegConfig::RegConfig(EventManager* em) : eventMgr(em), event(CreateEvent(0, TRUE, FALSE, 0)), callback(0) {
+RegConfig::RegConfig(EventManager* em)
+ : eventMgr(em), event(CreateEvent(nullptr, TRUE, FALSE, nullptr)),
+ callback(nullptr)
+{
if (em->addEvent(event, this))
eventMgr = em;
}
@@ -110,7 +113,7 @@ void RegConfigThread::worker() {
BOOL result = 0;
MSG msg;
thread_id = GetCurrentThreadId();
- while ((result = eventMgr.getMessage(&msg, 0, 0, 0)) > 0) {}
+ while ((result = eventMgr.getMessage(&msg, nullptr, 0, 0)) > 0) {}
if (result < 0)
throw rdr::SystemException("RegConfigThread failed", GetLastError());
}
diff --git a/win/rfb_win32/RegConfig.h b/win/rfb_win32/RegConfig.h
index ef8e45bd..401cb148 100644
--- a/win/rfb_win32/RegConfig.h
+++ b/win/rfb_win32/RegConfig.h
@@ -56,7 +56,7 @@ namespace rfb {
static void loadRegistryConfig(RegKey& key);
protected:
// EventHandler interface and trigger event
- virtual void processEvent(HANDLE event);
+ void processEvent(HANDLE event) override;
EventManager* eventMgr;
Handle event;
@@ -72,7 +72,7 @@ namespace rfb {
// Start the thread, reading from the specified key
bool start(const HKEY rootkey, const char* keyname);
protected:
- virtual void worker();
+ void worker() override;
EventManager eventMgr;
RegConfig config;
DWORD thread_id;
diff --git a/win/rfb_win32/Registry.cxx b/win/rfb_win32/Registry.cxx
index d0db60e2..bcb98704 100644
--- a/win/rfb_win32/Registry.cxx
+++ b/win/rfb_win32/Registry.cxx
@@ -49,18 +49,18 @@ using namespace rfb::win32;
static LogWriter vlog("Registry");
-RegKey::RegKey() : key(0), freeKey(false), valueName(NULL), valueNameBufLen(0) {}
+RegKey::RegKey() : key(nullptr), freeKey(false), valueName(nullptr), valueNameBufLen(0) {}
-RegKey::RegKey(const HKEY k) : key(0), freeKey(false), valueName(NULL), valueNameBufLen(0) {
- LONG result = RegOpenKeyEx(k, 0, 0, KEY_ALL_ACCESS, &key);
+RegKey::RegKey(const HKEY k) : key(nullptr), freeKey(false), valueName(nullptr), valueNameBufLen(0) {
+ LONG result = RegOpenKeyEx(k, nullptr, 0, KEY_ALL_ACCESS, &key);
if (result != ERROR_SUCCESS)
throw rdr::SystemException("RegOpenKeyEx(HKEY)", result);
vlog.debug("duplicated %p to %p", k, key);
freeKey = true;
}
-RegKey::RegKey(const RegKey& k) : key(0), freeKey(false), valueName(NULL), valueNameBufLen(0) {
- LONG result = RegOpenKeyEx(k.key, 0, 0, KEY_ALL_ACCESS, &key);
+RegKey::RegKey(const RegKey& k) : key(nullptr), freeKey(false), valueName(nullptr), valueNameBufLen(0) {
+ LONG result = RegOpenKeyEx(k.key, nullptr, 0, KEY_ALL_ACCESS, &key);
if (result != ERROR_SUCCESS)
throw rdr::SystemException("RegOpenKeyEx(RegKey&)", result);
vlog.debug("duplicated %p to %p", k.key, key);
@@ -108,7 +108,7 @@ void RegKey::setDACL(const PACL acl, bool inherit) {
if ((result = SetSecurityInfo(key, SE_REGISTRY_KEY,
DACL_SECURITY_INFORMATION |
(inherit ? UNPROTECTED_DACL_SECURITY_INFORMATION : PROTECTED_DACL_SECURITY_INFORMATION),
- 0, 0, acl, 0)) != ERROR_SUCCESS)
+ nullptr, nullptr, acl, nullptr)) != ERROR_SUCCESS)
throw rdr::SystemException("RegKey::setDACL failed", result);
}
@@ -116,7 +116,7 @@ void RegKey::close() {
if (freeKey) {
vlog.debug("RegCloseKey(%p)", key);
RegCloseKey(key);
- key = 0;
+ key = nullptr;
}
}
@@ -133,7 +133,7 @@ void RegKey::deleteValue(const char* name) const {
}
void RegKey::awaitChange(bool watchSubTree, DWORD filter, HANDLE event) const {
- LONG result = RegNotifyChangeKeyValue(key, watchSubTree, filter, event, event != 0);
+ LONG result = RegNotifyChangeKeyValue(key, watchSubTree, filter, event, event != nullptr);
if (result != ERROR_SUCCESS)
throw rdr::SystemException("RegNotifyChangeKeyValue", result);
}
@@ -212,11 +212,11 @@ bool RegKey::getBool(const char* valname, bool def) const {
std::string RegKey::getRepresentation(const char* valname) const {
DWORD type, length;
- LONG result = RegQueryValueEx(key, valname, 0, &type, 0, &length);
+ LONG result = RegQueryValueEx(key, valname, nullptr, &type, nullptr, &length);
if (result != ERROR_SUCCESS)
throw rdr::SystemException("get registry value length", result);
std::vector<uint8_t> data(length);
- result = RegQueryValueEx(key, valname, 0, &type, (BYTE*)data.data(), &length);
+ result = RegQueryValueEx(key, valname, nullptr, &type, (BYTE*)data.data(), &length);
if (result != ERROR_SUCCESS)
throw rdr::SystemException("get registry value", result);
@@ -241,14 +241,14 @@ std::string RegKey::getRepresentation(const char* valname) const {
{
if (length) {
std::string str((char*)data.data(), length);
- DWORD required = ExpandEnvironmentStrings(str.c_str(), 0, 0);
+ DWORD required = ExpandEnvironmentStrings(str.c_str(), nullptr, 0);
if (required==0)
throw rdr::SystemException("ExpandEnvironmentStrings", GetLastError());
- std::vector<char> result(required);
- length = ExpandEnvironmentStrings(str.c_str(), result.data(), required);
+ std::vector<char> expanded(required);
+ length = ExpandEnvironmentStrings(str.c_str(), expanded.data(), required);
if (required<length)
throw rdr::Exception("unable to expand environment strings");
- return result.data();
+ return expanded.data();
} else {
return "";
}
@@ -269,7 +269,7 @@ bool RegKey::isValue(const char* valname) const {
const char* RegKey::getValueName(int i) {
DWORD maxValueNameLen;
- LONG result = RegQueryInfoKey(key, 0, 0, 0, 0, 0, 0, 0, &maxValueNameLen, 0, 0, 0);
+ LONG result = RegQueryInfoKey(key, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, &maxValueNameLen, nullptr, nullptr, nullptr);
if (result != ERROR_SUCCESS)
throw rdr::SystemException("RegQueryInfoKey", result);
if (valueNameBufLen < maxValueNameLen + 1) {
@@ -278,8 +278,8 @@ const char* RegKey::getValueName(int i) {
valueName = new char[valueNameBufLen];
}
DWORD length = valueNameBufLen;
- result = RegEnumValue(key, i, valueName, &length, NULL, 0, 0, 0);
- if (result == ERROR_NO_MORE_ITEMS) return 0;
+ result = RegEnumValue(key, i, valueName, &length, nullptr, nullptr, nullptr, nullptr);
+ if (result == ERROR_NO_MORE_ITEMS) return nullptr;
if (result != ERROR_SUCCESS)
throw rdr::SystemException("RegEnumValue", result);
return valueName;
@@ -287,7 +287,7 @@ const char* RegKey::getValueName(int i) {
const char* RegKey::getKeyName(int i) {
DWORD maxValueNameLen;
- LONG result = RegQueryInfoKey(key, 0, 0, 0, 0, &maxValueNameLen, 0, 0, 0, 0, 0, 0);
+ LONG result = RegQueryInfoKey(key, nullptr, nullptr, nullptr, nullptr, &maxValueNameLen, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr);
if (result != ERROR_SUCCESS)
throw rdr::SystemException("RegQueryInfoKey", result);
if (valueNameBufLen < maxValueNameLen + 1) {
@@ -296,8 +296,8 @@ const char* RegKey::getKeyName(int i) {
valueName = new char[valueNameBufLen];
}
DWORD length = valueNameBufLen;
- result = RegEnumKeyEx(key, i, valueName, &length, NULL, 0, 0, 0);
- if (result == ERROR_NO_MORE_ITEMS) return 0;
+ result = RegEnumKeyEx(key, i, valueName, &length, nullptr, nullptr, nullptr, nullptr);
+ if (result == ERROR_NO_MORE_ITEMS) return nullptr;
if (result != ERROR_SUCCESS)
throw rdr::SystemException("RegEnumKey", result);
return valueName;
diff --git a/win/rfb_win32/Registry.h b/win/rfb_win32/Registry.h
index b99c95bc..10c9e099 100644
--- a/win/rfb_win32/Registry.h
+++ b/win/rfb_win32/Registry.h
@@ -68,7 +68,7 @@ namespace rfb {
// Block waiting for a registry change, OR return immediately and notify the
// event when there is a change, if specified
- void awaitChange(bool watchSubTree, DWORD filter, HANDLE event=0) const;
+ void awaitChange(bool watchSubTree, DWORD filter, HANDLE event=nullptr) const;
void setExpandString(const char* valname, const char* s) const;
void setString(const char* valname, const char* s) const;
diff --git a/win/rfb_win32/SDisplay.cxx b/win/rfb_win32/SDisplay.cxx
index dd1ac7da..b1abf849 100644
--- a/win/rfb_win32/SDisplay.cxx
+++ b/win/rfb_win32/SDisplay.cxx
@@ -70,13 +70,13 @@ BoolParameter rfb::win32::SDisplay::disableEffects("DisableEffects",
// -=- Constructor/Destructor
SDisplay::SDisplay()
- : server(0), pb(0), device(0),
- core(0), ptr(0), kbd(0), clipboard(0),
- inputs(0), monitor(0), cleanDesktop(0), cursor(0),
- statusLocation(0), queryConnectionHandler(0), ledState(0)
+ : server(nullptr), pb(nullptr), device(nullptr),
+ core(nullptr), ptr(nullptr), kbd(nullptr), clipboard(nullptr),
+ inputs(nullptr), monitor(nullptr), cleanDesktop(nullptr), cursor(nullptr),
+ statusLocation(nullptr), queryConnectionHandler(nullptr), ledState(0)
{
- updateEvent.h = CreateEvent(0, TRUE, FALSE, 0);
- terminateEvent.h = CreateEvent(0, TRUE, FALSE, 0);
+ updateEvent.h = CreateEvent(nullptr, TRUE, FALSE, nullptr);
+ terminateEvent.h = CreateEvent(nullptr, TRUE, FALSE, nullptr);
}
SDisplay::~SDisplay()
@@ -89,7 +89,7 @@ SDisplay::~SDisplay()
// the VNCServer ought not to exist and therefore we shouldn't invoke any
// methods on it. Setting server to zero here ensures that stop() doesn't
// call setPixelBuffer(0) on the server.
- server = 0;
+ server = nullptr;
if (core) stop();
}
@@ -139,7 +139,7 @@ void SDisplay::stop()
}
// Stop the SDisplayCore
- server->setPixelBuffer(0);
+ server->setPixelBuffer(nullptr);
stopCore();
vlog.debug("stopped");
@@ -156,7 +156,7 @@ void SDisplay::terminate()
void SDisplay::queryConnection(network::Socket* sock,
const char* userName)
{
- assert(server != NULL);
+ assert(server != nullptr);
if (queryConnectionHandler) {
queryConnectionHandler->queryConnection(sock, userName);
@@ -198,7 +198,7 @@ void SDisplay::startCore() {
core = new SDisplayCorePolling(this, &updates);
core->setScreenRect(screenRect);
} catch (rdr::Exception& e) {
- delete core; core = 0;
+ delete core; core = nullptr;
if (tryMethod == 0)
throw rdr::Exception("unable to access desktop");
tryMethod--;
@@ -234,16 +234,16 @@ void SDisplay::startCore() {
void SDisplay::stopCore() {
if (core)
vlog.info("Stopping %s", core->methodName());
- delete core; core = 0;
- delete pb; pb = 0;
- delete device; device = 0;
- delete monitor; monitor = 0;
- delete clipboard; clipboard = 0;
- delete inputs; inputs = 0;
- delete ptr; ptr = 0;
- delete kbd; kbd = 0;
- delete cleanDesktop; cleanDesktop = 0;
- delete cursor; cursor = 0;
+ delete core; core = nullptr;
+ delete pb; pb = nullptr;
+ delete device; device = nullptr;
+ delete monitor; monitor = nullptr;
+ delete clipboard; clipboard = nullptr;
+ delete inputs; inputs = nullptr;
+ delete ptr; ptr = nullptr;
+ delete kbd; kbd = nullptr;
+ delete cleanDesktop; cleanDesktop = nullptr;
+ delete cursor; cursor = nullptr;
ResetEvent(updateEvent);
}
@@ -416,7 +416,7 @@ SDisplay::processEvent(HANDLE event) {
// Update the cursor shape
if (set_cursor)
- pb->setCursor(info.visible ? info.cursor : 0, server);
+ pb->setCursor(info.visible ? info.cursor : nullptr, server);
// Update the cursor position
// NB: First translate from Screen coordinates to Desktop
@@ -447,14 +447,14 @@ SDisplay::recreatePixelBuffer(bool force) {
// If no device is specified, open entire screen using GetDC().
// Opening the whole display with CreateDC doesn't work on multi-monitor
// systems for some reason.
- DeviceContext* new_device = 0;
+ DeviceContext* new_device = nullptr;
if (strlen(displayDevice) > 0) {
vlog.info("Attaching to device %s", (const char*)displayDevice);
new_device = new DeviceDC(displayDevice);
}
if (!new_device) {
vlog.info("Attaching to virtual desktop");
- new_device = new WindowDC(0);
+ new_device = new WindowDC(nullptr);
}
// Get the coordinates of the specified dispay device
diff --git a/win/rfb_win32/SDisplay.h b/win/rfb_win32/SDisplay.h
index 5b55cd66..76780d9e 100644
--- a/win/rfb_win32/SDisplay.h
+++ b/win/rfb_win32/SDisplay.h
@@ -71,31 +71,31 @@ namespace rfb {
// -=- SDesktop interface
- virtual void init(VNCServer* vs);
- virtual void start();
- virtual void stop();
- virtual void terminate();
- virtual void queryConnection(network::Socket* sock,
- const char* userName);
- virtual void handleClipboardRequest();
- virtual void handleClipboardAnnounce(bool available);
- virtual void handleClipboardData(const char* data);
- virtual void pointerEvent(const Point& pos, int buttonmask);
- virtual void keyEvent(uint32_t keysym, uint32_t keycode, bool down);
+ void init(VNCServer* vs) override;
+ void start() override;
+ void stop() override;
+ void terminate() override;
+ void queryConnection(network::Socket* sock,
+ const char* userName) override;
+ void handleClipboardRequest() override;
+ void handleClipboardAnnounce(bool available) override;
+ void handleClipboardData(const char* data) override;
+ void pointerEvent(const Point& pos, int buttonmask) override;
+ void keyEvent(uint32_t keysym, uint32_t keycode, bool down) override;
// -=- Clipboard events
- virtual void notifyClipboardChanged(bool available);
+ void notifyClipboardChanged(bool available) override;
// -=- Display events
- virtual void notifyDisplayEvent(WMMonitor::Notifier::DisplayEventType evt);
+ void notifyDisplayEvent(WMMonitor::Notifier::DisplayEventType evt) override;
// -=- EventHandler interface
HANDLE getUpdateEvent() {return updateEvent;}
HANDLE getTerminateEvent() {return terminateEvent;}
- virtual void processEvent(HANDLE event);
+ void processEvent(HANDLE event) override;
// -=- Notification of whether or not SDisplay is started
diff --git a/win/rfb_win32/SDisplayCorePolling.h b/win/rfb_win32/SDisplayCorePolling.h
index 9a8bc29b..00de2d40 100644
--- a/win/rfb_win32/SDisplayCorePolling.h
+++ b/win/rfb_win32/SDisplayCorePolling.h
@@ -40,17 +40,17 @@ namespace rfb {
~SDisplayCorePolling();
// - Called by SDisplay to inform Core of the screen size
- virtual void setScreenRect(const Rect& screenRect_);
+ void setScreenRect(const Rect& screenRect_) override;
// - Called by SDisplay to flush updates to the specified tracker
- virtual void flushUpdates();
+ void flushUpdates() override;
- virtual const char* methodName() const { return "Polling"; }
+ const char* methodName() const override { return "Polling"; }
protected:
// - MsgWindow overrides
// processMessage is used to service the cursor & polling timers
- virtual LRESULT processMessage(UINT msg, WPARAM wParam, LPARAM lParam);
+ LRESULT processMessage(UINT msg, WPARAM wParam, LPARAM lParam) override;
// - Hooking subcomponents used to track the desktop state
WMCopyRect copyrect;
diff --git a/win/rfb_win32/SDisplayCoreWMHooks.h b/win/rfb_win32/SDisplayCoreWMHooks.h
index 82557f13..3358a1ee 100644
--- a/win/rfb_win32/SDisplayCoreWMHooks.h
+++ b/win/rfb_win32/SDisplayCoreWMHooks.h
@@ -43,14 +43,14 @@ namespace rfb {
~SDisplayCoreWMHooks();
// - Called by SDisplay to flush updates to the specified tracker
- virtual void flushUpdates();
+ void flushUpdates() override;
- virtual const char* methodName() const { return "VNC Hooks"; }
+ const char* methodName() const override { return "VNC Hooks"; }
protected:
// - MsgWindow overrides
// processMessage is used to service the cursor & polling timers
- virtual LRESULT processMessage(UINT msg, WPARAM wParam, LPARAM lParam);
+ LRESULT processMessage(UINT msg, WPARAM wParam, LPARAM lParam) override;
// - Hooking subcomponents used to track the desktop state
WMHooks hooks;
diff --git a/win/rfb_win32/Security.cxx b/win/rfb_win32/Security.cxx
index 8dfc5b8d..e706ddb4 100644
--- a/win/rfb_win32/Security.cxx
+++ b/win/rfb_win32/Security.cxx
@@ -38,7 +38,7 @@ static LogWriter vlog("SecurityWin32");
Trustee::Trustee(const char* name,
TRUSTEE_FORM form,
TRUSTEE_TYPE type) {
- pMultipleTrustee = 0;
+ pMultipleTrustee = nullptr;
MultipleTrusteeOperation = NO_MULTIPLE_TRUSTEE;
TrusteeForm = form;
TrusteeType = type;
@@ -58,7 +58,7 @@ ExplicitAccess::ExplicitAccess(const char* name,
}
-AccessEntries::AccessEntries() : entries(0), entry_count(0) {}
+AccessEntries::AccessEntries() : entries(nullptr), entry_count(0) {}
AccessEntries::~AccessEntries() {
delete [] entries;
@@ -115,19 +115,19 @@ void Sid::getUserNameAndDomain(char** name, char** domain) {
DWORD nameLen = 0;
DWORD domainLen = 0;
SID_NAME_USE use;
- LookupAccountSid(0, (PSID)*this, 0, &nameLen, 0, &domainLen, &use);
+ LookupAccountSid(nullptr, (PSID)*this, nullptr, &nameLen, nullptr, &domainLen, &use);
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
throw rdr::SystemException("Unable to determine SID name lengths", GetLastError());
vlog.info("nameLen=%lu, domainLen=%lu, use=%d", nameLen, domainLen, use);
*name = new char[nameLen];
*domain = new char[domainLen];
- if (!LookupAccountSid(0, (PSID)*this, *name, &nameLen, *domain, &domainLen, &use))
+ if (!LookupAccountSid(nullptr, (PSID)*this, *name, &nameLen, *domain, &domainLen, &use))
throw rdr::SystemException("Unable to lookup account SID", GetLastError());
}
Sid::Administrators::Administrators() {
- PSID sid = 0;
+ PSID sid = nullptr;
SID_IDENTIFIER_AUTHORITY ntAuth = { SECURITY_NT_AUTHORITY };
if (!AllocateAndInitializeSid(&ntAuth, 2,
SECURITY_BUILTIN_DOMAIN_RID,
@@ -139,7 +139,7 @@ Sid::Administrators::Administrators() {
}
Sid::SYSTEM::SYSTEM() {
- PSID sid = 0;
+ PSID sid = nullptr;
SID_IDENTIFIER_AUTHORITY ntAuth = { SECURITY_NT_AUTHORITY };
if (!AllocateAndInitializeSid(&ntAuth, 1,
SECURITY_LOCAL_SYSTEM_RID,
@@ -151,7 +151,7 @@ Sid::SYSTEM::SYSTEM() {
Sid::FromToken::FromToken(HANDLE h) {
DWORD required = 0;
- GetTokenInformation(h, TokenUser, 0, 0, &required);
+ GetTokenInformation(h, TokenUser, nullptr, 0, &required);
std::vector<uint8_t> tmp(required);
if (!GetTokenInformation(h, TokenUser, tmp.data(), tmp.size(), &required))
throw rdr::SystemException("GetTokenInformation", GetLastError());
diff --git a/win/rfb_win32/Security.h b/win/rfb_win32/Security.h
index a24c359f..a4471f97 100644
--- a/win/rfb_win32/Security.h
+++ b/win/rfb_win32/Security.h
@@ -96,17 +96,17 @@ namespace rfb {
// Helper class for handling & freeing ACLs
struct AccessControlList : public LocalMem {
AccessControlList(int size) : LocalMem(size) {}
- AccessControlList(PACL acl_=0) : LocalMem(acl_) {}
+ AccessControlList(PACL acl_=nullptr) : LocalMem(acl_) {}
operator PACL() {return (PACL)ptr;}
};
// Create a new ACL based on supplied entries and, if supplied, existing ACL
- PACL CreateACL(const AccessEntries& ae, PACL existing_acl=0);
+ PACL CreateACL(const AccessEntries& ae, PACL existing_acl=nullptr);
// Helper class for memory-management of self-relative SecurityDescriptors
struct SecurityDescriptorPtr : LocalMem {
SecurityDescriptorPtr(int size) : LocalMem(size) {}
- SecurityDescriptorPtr(PSECURITY_DESCRIPTOR sd_=0) : LocalMem(sd_) {}
+ SecurityDescriptorPtr(PSECURITY_DESCRIPTOR sd_=nullptr) : LocalMem(sd_) {}
PSECURITY_DESCRIPTOR takeSD() {return (PSECURITY_DESCRIPTOR)takePtr();}
};
diff --git a/win/rfb_win32/SecurityPage.cxx b/win/rfb_win32/SecurityPage.cxx
index 600a8a34..a6f026cf 100644
--- a/win/rfb_win32/SecurityPage.cxx
+++ b/win/rfb_win32/SecurityPage.cxx
@@ -40,7 +40,7 @@ static LogWriter vlog("AuthDialog");
/* XXX: This class contains bunch of similar code to unix/vncviewer/CConn.cxx */
SecurityPage::SecurityPage(Security *security_)
- : PropSheetPage(GetModuleHandle(0), MAKEINTRESOURCE(IDD_SECURITY)),
+ : PropSheetPage(GetModuleHandle(nullptr), MAKEINTRESOURCE(IDD_SECURITY)),
security(security_) {
}
@@ -48,7 +48,6 @@ void
SecurityPage::initDialog()
{
list<uint8_t> secTypes;
- list<uint8_t>::iterator i;
if (isItemChecked(IDC_ENC_X509))
enableX509Dialogs();
@@ -58,8 +57,8 @@ SecurityPage::initDialog()
secTypes = security->GetEnabledSecTypes();
/* Process non-VeNCrypt sectypes */
- for (i = secTypes.begin(); i != secTypes.end(); i++) {
- switch (*i) {
+ for (uint8_t type : secTypes) {
+ switch (type) {
case secTypeNone:
enableAuthMethod(IDC_ENC_NONE, IDC_AUTH_NONE);
break;
@@ -70,13 +69,12 @@ SecurityPage::initDialog()
}
list<uint32_t> secTypesExt;
- list<uint32_t>::iterator iext;
secTypesExt = security->GetEnabledExtSecTypes();
/* Process VeNCrypt subtypes */
- for (iext = secTypesExt.begin(); iext != secTypesExt.end(); iext++) {
- switch (*iext) {
+ for (uint32_t type : secTypesExt) {
+ switch (type) {
case secTypePlain:
enableAuthMethod(IDC_ENC_NONE, IDC_AUTH_PLAIN);
break;
diff --git a/win/rfb_win32/SecurityPage.h b/win/rfb_win32/SecurityPage.h
index 258b58e0..62c50388 100644
--- a/win/rfb_win32/SecurityPage.h
+++ b/win/rfb_win32/SecurityPage.h
@@ -39,9 +39,9 @@ public:
virtual void disableX509Dialogs(void) = 0;
virtual void loadVncPasswd(void) = 0;
- virtual void initDialog();
- virtual bool onCommand(int id, int cmd);
- virtual bool onOk();
+ void initDialog() override;
+ bool onCommand(int id, int cmd) override;
+ bool onOk() override;
protected:
Security *security;
diff --git a/win/rfb_win32/Service.cxx b/win/rfb_win32/Service.cxx
index 62230b07..dafa38b5 100644
--- a/win/rfb_win32/Service.cxx
+++ b/win/rfb_win32/Service.cxx
@@ -42,7 +42,7 @@ static LogWriter vlog("Service");
// - Internal service implementation functions
-Service* service = 0;
+Service* service = nullptr;
bool runAsService = false;
VOID WINAPI serviceHandler(DWORD control) {
@@ -93,7 +93,7 @@ VOID WINAPI serviceProc(DWORD dwArgc, LPTSTR* lpszArgv) {
Service::Service(const char* name_) : name(name_) {
vlog.debug("Service");
- status_handle = 0;
+ status_handle = nullptr;
status.dwControlsAccepted = SERVICE_CONTROL_INTERROGATE | SERVICE_ACCEPT_SHUTDOWN | SERVICE_ACCEPT_STOP;
status.dwServiceType = SERVICE_WIN32_OWN_PROCESS | SERVICE_INTERACTIVE_PROCESS;
status.dwWin32ExitCode = NO_ERROR;
@@ -108,8 +108,8 @@ Service::start() {
SERVICE_TABLE_ENTRY entry[2];
entry[0].lpServiceName = (char*)name;
entry[0].lpServiceProc = serviceProc;
- entry[1].lpServiceName = NULL;
- entry[1].lpServiceProc = NULL;
+ entry[1].lpServiceName = nullptr;
+ entry[1].lpServiceProc = nullptr;
vlog.debug("entering dispatcher");
if (!SetProcessShutdownParameters(0x100, 0))
vlog.error("unable to set shutdown parameters: %lu", GetLastError());
@@ -125,7 +125,7 @@ Service::setStatus() {
void
Service::setStatus(DWORD state) {
- if (status_handle == 0) {
+ if (status_handle == nullptr) {
vlog.debug("warning - cannot setStatus");
return;
}
@@ -141,7 +141,7 @@ Service::setStatus(DWORD state) {
Service::~Service() {
vlog.debug("~Service");
- service = 0;
+ service = nullptr;
}
@@ -254,7 +254,7 @@ rfb::win32::changeDesktop() {
bool
rfb::win32::emulateCtrlAltDel() {
rfb::win32::Handle sessionEventCad =
- CreateEvent(0, FALSE, FALSE, "Global\\SessionEventTigerVNCCad");
+ CreateEvent(nullptr, FALSE, FALSE, "Global\\SessionEventTigerVNCCad");
SetEvent(sessionEventCad);
return true;
}
@@ -265,7 +265,7 @@ rfb::win32::emulateCtrlAltDel() {
class Logger_EventLog : public Logger {
public:
Logger_EventLog(const char* srcname) : Logger("EventLog") {
- eventlog = RegisterEventSource(NULL, srcname);
+ eventlog = RegisterEventSource(nullptr, srcname);
if (!eventlog)
printf("Unable to open event log:%ld\n", GetLastError());
}
@@ -274,12 +274,12 @@ public:
DeregisterEventSource(eventlog);
}
- virtual void write(int level, const char *logname, const char *message) {
+ void write(int level, const char *logname, const char *message) override {
if (!eventlog) return;
const char* strings[] = {logname, message};
WORD type = EVENTLOG_INFORMATION_TYPE;
if (level == 0) type = EVENTLOG_ERROR_TYPE;
- if (!ReportEvent(eventlog, type, 0, VNC4LogMessage, NULL, 2, 0, strings, NULL)) {
+ if (!ReportEvent(eventlog, type, 0, VNC4LogMessage, nullptr, 2, 0, strings, nullptr)) {
// *** It's not at all clear what is the correct behaviour if this fails...
printf("ReportEvent failed:%ld\n", GetLastError());
}
@@ -289,7 +289,7 @@ protected:
HANDLE eventlog;
};
-static Logger_EventLog* logger = 0;
+static Logger_EventLog* logger = nullptr;
bool rfb::win32::initEventLogLogger(const char* srcname) {
if (logger)
@@ -333,22 +333,22 @@ bool rfb::win32::registerService(const char* name,
// - Register the service
// - Open the SCM
- ServiceHandle scm = OpenSCManager(NULL, NULL, SC_MANAGER_CREATE_SERVICE);
+ ServiceHandle scm = OpenSCManager(nullptr, nullptr, SC_MANAGER_CREATE_SERVICE);
if (!scm)
throw rdr::SystemException("unable to open Service Control Manager", GetLastError());
// - Add the service
- ServiceHandle service = CreateService(scm,
+ ServiceHandle handle = CreateService(scm,
name, display, SC_MANAGER_ALL_ACCESS,
SERVICE_WIN32_OWN_PROCESS | SERVICE_INTERACTIVE_PROCESS,
SERVICE_AUTO_START, SERVICE_ERROR_IGNORE,
- cmdline.c_str(), NULL, NULL, NULL, NULL, NULL);
- if (!service)
+ cmdline.c_str(), nullptr, nullptr, nullptr, nullptr, nullptr);
+ if (!handle)
throw rdr::SystemException("unable to create service", GetLastError());
// - Set a description
SERVICE_DESCRIPTION sdesc = {(LPTSTR)desc};
- ChangeServiceConfig2(service, SERVICE_CONFIG_DESCRIPTION, &sdesc);
+ ChangeServiceConfig2(handle, SERVICE_CONFIG_DESCRIPTION, &sdesc);
// - Register the event log source
RegKey hk, hk2;
@@ -378,15 +378,15 @@ bool rfb::win32::registerService(const char* name,
bool rfb::win32::unregisterService(const char* name) {
// - Open the SCM
- ServiceHandle scm = OpenSCManager(NULL, NULL, SC_MANAGER_CREATE_SERVICE);
+ ServiceHandle scm = OpenSCManager(nullptr, nullptr, SC_MANAGER_CREATE_SERVICE);
if (!scm)
throw rdr::SystemException("unable to open Service Control Manager", GetLastError());
// - Create the service
- ServiceHandle service = OpenService(scm, name, SC_MANAGER_ALL_ACCESS);
- if (!service)
+ ServiceHandle handle = OpenService(scm, name, SC_MANAGER_ALL_ACCESS);
+ if (!handle)
throw rdr::SystemException("unable to locate the service", GetLastError());
- if (!DeleteService(service))
+ if (!DeleteService(handle))
throw rdr::SystemException("unable to remove the service", GetLastError());
// - Register the event log source
@@ -405,17 +405,17 @@ bool rfb::win32::unregisterService(const char* name) {
bool rfb::win32::startService(const char* name) {
// - Open the SCM
- ServiceHandle scm = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT);
+ ServiceHandle scm = OpenSCManager(nullptr, nullptr, SC_MANAGER_CONNECT);
if (!scm)
throw rdr::SystemException("unable to open Service Control Manager", GetLastError());
// - Locate the service
- ServiceHandle service = OpenService(scm, name, SERVICE_START);
- if (!service)
+ ServiceHandle handle = OpenService(scm, name, SERVICE_START);
+ if (!handle)
throw rdr::SystemException("unable to open the service", GetLastError());
// - Start the service
- if (!StartService(service, 0, NULL))
+ if (!StartService(handle, 0, nullptr))
throw rdr::SystemException("unable to start the service", GetLastError());
Sleep(500);
@@ -425,18 +425,18 @@ bool rfb::win32::startService(const char* name) {
bool rfb::win32::stopService(const char* name) {
// - Open the SCM
- ServiceHandle scm = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT);
+ ServiceHandle scm = OpenSCManager(nullptr, nullptr, SC_MANAGER_CONNECT);
if (!scm)
throw rdr::SystemException("unable to open Service Control Manager", GetLastError());
// - Locate the service
- ServiceHandle service = OpenService(scm, name, SERVICE_STOP);
- if (!service)
+ ServiceHandle handle = OpenService(scm, name, SERVICE_STOP);
+ if (!handle)
throw rdr::SystemException("unable to open the service", GetLastError());
// - Start the service
SERVICE_STATUS status;
- if (!ControlService(service, SERVICE_CONTROL_STOP, &status))
+ if (!ControlService(handle, SERVICE_CONTROL_STOP, &status))
throw rdr::SystemException("unable to stop the service", GetLastError());
Sleep(500);
@@ -446,18 +446,18 @@ bool rfb::win32::stopService(const char* name) {
DWORD rfb::win32::getServiceState(const char* name) {
// - Open the SCM
- ServiceHandle scm = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT);
+ ServiceHandle scm = OpenSCManager(nullptr, nullptr, SC_MANAGER_CONNECT);
if (!scm)
throw rdr::SystemException("unable to open Service Control Manager", GetLastError());
// - Locate the service
- ServiceHandle service = OpenService(scm, name, SERVICE_INTERROGATE);
- if (!service)
+ ServiceHandle handle = OpenService(scm, name, SERVICE_INTERROGATE);
+ if (!handle)
throw rdr::SystemException("unable to open the service", GetLastError());
// - Get the service status
SERVICE_STATUS status;
- if (!ControlService(service, SERVICE_CONTROL_INTERROGATE, (SERVICE_STATUS*)&status))
+ if (!ControlService(handle, SERVICE_CONTROL_INTERROGATE, (SERVICE_STATUS*)&status))
throw rdr::SystemException("unable to query the service", GetLastError());
return status.dwCurrentState;
diff --git a/win/rfb_win32/SocketManager.cxx b/win/rfb_win32/SocketManager.cxx
index 015ba549..57b65aef 100644
--- a/win/rfb_win32/SocketManager.cxx
+++ b/win/rfb_win32/SocketManager.cxx
@@ -50,7 +50,7 @@ SocketManager::~SocketManager() {
static void requestAddressChangeEvents(network::SocketListener* sock_) {
DWORD dummy = 0;
- if (WSAIoctl(sock_->getFd(), SIO_ADDRESS_LIST_CHANGE, 0, 0, 0, 0, &dummy, 0, 0) == SOCKET_ERROR) {
+ if (WSAIoctl(sock_->getFd(), SIO_ADDRESS_LIST_CHANGE, nullptr, 0, nullptr, 0, &dummy, nullptr, nullptr) == SOCKET_ERROR) {
DWORD err = WSAGetLastError();
if (err != WSAEWOULDBLOCK)
vlog.error("Unable to track address changes: 0x%08x", (unsigned)err);
@@ -210,7 +210,7 @@ void SocketManager::processEvent(HANDLE event) {
network::Socket* new_sock = li.sock->accept();
if (new_sock && li.disable) {
delete new_sock;
- new_sock = 0;
+ new_sock = nullptr;
}
if (new_sock)
addSocket(new_sock, li.server, false);
@@ -229,11 +229,11 @@ void SocketManager::processEvent(HANDLE event) {
try {
// Process data from an active connection
- WSANETWORKEVENTS events;
+ WSANETWORKEVENTS network_events;
long eventMask;
// Fetch why this event notification triggered
- if (WSAEnumNetworkEvents(ci.sock->getFd(), event, &events) == SOCKET_ERROR)
+ if (WSAEnumNetworkEvents(ci.sock->getFd(), event, &network_events) == SOCKET_ERROR)
throw rdr::SystemException("unable to get WSAEnumNetworkEvents:%u", WSAGetLastError());
// Cancel event notification for this socket
@@ -245,14 +245,14 @@ void SocketManager::processEvent(HANDLE event) {
// Call the socket server to process the event
- if (events.lNetworkEvents & FD_WRITE) {
+ if (network_events.lNetworkEvents & FD_WRITE) {
ci.server->processSocketWriteEvent(ci.sock);
if (ci.sock->isShutdown()) {
remSocket(ci.sock);
return;
}
}
- if (events.lNetworkEvents & (FD_READ | FD_CLOSE)) {
+ if (network_events.lNetworkEvents & (FD_READ | FD_CLOSE)) {
ci.server->processSocketReadEvent(ci.sock);
if (ci.sock->isShutdown()) {
remSocket(ci.sock);
diff --git a/win/rfb_win32/SocketManager.h b/win/rfb_win32/SocketManager.h
index 809c470e..4302bbbe 100644
--- a/win/rfb_win32/SocketManager.h
+++ b/win/rfb_win32/SocketManager.h
@@ -61,7 +61,7 @@ namespace rfb {
// VNCServer.
void addListener(network::SocketListener* sock_,
VNCServer* srvr,
- AddressChangeNotifier* acn = 0);
+ AddressChangeNotifier* acn = nullptr);
// Remove and delete a listening socket.
void remListener(network::SocketListener* sock);
@@ -75,8 +75,8 @@ namespace rfb {
void setDisable(VNCServer* srvr, bool disable);
protected:
- virtual int checkTimeouts();
- virtual void processEvent(HANDLE event);
+ int checkTimeouts() override;
+ void processEvent(HANDLE event) override;
virtual void remSocket(network::Socket* sock);
struct ConnInfo {
diff --git a/win/rfb_win32/TrayIcon.h b/win/rfb_win32/TrayIcon.h
index c99203d1..61d2c9ac 100644
--- a/win/rfb_win32/TrayIcon.h
+++ b/win/rfb_win32/TrayIcon.h
@@ -43,7 +43,7 @@ namespace rfb {
nid.hWnd = getHandle();
nid.uID = 0;
- nid.hIcon = 0;
+ nid.hIcon = nullptr;
nid.uFlags = NIF_ICON | NIF_MESSAGE;
nid.uCallbackMessage = WM_USER;
}
@@ -54,13 +54,13 @@ namespace rfb {
if (icon == 0) {
return remove();
} else {
- nid.hIcon = (HICON)LoadImage(GetModuleHandle(0), MAKEINTRESOURCE(icon),
+ nid.hIcon = (HICON)LoadImage(GetModuleHandle(nullptr), MAKEINTRESOURCE(icon),
IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_SHARED);
return refresh();
}
}
bool setToolTip(const char* text) {
- if (text == 0) {
+ if (text == nullptr) {
nid.uFlags &= ~NIF_TIP;
} else {
const int tipLen = sizeof(nid.szTip)/sizeof(char);
diff --git a/win/rfb_win32/WMCursor.cxx b/win/rfb_win32/WMCursor.cxx
index 32a89930..54e31cdc 100644
--- a/win/rfb_win32/WMCursor.cxx
+++ b/win/rfb_win32/WMCursor.cxx
@@ -32,8 +32,8 @@ using namespace rfb::win32;
static LogWriter vlog("WMCursor");
-WMCursor::WMCursor() : cursor(0) {
- cursor = (HCURSOR)LoadImage(0, IDC_ARROW, IMAGE_CURSOR, 0, 0, LR_DEFAULTSIZE | LR_SHARED);
+WMCursor::WMCursor() : cursor(nullptr) {
+ cursor = (HCURSOR)LoadImage(nullptr, IDC_ARROW, IMAGE_CURSOR, 0, 0, LR_DEFAULTSIZE | LR_SHARED);
}
WMCursor::~WMCursor() {
diff --git a/win/rfb_win32/WMCursor.h b/win/rfb_win32/WMCursor.h
index f4366583..465331de 100644
--- a/win/rfb_win32/WMCursor.h
+++ b/win/rfb_win32/WMCursor.h
@@ -40,7 +40,7 @@ namespace rfb {
HCURSOR cursor;
Point position;
bool visible;
- Info() : cursor(0), visible(false) {}
+ Info() : cursor(nullptr), visible(false) {}
bool operator!=(const Info& info) {
return ((cursor != info.cursor) ||
(position != info.position) ||
diff --git a/win/rfb_win32/WMHooks.cxx b/win/rfb_win32/WMHooks.cxx
index 017972ba..cb2e0275 100644
--- a/win/rfb_win32/WMHooks.cxx
+++ b/win/rfb_win32/WMHooks.cxx
@@ -65,52 +65,52 @@ static WM_Hooks_EnableRealInputs_proto WM_Hooks_EnableRealInputs;
static void LoadHooks()
{
- if (hooksLibrary != NULL)
+ if (hooksLibrary != nullptr)
return;
hooksLibrary = LoadLibrary("wm_hooks.dll");
- if (hooksLibrary == NULL)
+ if (hooksLibrary == nullptr)
return;
WM_Hooks_WindowChanged = (WM_Hooks_WMVAL_proto)(void*)GetProcAddress(hooksLibrary, "WM_Hooks_WindowChanged");
- if (WM_Hooks_WindowChanged == NULL)
+ if (WM_Hooks_WindowChanged == nullptr)
goto error;
WM_Hooks_WindowBorderChanged = (WM_Hooks_WMVAL_proto)(void*)GetProcAddress(hooksLibrary, "WM_Hooks_WindowBorderChanged");
- if (WM_Hooks_WindowBorderChanged == NULL)
+ if (WM_Hooks_WindowBorderChanged == nullptr)
goto error;
WM_Hooks_WindowClientAreaChanged = (WM_Hooks_WMVAL_proto)(void*)GetProcAddress(hooksLibrary, "WM_Hooks_WindowClientAreaChanged");
- if (WM_Hooks_WindowClientAreaChanged == NULL)
+ if (WM_Hooks_WindowClientAreaChanged == nullptr)
goto error;
WM_Hooks_RectangleChanged = (WM_Hooks_WMVAL_proto)(void*)GetProcAddress(hooksLibrary, "WM_Hooks_RectangleChanged");
- if (WM_Hooks_RectangleChanged == NULL)
+ if (WM_Hooks_RectangleChanged == nullptr)
goto error;
#ifdef _DEBUG
WM_Hooks_Diagnostic = (WM_Hooks_WMVAL_proto)(void*)GetProcAddress(hooksLibrary, "WM_Hooks_Diagnostic");
- if (WM_Hooks_Diagnostic == NULL)
+ if (WM_Hooks_Diagnostic == nullptr)
goto error;
#endif
WM_Hooks_Install = (WM_Hooks_Install_proto)(void*)GetProcAddress(hooksLibrary, "WM_Hooks_Install");
- if (WM_Hooks_Install == NULL)
+ if (WM_Hooks_Install == nullptr)
goto error;
WM_Hooks_Remove = (WM_Hooks_Remove_proto)(void*)GetProcAddress(hooksLibrary, "WM_Hooks_Remove");
- if (WM_Hooks_Remove == NULL)
+ if (WM_Hooks_Remove == nullptr)
goto error;
#ifdef _DEBUG
WM_Hooks_SetDiagnosticRange = (WM_Hooks_SetDiagnosticRange_proto)(void*)GetProcAddress(hooksLibrary, "WM_Hooks_SetDiagnosticRange");
- if (WM_Hooks_SetDiagnosticRange == NULL)
+ if (WM_Hooks_SetDiagnosticRange == nullptr)
goto error;
#endif
WM_Hooks_EnableRealInputs = (WM_Hooks_EnableRealInputs_proto)(void*)GetProcAddress(hooksLibrary, "WM_Hooks_EnableRealInputs");
- if (WM_Hooks_EnableRealInputs == NULL)
+ if (WM_Hooks_EnableRealInputs == nullptr)
goto error;
return;
error:
FreeLibrary(hooksLibrary);
- hooksLibrary = NULL;
+ hooksLibrary = nullptr;
}
@@ -120,13 +120,13 @@ public:
void stop();
DWORD getThreadId() { return thread_id; }
protected:
- virtual void worker();
+ void worker() override;
protected:
bool active;
DWORD thread_id;
};
-static WMHooksThread* hook_mgr = 0;
+static WMHooksThread* hook_mgr = nullptr;
static std::list<WMHooks*> hooks;
static os::Mutex hook_mgr_lock;
@@ -134,7 +134,7 @@ static os::Mutex hook_mgr_lock;
static bool StartHookThread() {
if (hook_mgr)
return true;
- if (hooksLibrary == NULL)
+ if (hooksLibrary == nullptr)
return false;
vlog.debug("creating thread");
hook_mgr = new WMHooksThread();
@@ -146,7 +146,7 @@ static bool StartHookThread() {
vlog.error("failed to initialise hooks");
hook_mgr->stop();
delete hook_mgr;
- hook_mgr = 0;
+ hook_mgr = nullptr;
return false;
}
return true;
@@ -160,7 +160,7 @@ static void StopHookThread() {
vlog.debug("closing thread");
hook_mgr->stop();
delete hook_mgr;
- hook_mgr = 0;
+ hook_mgr = nullptr;
}
@@ -220,7 +220,7 @@ WMHooksThread::worker() {
thread_id = GetCurrentThreadId();
- while (active && GetMessage(&msg, NULL, 0, 0)) {
+ while (active && GetMessage(&msg, nullptr, 0, 0)) {
count++;
if (msg.message == WM_TIMER) {
@@ -306,7 +306,7 @@ WMHooksThread::stop() {
// -=- WMHooks class
-rfb::win32::WMHooks::WMHooks() : updateEvent(0) {
+rfb::win32::WMHooks::WMHooks() : updateEvent(nullptr) {
LoadHooks();
}
@@ -358,7 +358,7 @@ rfb::win32::WMBlockInput::~WMBlockInput() {
static bool blocking = false;
static bool blockRealInputs(bool block_) {
// NB: Requires blockMutex to be held!
- if (hooksLibrary == NULL)
+ if (hooksLibrary == nullptr)
return false;
if (block_) {
if (blocking)
diff --git a/win/rfb_win32/WMNotifier.cxx b/win/rfb_win32/WMNotifier.cxx
index 81b4fa51..894add1c 100644
--- a/win/rfb_win32/WMNotifier.cxx
+++ b/win/rfb_win32/WMNotifier.cxx
@@ -34,7 +34,7 @@ using namespace rfb::win32;
static LogWriter vlog("WMMonitor");
-WMMonitor::WMMonitor() : MsgWindow("WMMonitor"), notifier(0) {
+WMMonitor::WMMonitor() : MsgWindow("WMMonitor"), notifier(nullptr) {
}
WMMonitor::~WMMonitor() {
diff --git a/win/rfb_win32/WMNotifier.h b/win/rfb_win32/WMNotifier.h
index 3855430b..937a655d 100644
--- a/win/rfb_win32/WMNotifier.h
+++ b/win/rfb_win32/WMNotifier.h
@@ -55,7 +55,7 @@ namespace rfb {
protected:
// - Internal MsgWindow callback
- virtual LRESULT processMessage(UINT msg, WPARAM wParam, LPARAM lParam);
+ LRESULT processMessage(UINT msg, WPARAM wParam, LPARAM lParam) override;
Notifier* notifier;
};
diff --git a/win/rfb_win32/WMPoller.h b/win/rfb_win32/WMPoller.h
index 851b69f4..0783e4ff 100644
--- a/win/rfb_win32/WMPoller.h
+++ b/win/rfb_win32/WMPoller.h
@@ -38,7 +38,7 @@ namespace rfb {
class WMPoller {
public:
- WMPoller() : ut(0) {}
+ WMPoller() : ut(nullptr) {}
bool processEvent();
bool setUpdateTracker(UpdateTracker* ut);
diff --git a/win/rfb_win32/WMWindowCopyRect.cxx b/win/rfb_win32/WMWindowCopyRect.cxx
index 4d69d54b..ec6e1fdc 100644
--- a/win/rfb_win32/WMWindowCopyRect.cxx
+++ b/win/rfb_win32/WMWindowCopyRect.cxx
@@ -33,7 +33,7 @@ static LogWriter vlog("WMCopyRect");
// -=- WMHooks class
-rfb::win32::WMCopyRect::WMCopyRect() : ut(0), fg_window(0) {
+rfb::win32::WMCopyRect::WMCopyRect() : ut(nullptr), fg_window(nullptr) {
}
bool
@@ -56,10 +56,10 @@ rfb::win32::WMCopyRect::processEvent() {
fg_window = window;
fg_window_rect = winrect;
} else {
- fg_window = 0;
+ fg_window = nullptr;
}
} else {
- fg_window = 0;
+ fg_window = nullptr;
}
return false;
}
diff --git a/win/rfb_win32/Win32Util.cxx b/win/rfb_win32/Win32Util.cxx
index ed6b70cb..c3b7ad19 100644
--- a/win/rfb_win32/Win32Util.cxx
+++ b/win/rfb_win32/Win32Util.cxx
@@ -44,7 +44,7 @@ FileVersionInfo::FileVersionInfo(const char* filename) {
// Attempt to open the file, to cause Access Denied, etc, errors
// to be correctly reported, since the GetFileVersionInfoXXX calls lie...
{
- Handle file(CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0));
+ Handle file(CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr));
if (file.h == INVALID_HANDLE_VALUE)
throw rdr::SystemException("Failed to open file", GetLastError());
}
@@ -77,7 +77,7 @@ const char* FileVersionInfo::getVerString(const char* name, DWORD langId) {
infoName = format("\\StringFileInfo\\%s\\%s", langIdStr.c_str(), name);
// Locate the required version string within the version info
- char* buffer = 0;
+ char* buffer = nullptr;
UINT length = 0;
if (!VerQueryValue(buf, infoName.c_str(), (void**)&buffer, &length)) {
printf("unable to find %s version string", infoName.c_str());
@@ -104,13 +104,13 @@ void centerWindow(HWND handle, const RECT& r) {
int x = (r.left + r.right - w)/2;
int y = (r.top + r.bottom - h)/2;
UINT flags = SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_NOSIZE;
- SetWindowPos(handle, 0, x, y, 0, 0, flags);
+ SetWindowPos(handle, nullptr, x, y, 0, 0, flags);
}
void resizeWindow(HWND handle, int width, int height) {
RECT r;
GetWindowRect(handle, &r);
- SetWindowPos(handle, 0, 0, 0, width, height, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_NOMOVE);
+ SetWindowPos(handle, nullptr, 0, 0, width, height, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_NOMOVE);
centerWindow(handle, r);
}
diff --git a/win/rfb_win32/Win32Util.h b/win/rfb_win32/Win32Util.h
index 24d5905d..927ca1e2 100644
--- a/win/rfb_win32/Win32Util.h
+++ b/win/rfb_win32/Win32Util.h
@@ -30,7 +30,7 @@ namespace rfb {
namespace win32 {
struct FileVersionInfo {
- FileVersionInfo(const char* filename=0);
+ FileVersionInfo(const char* filename=nullptr);
~FileVersionInfo();
const char* getVerString(const char* name, DWORD langId = 0x080904b0);
private:
diff --git a/win/vncconfig/Authentication.h b/win/vncconfig/Authentication.h
index a69f7592..1123678f 100644
--- a/win/vncconfig/Authentication.h
+++ b/win/vncconfig/Authentication.h
@@ -43,11 +43,11 @@ namespace rfb {
class SecPage : public SecurityPage {
public:
SecPage(const RegKey& rk)
- : SecurityPage(NULL), regKey(rk) {
+ : SecurityPage(nullptr), regKey(rk) {
security = new SecurityServer();
}
- void initDialog() {
+ void initDialog() override {
SecurityPage::initDialog();
setItemChecked(IDC_QUERY_CONNECT, rfb::Server::queryConnect);
@@ -55,7 +55,7 @@ namespace rfb {
onCommand(IDC_AUTH_NONE, 0);
}
- bool onCommand(int id, int cmd) {
+ bool onCommand(int id, int cmd) override {
SecurityPage::onCommand(id, cmd);
setChanged(true);
@@ -78,16 +78,16 @@ namespace rfb {
return true;
}
- bool onOk() {
+ bool onOk() override {
SecurityPage::onOk();
if (isItemChecked(IDC_AUTH_VNC))
verifyVncPassword(regKey);
else if (haveVncPassword() &&
- MsgBox(0, "The VNC authentication method is disabled, but a password is still stored for it.\n"
+ MsgBox(nullptr, "The VNC authentication method is disabled, but a password is still stored for it.\n"
"Do you want to remove the VNC authentication password from the registry?",
MB_ICONWARNING | MB_YESNO) == IDYES) {
- regKey.setBinary("Password", 0, 0);
+ regKey.setBinary("Password", nullptr, 0);
}
#ifdef HAVE_GNUTLS
@@ -119,23 +119,23 @@ namespace rfb {
static void verifyVncPassword(const RegKey& regKey) {
if (!haveVncPassword()) {
- MsgBox(0, "The VNC authentication method is enabled, but no password is specified.\n"
+ MsgBox(nullptr, "The VNC authentication method is enabled, but no password is specified.\n"
"The password dialog will now be shown.", MB_ICONINFORMATION | MB_OK);
PasswordDialog passwd(regKey, registryInsecure);
passwd.showDialog();
}
}
- virtual void loadX509Certs(void) {}
- virtual void enableX509Dialogs(void) {
+ void loadX509Certs(void) override {}
+ void enableX509Dialogs(void) override {
enableItem(IDC_LOAD_CERT, true);
enableItem(IDC_LOAD_CERTKEY, true);
}
- virtual void disableX509Dialogs(void) {
+ void disableX509Dialogs(void) override {
enableItem(IDC_LOAD_CERT, false);
enableItem(IDC_LOAD_CERTKEY, false);
}
- virtual void loadVncPasswd() {
+ void loadVncPasswd() override {
enableItem(IDC_AUTH_VNC_PASSWD, isItemChecked(IDC_AUTH_VNC));
}
@@ -165,10 +165,10 @@ namespace rfb {
ofn.nMaxFile = sizeof(filename);
ofn.lpstrFilter = (char*)filter;
ofn.nFilterIndex = 1;
- ofn.lpstrFileTitle = NULL;
+ ofn.lpstrFileTitle = nullptr;
ofn.nMaxFileTitle = 0;
ofn.lpstrTitle = (char*)title;
- ofn.lpstrInitialDir = NULL;
+ ofn.lpstrInitialDir = nullptr;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
if (GetOpenFileName(&ofn)==TRUE) {
diff --git a/win/vncconfig/Connections.h b/win/vncconfig/Connections.h
index fcaae203..a540bd76 100644
--- a/win/vncconfig/Connections.h
+++ b/win/vncconfig/Connections.h
@@ -41,12 +41,12 @@ namespace rfb {
class ConnHostDialog : public Dialog {
public:
- ConnHostDialog() : Dialog(GetModuleHandle(0)) {}
+ ConnHostDialog() : Dialog(GetModuleHandle(nullptr)) {}
bool showDialog(const char* pat) {
pattern = pat;
return Dialog::showDialog(MAKEINTRESOURCE(IDD_CONN_HOST));
}
- void initDialog() {
+ void initDialog() override {
if (pattern.empty())
pattern = "+";
@@ -60,7 +60,7 @@ namespace rfb {
setItemString(IDC_HOST_PATTERN, &pattern.c_str()[1]);
pattern.clear();
}
- bool onOk() {
+ bool onOk() override {
std::string newPat;
if (isItemChecked(IDC_ALLOW))
newPat = '+';
@@ -74,7 +74,7 @@ namespace rfb {
network::TcpFilter::Pattern pat(network::TcpFilter::parsePattern(newPat.c_str()));
pattern = network::TcpFilter::patternToStr(pat);
} catch(rdr::Exception& e) {
- MsgBox(NULL, e.str(), MB_ICONEXCLAMATION | MB_OK);
+ MsgBox(nullptr, e.str(), MB_ICONEXCLAMATION | MB_OK);
return false;
}
return true;
@@ -87,8 +87,8 @@ namespace rfb {
class ConnectionsPage : public PropSheetPage {
public:
ConnectionsPage(const RegKey& rk)
- : PropSheetPage(GetModuleHandle(0), MAKEINTRESOURCE(IDD_CONNECTIONS)), regKey(rk) {}
- void initDialog() {
+ : PropSheetPage(GetModuleHandle(nullptr), MAKEINTRESOURCE(IDD_CONNECTIONS)), regKey(rk) {}
+ void initDialog() override {
vlog.debug("set IDC_PORT %d", (int)port_number);
setItemInt(IDC_PORT, port_number ? port_number : 5900);
setItemChecked(IDC_RFB_ENABLE, port_number != 0);
@@ -108,7 +108,7 @@ namespace rfb {
onCommand(IDC_RFB_ENABLE, EN_CHANGE);
}
- bool onCommand(int id, int cmd) {
+ bool onCommand(int id, int cmd) override {
switch (id) {
case IDC_HOSTS:
{
@@ -221,7 +221,7 @@ namespace rfb {
}
return false;
}
- bool onOk() {
+ bool onOk() override {
regKey.setInt("PortNumber", isItemChecked(IDC_RFB_ENABLE) ? getItemInt(IDC_PORT) : 0);
regKey.setInt("IdleTimeout", getItemInt(IDC_IDLE_TIMEOUT));
regKey.setInt("LocalHost", isItemChecked(IDC_LOCALHOST));
diff --git a/win/vncconfig/Desktop.h b/win/vncconfig/Desktop.h
index d7ed0bc8..a5058389 100644
--- a/win/vncconfig/Desktop.h
+++ b/win/vncconfig/Desktop.h
@@ -29,8 +29,8 @@ namespace rfb {
class DesktopPage : public PropSheetPage {
public:
DesktopPage(const RegKey& rk)
- : PropSheetPage(GetModuleHandle(0), MAKEINTRESOURCE(IDD_DESKTOP)), regKey(rk) {}
- void initDialog() {
+ : PropSheetPage(GetModuleHandle(nullptr), MAKEINTRESOURCE(IDD_DESKTOP)), regKey(rk) {}
+ void initDialog() override {
const char *action(rfb::win32::SDisplay::disconnectAction);
bool disconnectLock = stricmp(action, "Lock") == 0;
bool disconnectLogoff = stricmp(action, "Logoff") == 0;
@@ -40,7 +40,7 @@ namespace rfb {
setItemChecked(IDC_REMOVE_WALLPAPER, rfb::win32::SDisplay::removeWallpaper);
setItemChecked(IDC_DISABLE_EFFECTS, rfb::win32::SDisplay::disableEffects);
}
- bool onCommand(int id, int /*cmd*/) {
+ bool onCommand(int id, int /*cmd*/) override {
switch (id) {
case IDC_DISCONNECT_LOGOFF:
case IDC_DISCONNECT_LOCK:
@@ -58,7 +58,7 @@ namespace rfb {
}
return false;
}
- bool onOk() {
+ bool onOk() override {
const char* action = "None";
if (isItemChecked(IDC_DISCONNECT_LOGOFF))
action = "Logoff";
diff --git a/win/vncconfig/Hooking.h b/win/vncconfig/Hooking.h
index e775f290..9f84230d 100644
--- a/win/vncconfig/Hooking.h
+++ b/win/vncconfig/Hooking.h
@@ -31,15 +31,15 @@ namespace rfb {
class HookingPage : public PropSheetPage {
public:
HookingPage(const RegKey& rk)
- : PropSheetPage(GetModuleHandle(0), MAKEINTRESOURCE(IDD_HOOKING)), regKey(rk) {}
- void initDialog() {
+ : PropSheetPage(GetModuleHandle(nullptr), MAKEINTRESOURCE(IDD_HOOKING)), regKey(rk) {}
+ void initDialog() override {
setItemChecked(IDC_USEPOLLING, rfb::win32::SDisplay::updateMethod == 0);
setItemChecked(IDC_USEHOOKS, (rfb::win32::SDisplay::updateMethod == 1));
setItemChecked(IDC_POLLCONSOLES, rfb::win32::WMPoller::poll_console_windows);
setItemChecked(IDC_CAPTUREBLT, rfb::win32::DeviceFrameBuffer::useCaptureBlt);
onCommand(IDC_USEHOOKS, 0);
}
- bool onCommand(int id, int /*cmd*/) {
+ bool onCommand(int id, int /*cmd*/) override {
switch (id) {
case IDC_USEPOLLING:
case IDC_USEHOOKS:
@@ -54,7 +54,7 @@ namespace rfb {
}
return false;
}
- bool onOk() {
+ bool onOk() override {
if (isItemChecked(IDC_USEPOLLING))
regKey.setInt("UpdateMethod", 0);
if (isItemChecked(IDC_USEHOOKS))
diff --git a/win/vncconfig/Inputs.h b/win/vncconfig/Inputs.h
index a2ac5a46..2ffdda03 100644
--- a/win/vncconfig/Inputs.h
+++ b/win/vncconfig/Inputs.h
@@ -33,9 +33,9 @@ namespace rfb {
class InputsPage : public PropSheetPage {
public:
InputsPage(const RegKey& rk)
- : PropSheetPage(GetModuleHandle(0), MAKEINTRESOURCE(IDD_INPUTS)),
+ : PropSheetPage(GetModuleHandle(nullptr), MAKEINTRESOURCE(IDD_INPUTS)),
regKey(rk), enableAffectSSaver(true) {}
- void initDialog() {
+ void initDialog() override {
setItemChecked(IDC_ACCEPT_KEYS, rfb::Server::acceptKeyEvents);
setItemChecked(IDC_RAW_KEYBOARD, SKeyboard::rawKeyboard);
setItemChecked(IDC_ACCEPT_PTR, rfb::Server::acceptPointerEvents);
@@ -49,7 +49,7 @@ namespace rfb {
enableAffectSSaver = false;
enableItem(IDC_AFFECT_SCREENSAVER, enableAffectSSaver);
}
- bool onCommand(int /*id*/, int /*cmd*/) {
+ bool onCommand(int /*id*/, int /*cmd*/) override {
BOOL inputResetsBlocked;
SystemParametersInfo(SPI_GETBLOCKSENDINPUTRESETS, 0, &inputResetsBlocked, 0);
setChanged((rfb::Server::acceptKeyEvents != isItemChecked(IDC_ACCEPT_KEYS)) ||
@@ -61,7 +61,7 @@ namespace rfb {
(enableAffectSSaver && (!inputResetsBlocked != isItemChecked(IDC_AFFECT_SCREENSAVER))));
return false;
}
- bool onOk() {
+ bool onOk() override {
regKey.setBool("AcceptKeyEvents", isItemChecked(IDC_ACCEPT_KEYS));
regKey.setBool("RawKeyboard", isItemChecked(IDC_RAW_KEYBOARD));
regKey.setBool("AcceptPointerEvents", isItemChecked(IDC_ACCEPT_PTR));
@@ -70,7 +70,7 @@ namespace rfb {
regKey.setBool("DisableLocalInputs", isItemChecked(IDC_DISABLE_LOCAL_INPUTS));
if (enableAffectSSaver) {
BOOL blocked = !isItemChecked(IDC_AFFECT_SCREENSAVER);
- SystemParametersInfo(SPI_SETBLOCKSENDINPUTRESETS, blocked, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
+ SystemParametersInfo(SPI_SETBLOCKSENDINPUTRESETS, blocked, nullptr, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
}
return true;
}
diff --git a/win/vncconfig/Legacy.cxx b/win/vncconfig/Legacy.cxx
index 3a22bb52..1ea867fb 100644
--- a/win/vncconfig/Legacy.cxx
+++ b/win/vncconfig/Legacy.cxx
@@ -53,7 +53,7 @@ void LegacyPage::LoadPrefs()
try {
winvnc3.openKey(HKEY_LOCAL_MACHINE, "Software\\ORL\\WinVNC3");
int debugMode = winvnc3.getInt("DebugMode", 0);
- const char* debugTarget = 0;
+ const char* debugTarget = nullptr;
if (debugMode & 2) debugTarget = "file";
if (debugMode & 4) debugTarget = "stderr";
if (debugTarget) {
@@ -115,7 +115,7 @@ void LegacyPage::LoadPrefs()
// Finally, save the Hosts value
regKey.setString("Hosts", newHosts.c_str());
} catch (rdr::Exception&) {
- MsgBox(0, "Unable to convert AuthHosts setting to Hosts format.",
+ MsgBox(nullptr, "Unable to convert AuthHosts setting to Hosts format.",
MB_ICONWARNING | MB_OK);
}
} else {
@@ -181,7 +181,7 @@ void LegacyPage::LoadPrefs()
{
regKey.setInt("PortNumber", key.getBool("SocketConnect") ? key.getInt("PortNumber", 5900) : 0);
if (key.getBool("AutoPortSelect", false)) {
- MsgBox(0, "The AutoPortSelect setting is not supported by this release."
+ MsgBox(nullptr, "The AutoPortSelect setting is not supported by this release."
"The port number will default to 5900.",
MB_ICONWARNING | MB_OK);
regKey.setInt("PortNumber", 5900);
@@ -193,7 +193,7 @@ void LegacyPage::LoadPrefs()
if (key.getInt("QuerySetting", 2) != 2) {
regKey.setBool("QueryConnect", key.getInt("QuerySetting") > 2);
- MsgBox(0, "The QuerySetting option has been replaced by QueryConnect."
+ MsgBox(nullptr, "The QuerySetting option has been replaced by QueryConnect."
"Please see the documentation for details of the QueryConnect option.",
MB_ICONWARNING | MB_OK);
}
@@ -222,9 +222,9 @@ void LegacyPage::LoadPrefs()
regKey.setBool("UseHooks", !key.getBool("PollFullScreen", false));
if (key.isValue("AllowShutdown"))
- MsgBox(0, "The AllowShutdown option is not supported by this release.", MB_ICONWARNING | MB_OK);
+ MsgBox(nullptr, "The AllowShutdown option is not supported by this release.", MB_ICONWARNING | MB_OK);
if (key.isValue("AllowEditClients"))
- MsgBox(0, "The AllowEditClients option is not supported by this release.", MB_ICONWARNING | MB_OK);
+ MsgBox(nullptr, "The AllowEditClients option is not supported by this release.", MB_ICONWARNING | MB_OK);
allowProperties = key.getBool("AllowProperties", allowProperties);
}
diff --git a/win/vncconfig/Legacy.h b/win/vncconfig/Legacy.h
index 884a151a..47bec7d6 100644
--- a/win/vncconfig/Legacy.h
+++ b/win/vncconfig/Legacy.h
@@ -35,21 +35,21 @@ namespace rfb {
class LegacyPage : public PropSheetPage {
public:
LegacyPage(const RegKey& rk, bool userSettings_)
- : PropSheetPage(GetModuleHandle(0), MAKEINTRESOURCE(IDD_LEGACY)), regKey(rk), userSettings(userSettings_) {}
- void initDialog() {
+ : PropSheetPage(GetModuleHandle(nullptr), MAKEINTRESOURCE(IDD_LEGACY)), regKey(rk), userSettings(userSettings_) {}
+ void initDialog() override {
setItemChecked(IDC_PROTOCOL_3_3, rfb::Server::protocol3_3);
}
- bool onCommand(int id, int /*cmd*/) {
+ bool onCommand(int id, int /*cmd*/) override {
switch (id) {
case IDC_LEGACY_IMPORT:
{
- DWORD result = MsgBox(0,
+ DWORD result = MsgBox(nullptr,
"Importing your legacy VNC 3.3 settings will overwrite your existing settings.\n"
"Are you sure you wish to continue?",
MB_ICONWARNING | MB_YESNO);
if (result == IDYES) {
LoadPrefs();
- MsgBox(0, "Imported VNC 3.3 settings successfully.",
+ MsgBox(nullptr, "Imported VNC 3.3 settings successfully.",
MB_ICONINFORMATION | MB_OK);
// Sleep to allow RegConfig thread to reload settings
@@ -64,7 +64,7 @@ namespace rfb {
};
return false;
}
- bool onOk() {
+ bool onOk() override {
regKey.setBool("Protocol3.3", isItemChecked(IDC_PROTOCOL_3_3));
return true;
}
diff --git a/win/vncconfig/PasswordDialog.cxx b/win/vncconfig/PasswordDialog.cxx
index f35aeb54..8a7103ca 100644
--- a/win/vncconfig/PasswordDialog.cxx
+++ b/win/vncconfig/PasswordDialog.cxx
@@ -25,7 +25,7 @@ using namespace rfb;
using namespace win32;
PasswordDialog::PasswordDialog(const RegKey& rk, bool registryInsecure_)
- : Dialog(GetModuleHandle(0)), regKey(rk), registryInsecure(registryInsecure_) {
+ : Dialog(GetModuleHandle(nullptr)), regKey(rk), registryInsecure(registryInsecure_) {
}
bool PasswordDialog::showDialog(HWND owner) {
@@ -36,12 +36,12 @@ bool PasswordDialog::onOk() {
std::string password1(getItemString(IDC_PASSWORD1));
std::string password2(getItemString(IDC_PASSWORD2));
if (password1 != password2) {
- MsgBox(0, "The supplied passwords do not match",
+ MsgBox(nullptr, "The supplied passwords do not match",
MB_ICONEXCLAMATION | MB_OK);
return false;
}
if (registryInsecure &&
- (MsgBox(0, "Please note that your password cannot be stored securely on this system. "
+ (MsgBox(nullptr, "Please note that your password cannot be stored securely on this system. "
"Are you sure you wish to continue?",
MB_YESNO | MB_ICONWARNING) == IDNO))
return false;
diff --git a/win/vncconfig/PasswordDialog.h b/win/vncconfig/PasswordDialog.h
index dd23f8e3..06973bb9 100644
--- a/win/vncconfig/PasswordDialog.h
+++ b/win/vncconfig/PasswordDialog.h
@@ -27,8 +27,8 @@ namespace rfb {
class PasswordDialog : public Dialog {
public:
PasswordDialog(const RegKey& rk, bool registryInsecure_);
- bool showDialog(HWND owner=0);
- bool onOk();
+ bool showDialog(HWND owner=nullptr);
+ bool onOk() override;
protected:
const RegKey& regKey;
bool registryInsecure;
diff --git a/win/vncconfig/Sharing.h b/win/vncconfig/Sharing.h
index 0a2bbe40..a6459e5f 100644
--- a/win/vncconfig/Sharing.h
+++ b/win/vncconfig/Sharing.h
@@ -29,20 +29,20 @@ namespace rfb {
class SharingPage : public PropSheetPage {
public:
SharingPage(const RegKey& rk)
- : PropSheetPage(GetModuleHandle(0), MAKEINTRESOURCE(IDD_SHARING)), regKey(rk) {}
- void initDialog() {
+ : PropSheetPage(GetModuleHandle(nullptr), MAKEINTRESOURCE(IDD_SHARING)), regKey(rk) {}
+ void initDialog() override {
setItemChecked(IDC_DISCONNECT_CLIENTS, rfb::Server::disconnectClients);
setItemChecked(IDC_SHARE_NEVER, rfb::Server::neverShared);
setItemChecked(IDC_SHARE_ALWAYS, rfb::Server::alwaysShared);
setItemChecked(IDC_SHARE_CLIENT, !(rfb::Server::neverShared || rfb::Server::alwaysShared));
}
- bool onCommand(int /*id*/, int /*cmd*/) {
+ bool onCommand(int /*id*/, int /*cmd*/) override {
setChanged((isItemChecked(IDC_DISCONNECT_CLIENTS) != rfb::Server::disconnectClients) ||
(isItemChecked(IDC_SHARE_NEVER) != rfb::Server::neverShared) ||
(isItemChecked(IDC_SHARE_ALWAYS) != rfb::Server::alwaysShared));
return true;
}
- bool onOk() {
+ bool onOk() override {
regKey.setBool("DisconnectClients", isItemChecked(IDC_DISCONNECT_CLIENTS));
regKey.setBool("AlwaysShared", isItemChecked(IDC_SHARE_ALWAYS));
regKey.setBool("NeverShared", isItemChecked(IDC_SHARE_NEVER));
diff --git a/win/vncconfig/vncconfig.cxx b/win/vncconfig/vncconfig.cxx
index 2b7eaa1e..b8cb5dc8 100644
--- a/win/vncconfig/vncconfig.cxx
+++ b/win/vncconfig/vncconfig.cxx
@@ -84,9 +84,8 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE /*prev*/, char* /*cmdLine*/, int /*
freopen("CONIN$","rb",stdin);
freopen("CONOUT$","wb",stdout);
freopen("CONOUT$","wb",stderr);
- setbuf(stderr, 0);
+ setbuf(stderr, nullptr);
initStdIOLoggers();
- LogWriter vlog("main");
logParams.setParam("*:stderr:100");
vlog.info("Starting vncconfig applet");
#endif
@@ -130,7 +129,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE /*prev*/, char* /*cmdLine*/, int /*
// Something weird happens on NT 4.0 SP5 but I can't reproduce it on other
// NT 4.0 service pack revisions.
if (e.err == ERROR_INVALID_PARAMETER) {
- MsgBox(0, "Windows reported an error trying to secure the VNC Server settings for this user. "
+ MsgBox(nullptr, "Windows reported an error trying to secure the VNC Server settings for this user. "
"Your settings may not be secure!", MB_ICONWARNING | MB_OK);
} else if (e.err != ERROR_CALL_NOT_IMPLEMENTED &&
e.err != ERROR_NOT_LOGGED_ON) {
@@ -166,14 +165,14 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE /*prev*/, char* /*cmdLine*/, int /*
#ifdef _DEBUG
vlog.debug("capture dialogs=%s", captureDialogs ? "true" : "false");
- sheet.showPropSheet(0, true, false, captureDialogs);
+ sheet.showPropSheet(nullptr, true, false, captureDialogs);
#else
- sheet.showPropSheet(0, true, false);
+ sheet.showPropSheet(nullptr, true, false);
#endif
} catch (rdr::SystemException& e) {
switch (e.err) {
case ERROR_ACCESS_DENIED:
- MsgBox(0, "You do not have sufficient access rights to run the VNC Configuration applet",
+ MsgBox(nullptr, "You do not have sufficient access rights to run the VNC Configuration applet",
MB_ICONSTOP | MB_OK);
return 1;
};
@@ -181,7 +180,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE /*prev*/, char* /*cmdLine*/, int /*
}
} catch (rdr::Exception& e) {
- MsgBox(NULL, e.str(), MB_ICONEXCLAMATION | MB_OK);
+ MsgBox(nullptr, e.str(), MB_ICONEXCLAMATION | MB_OK);
return 1;
}
diff --git a/win/winvnc/AddNewClientDialog.h b/win/winvnc/AddNewClientDialog.h
index 44e15e70..ad34ec23 100644
--- a/win/winvnc/AddNewClientDialog.h
+++ b/win/winvnc/AddNewClientDialog.h
@@ -28,7 +28,7 @@ namespace winvnc {
class AddNewClientDialog : public rfb::win32::Dialog {
public:
- AddNewClientDialog() : Dialog(GetModuleHandle(0)) {}
+ AddNewClientDialog() : Dialog(GetModuleHandle(nullptr)) {}
// - Show the dialog and return true if OK was clicked,
// false in case of error or Cancel
virtual bool showDialog() {
@@ -38,11 +38,11 @@ namespace winvnc {
protected:
// Dialog methods (protected)
- virtual void initDialog() {
+ void initDialog() override {
if (!hostName.empty())
setItemString(IDC_HOST, hostName.c_str());
}
- virtual bool onOk() {
+ bool onOk() override {
hostName = getItemString(IDC_HOST);
return true;
}
diff --git a/win/winvnc/ControlPanel.cxx b/win/winvnc/ControlPanel.cxx
index 1b3c40eb..6c593c45 100644
--- a/win/winvnc/ControlPanel.cxx
+++ b/win/winvnc/ControlPanel.cxx
@@ -16,7 +16,7 @@ using namespace winvnc;
bool ControlPanel::showDialog()
{
- return Dialog::showDialog(MAKEINTRESOURCE(IDD_CONTROL_PANEL), NULL);
+ return Dialog::showDialog(MAKEINTRESOURCE(IDD_CONTROL_PANEL), nullptr);
}
void ControlPanel::initDialog()
@@ -118,7 +118,7 @@ BOOL ControlPanel::dialogProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM /*lPara
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDCANCEL:
- handle = NULL;
+ handle = nullptr;
EndDialog(hwnd, 0);
return TRUE;
default:
@@ -145,7 +145,7 @@ void ControlPanel::SendCommand(DWORD command, int data)
COPYDATASTRUCT copyData;
copyData.dwData = command;
copyData.cbData = 0;
- copyData.lpData = 0;
+ copyData.lpData = nullptr;
getSelConnInfo();
if (data != -1) {
ListConnStatus.Copy(&ListSelConn);
diff --git a/win/winvnc/ControlPanel.h b/win/winvnc/ControlPanel.h
index f64a6081..23aff0a5 100644
--- a/win/winvnc/ControlPanel.h
+++ b/win/winvnc/ControlPanel.h
@@ -20,12 +20,12 @@ namespace winvnc {
class ControlPanel : rfb::win32::Dialog, rfb::win32::ListViewControl {
public:
- ControlPanel(HWND hSTIcon) : Dialog(GetModuleHandle(0)), ListViewControl(){
+ ControlPanel(HWND hSTIcon) : Dialog(GetModuleHandle(nullptr)), ListViewControl(){
m_hSTIcon = hSTIcon;
stop_updating = false;
};
virtual bool showDialog();
- virtual void initDialog();
+ void initDialog() override;
virtual bool onCommand(int cmd);
void UpdateListView(ListConnInfo* LCInfo);
HWND GetHandle() {return handle;};
@@ -33,7 +33,7 @@ namespace winvnc {
~ControlPanel();
ListConnInfo ListConnStatus;
protected:
- virtual BOOL dialogProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
+ BOOL dialogProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) override;
void getSelConnInfo();
HWND m_hSTIcon;
ListConnInfo ListConn;
diff --git a/win/winvnc/ManagedListener.cxx b/win/winvnc/ManagedListener.cxx
index 1a278678..adc074cf 100644
--- a/win/winvnc/ManagedListener.cxx
+++ b/win/winvnc/ManagedListener.cxx
@@ -31,7 +31,7 @@ static LogWriter vlog("ManagedListener");
ManagedListener::ManagedListener(SocketManager* mgr)
-: filter(0), manager(mgr), addrChangeNotifier(0), server(0), port(0), localOnly(false) {
+: filter(nullptr), manager(mgr), addrChangeNotifier(nullptr), server(nullptr), port(0), localOnly(false) {
}
ManagedListener::~ManagedListener() {
@@ -98,7 +98,7 @@ void ManagedListener::refresh() {
if (localOnly)
network::createLocalTcpListeners(&sockets, port);
else
- network::createTcpListeners(&sockets, NULL, port);
+ network::createTcpListeners(&sockets, nullptr, port);
}
} catch (rdr::Exception& e) {
vlog.error("%s", e.str());
diff --git a/win/winvnc/QueryConnectDialog.cxx b/win/winvnc/QueryConnectDialog.cxx
index 26bd9331..bedfe5a9 100644
--- a/win/winvnc/QueryConnectDialog.cxx
+++ b/win/winvnc/QueryConnectDialog.cxx
@@ -44,7 +44,7 @@ static IntParameter timeout("QueryConnectTimeout",
QueryConnectDialog::QueryConnectDialog(network::Socket* sock_,
const char* userName_,
VNCServerWin32* s)
-: Dialog(GetModuleHandle(0)),
+: Dialog(GetModuleHandle(nullptr)),
sock(sock_), peerIp(sock->getPeerAddress()), userName(userName_),
approve(false), server(s) {
}
@@ -73,7 +73,7 @@ void QueryConnectDialog::worker() {
// - Dialog overrides
void QueryConnectDialog::initDialog() {
- if (!SetTimer(handle, 1, 1000, 0))
+ if (!SetTimer(handle, 1, 1000, nullptr))
throw rdr::SystemException("SetTimer", GetLastError());
setItemString(IDC_QUERY_HOST, peerIp.c_str());
if (userName.empty())
diff --git a/win/winvnc/QueryConnectDialog.h b/win/winvnc/QueryConnectDialog.h
index 36e885f9..332e7439 100644
--- a/win/winvnc/QueryConnectDialog.h
+++ b/win/winvnc/QueryConnectDialog.h
@@ -39,11 +39,11 @@ namespace winvnc {
bool isAccepted() const {return approve;}
protected:
// Thread methods
- virtual void worker();
+ void worker() override;
// Dialog methods (protected)
- virtual void initDialog();
- virtual BOOL dialogProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
+ void initDialog() override;
+ BOOL dialogProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) override;
// Custom internal methods
void setCountdownLabel();
diff --git a/win/winvnc/STrayIcon.cxx b/win/winvnc/STrayIcon.cxx
index e7032998..d703f47a 100644
--- a/win/winvnc/STrayIcon.cxx
+++ b/win/winvnc/STrayIcon.cxx
@@ -80,13 +80,13 @@ public:
SetWindowText(getHandle(), "winvnc::IPC_Interface");
// ***
- SetTimer(getHandle(), 1, 3000, 0);
+ SetTimer(getHandle(), 1, 3000, nullptr);
PostMessage(getHandle(), WM_TIMER, 1, 0);
PostMessage(getHandle(), WM_SET_TOOLTIP, 0, 0);
CPanel = new ControlPanel(getHandle());
}
- virtual LRESULT processMessage(UINT msg, WPARAM wParam, LPARAM lParam) {
+ LRESULT processMessage(UINT msg, WPARAM wParam, LPARAM lParam) override {
switch(msg) {
case WM_USER:
@@ -100,7 +100,7 @@ public:
SendMessage(getHandle(), WM_COMMAND, ID_CONTR0L_PANEL, 0);
break;
case WM_RBUTTONUP:
- HMENU menu = LoadMenu(GetModuleHandle(0), MAKEINTRESOURCE(thread.menu));
+ HMENU menu = LoadMenu(GetModuleHandle(nullptr), MAKEINTRESOURCE(thread.menu));
HMENU trayMenu = GetSubMenu(menu, 0);
@@ -123,7 +123,7 @@ public:
// Display the menu
POINT pos;
GetCursorPos(&pos);
- TrackPopupMenu(trayMenu, 0, pos.x, pos.y, 0, getHandle(), 0);
+ TrackPopupMenu(trayMenu, 0, pos.x, pos.y, 0, getHandle(), nullptr);
break;
}
@@ -154,13 +154,13 @@ public:
thread.server.disconnectClients("tray menu disconnect");
break;
case ID_CLOSE:
- if (MsgBox(0, "Are you sure you want to close the server?",
+ if (MsgBox(nullptr, "Are you sure you want to close the server?",
MB_ICONQUESTION | MB_YESNO | MB_DEFBUTTON2) == IDYES) {
if (isServiceProcess()) {
try {
rfb::win32::stopService(VNCServerService::Name);
} catch (rdr::Exception& e) {
- MsgBox(0, e.str(), MB_ICONERROR | MB_OK);
+ MsgBox(nullptr, e.str(), MB_ICONERROR | MB_OK);
}
} else {
thread.server.stop();
@@ -239,7 +239,7 @@ protected:
STrayIconThread::STrayIconThread(VNCServerWin32& sm, UINT inactiveIcon_, UINT activeIcon_,
UINT dis_inactiveIcon_, UINT dis_activeIcon_, UINT menu_)
-: thread_id(-1), windowHandle(0), server(sm),
+: thread_id(-1), windowHandle(nullptr), server(sm),
inactiveIcon(inactiveIcon_), activeIcon(activeIcon_),
dis_inactiveIcon(dis_inactiveIcon_), dis_activeIcon(dis_activeIcon_),
menu(menu_), runTrayIcon(true) {
@@ -266,12 +266,12 @@ void STrayIconThread::worker() {
windowHandle = icon.getHandle();
MSG msg;
- while (runTrayIcon && ::GetMessage(&msg, 0, 0, 0) > 0) {
+ while (runTrayIcon && ::GetMessage(&msg, nullptr, 0, 0) > 0) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
- windowHandle = 0;
+ windowHandle = nullptr;
}
}
diff --git a/win/winvnc/STrayIcon.h b/win/winvnc/STrayIcon.h
index 511c3ae2..1aa7bfbc 100644
--- a/win/winvnc/STrayIcon.h
+++ b/win/winvnc/STrayIcon.h
@@ -42,7 +42,7 @@ namespace winvnc {
friend class STrayIcon;
protected:
- virtual void worker();
+ void worker() override;
os::Mutex* lock;
DWORD thread_id;
diff --git a/win/winvnc/VNCServerService.cxx b/win/winvnc/VNCServerService.cxx
index 09a0707b..8ae4b747 100644
--- a/win/winvnc/VNCServerService.cxx
+++ b/win/winvnc/VNCServerService.cxx
@@ -38,18 +38,18 @@ using namespace win32;
const char* winvnc::VNCServerService::Name = "TigerVNC";
// SendSAS is not available until Windows 7, and missing from MinGW
-static HMODULE sasLibrary = NULL;
+static HMODULE sasLibrary = nullptr;
typedef void WINAPI (*SendSAS_proto)(BOOL AsUser);
-static SendSAS_proto _SendSAS = NULL;
+static SendSAS_proto _SendSAS = nullptr;
VNCServerService::VNCServerService()
: Service(Name)
- , stopServiceEvent(CreateEvent(0, FALSE, FALSE, 0))
- , sessionEvent(CreateEvent(0, FALSE, FALSE, "Global\\SessionEventTigerVNC"))
- , sessionEventCad(CreateEvent(0, FALSE, FALSE, "Global\\SessionEventTigerVNCCad")) {
- if (sasLibrary == NULL) {
+ , stopServiceEvent(CreateEvent(nullptr, FALSE, FALSE, nullptr))
+ , sessionEvent(CreateEvent(nullptr, FALSE, FALSE, "Global\\SessionEventTigerVNC"))
+ , sessionEventCad(CreateEvent(nullptr, FALSE, FALSE, "Global\\SessionEventTigerVNCCad")) {
+ if (sasLibrary == nullptr) {
sasLibrary = LoadLibrary("sas.dll");
- if (sasLibrary != NULL)
+ if (sasLibrary != nullptr)
_SendSAS = (SendSAS_proto)(void*)GetProcAddress(sasLibrary, "SendSAS");
}
// - Set the service-mode logging defaults
@@ -104,8 +104,8 @@ BOOL GetSessionUserTokenWin(OUT LPHANDLE lphUserToken)
// START the app as system
HANDLE LaunchProcessWin(DWORD /*dwSessionId*/)
{
- HANDLE hProcess = NULL;
- HANDLE hToken = NULL;
+ HANDLE hProcess = nullptr;
+ HANDLE hToken = nullptr;
if (GetSessionUserTokenWin(&hToken))
{
ModuleFileName filename;
@@ -116,9 +116,9 @@ HANDLE LaunchProcessWin(DWORD /*dwSessionId*/)
si.cb = sizeof si;
si.dwFlags = STARTF_USESHOWWINDOW;
PROCESS_INFORMATION pi;
- if (CreateProcessAsUser(hToken, NULL, (char*)cmdLine.c_str(),
- NULL, NULL, FALSE, DETACHED_PROCESS,
- NULL, NULL, &si, &pi))
+ if (CreateProcessAsUser(hToken, nullptr, (char*)cmdLine.c_str(),
+ nullptr, nullptr, FALSE, DETACHED_PROCESS,
+ nullptr, nullptr, &si, &pi))
{
CloseHandle(pi.hThread);
hProcess = pi.hProcess;
@@ -132,7 +132,7 @@ DWORD VNCServerService::serviceMain(int /*argc*/, char* /*argv*/ [])
{
ConsoleSessionId OlddwSessionId;
- HANDLE hProcess = NULL;
+ HANDLE hProcess = nullptr;
//We use this event to notify the program that the session has changed
//The program need to end so the service can restart the program in the correct session
//wait_for_existing_process();
@@ -150,7 +150,7 @@ DWORD VNCServerService::serviceMain(int /*argc*/, char* /*argv*/ [])
//cad request
case WAIT_OBJECT_0 + 1:
- if (_SendSAS != NULL)
+ if (_SendSAS != nullptr)
_SendSAS(FALSE);
break;
@@ -163,7 +163,7 @@ DWORD VNCServerService::serviceMain(int /*argc*/, char* /*argv*/ [])
SetEvent(sessionEvent);
}
DWORD dwExitCode = 0;
- if (hProcess == NULL ||
+ if (hProcess == nullptr ||
(GetExitCodeProcess(hProcess, &dwExitCode) &&
dwExitCode != STILL_ACTIVE &&
CloseHandle(hProcess)))
diff --git a/win/winvnc/VNCServerService.h b/win/winvnc/VNCServerService.h
index cae44868..3992bc91 100644
--- a/win/winvnc/VNCServerService.h
+++ b/win/winvnc/VNCServerService.h
@@ -28,8 +28,8 @@ namespace winvnc {
public:
VNCServerService();
- DWORD serviceMain(int argc, char* argv[]);
- void stop();
+ DWORD serviceMain(int argc, char* argv[]) override;
+ void stop() override;
static const char* Name;
protected:
diff --git a/win/winvnc/VNCServerWin32.cxx b/win/winvnc/VNCServerWin32.cxx
index 38b2ef16..140d82ad 100644
--- a/win/winvnc/VNCServerWin32.cxx
+++ b/win/winvnc/VNCServerWin32.cxx
@@ -61,13 +61,13 @@ static BoolParameter showTrayIcon("ShowTrayIcon",
VNCServerWin32::VNCServerWin32()
: command(NoCommand),
- commandEvent(CreateEvent(0, TRUE, FALSE, 0)),
+ commandEvent(CreateEvent(nullptr, TRUE, FALSE, nullptr)),
sessionEvent(isServiceProcess() ?
- CreateEvent(0, FALSE, FALSE, "Global\\SessionEventTigerVNC") : 0),
+ CreateEvent(nullptr, FALSE, FALSE, "Global\\SessionEventTigerVNC") : nullptr),
vncServer(ComputerName().buf, &desktop),
thread_id(-1), runServer(false), isDesktopStarted(false),
- config(&sockMgr), rfbSock(&sockMgr), trayIcon(0),
- queryConnectDialog(0)
+ config(&sockMgr), rfbSock(&sockMgr), trayIcon(nullptr),
+ queryConnectDialog(nullptr)
{
commandLock = new os::Mutex;
commandSig = new os::Condition(commandLock);
@@ -92,7 +92,7 @@ VNCServerWin32::~VNCServerWin32() {
delete trayIcon;
// Stop the SDisplay from updating our state
- desktop.setStatusLocation(0);
+ desktop.setStatusLocation(nullptr);
// Join the Accept/Reject dialog thread
if (queryConnectDialog) {
@@ -179,15 +179,14 @@ int VNCServerWin32::run() {
// - Set the address-changed handler for the RFB socket
rfbSock.setAddressChangeNotifier(this);
- DWORD result = 0;
+ int result = 0;
try {
vlog.debug("Entering message loop");
// - Run the server until we're told to quit
MSG msg;
- int result = 0;
while (runServer) {
- result = sockMgr.getMessage(&msg, NULL, 0, 0);
+ result = sockMgr.getMessage(&msg, nullptr, 0, 0);
if (result < 0)
throw rdr::SystemException("getMessage", GetLastError());
if (!isServiceProcess() && (result == 0))
@@ -226,7 +225,7 @@ bool VNCServerWin32::disconnectClients(const char* reason) {
}
bool VNCServerWin32::addNewClient(const char* client) {
- TcpSocket* sock = 0;
+ TcpSocket* sock = nullptr;
try {
std::string hostname;
int port;
@@ -254,7 +253,7 @@ void VNCServerWin32::queryConnection(network::Socket* sock,
const char* userName)
{
if (queryOnlyIfLoggedOn && CurrentUserToken().noUserLoggedOn()) {
- vncServer.approveConnection(sock, true, NULL);
+ vncServer.approveConnection(sock, true, nullptr);
return;
}
if (queryConnectDialog) {
@@ -266,7 +265,7 @@ void VNCServerWin32::queryConnection(network::Socket* sock,
}
void VNCServerWin32::queryConnectionComplete() {
- queueCommand(QueryConnectionComplete, 0, 0, false);
+ queueCommand(QueryConnectionComplete, nullptr, 0, false);
}
@@ -324,7 +323,7 @@ void VNCServerWin32::processEvent(HANDLE event_) {
"Connection rejected by user");
queryConnectDialog->wait();
delete queryConnectDialog;
- queryConnectDialog = 0;
+ queryConnectDialog = nullptr;
break;
default:
@@ -396,7 +395,7 @@ void VNCServerWin32::setConnStatus(ListConnInfo* listConn)
status = listConn->iGetStatus();
if (status == 3) {
- conn->close(0);
+ conn->close(nullptr);
} else {
rfb::AccessRights ar;
diff --git a/win/winvnc/VNCServerWin32.h b/win/winvnc/VNCServerWin32.h
index 0a2c330c..493b3fa6 100644
--- a/win/winvnc/VNCServerWin32.h
+++ b/win/winvnc/VNCServerWin32.h
@@ -64,7 +64,7 @@ namespace winvnc {
// Disconnect all connected clients
// THREAD-SAFE
- bool disconnectClients(const char* reason=0);
+ bool disconnectClients(const char* reason=nullptr);
// Call used to notify VNCServerST of user accept/reject query completion
// CALLED FROM AcceptConnectDialog THREAD
@@ -81,20 +81,20 @@ namespace winvnc {
// QueryConnectionHandler interface
// Callback used to prompt user to accept or reject a connection.
// CALLBACK IN VNCServerST "HOST" THREAD
- virtual void queryConnection(network::Socket* sock,
- const char* userName);
+ void queryConnection(network::Socket* sock,
+ const char* userName) override;
// SocketManager::AddressChangeNotifier interface
// Used to keep tray icon up to date
- virtual void processAddressChange();
+ void processAddressChange() override;
// RegConfig::Callback interface
// Called via the EventManager whenever RegConfig sees the registry change
- virtual void regConfigChanged();
+ void regConfigChanged() override;
// EventHandler interface
// Used to perform queued commands
- virtual void processEvent(HANDLE event);
+ void processEvent(HANDLE event) override;
void getConnInfo(ListConnInfo * listConn);
void setConnStatus(ListConnInfo* listConn);
diff --git a/win/winvnc/winvnc.cxx b/win/winvnc/winvnc.cxx
index 51246407..d612a43e 100644
--- a/win/winvnc/winvnc.cxx
+++ b/win/winvnc/winvnc.cxx
@@ -88,7 +88,7 @@ static void programUsage() {
static void MsgBoxOrLog(const char* msg, bool isError=false) {
if (close_console) {
- MsgBox(0, msg, (isError ? MB_ICONERROR : MB_ICONINFORMATION) | MB_OK);
+ MsgBox(nullptr, msg, (isError ? MB_ICONERROR : MB_ICONINFORMATION) | MB_OK);
} else {
if (isError) {
try {
@@ -116,8 +116,8 @@ static void processParams(int argc, char** argv) {
if (ancd.showDialog())
host = ancd.getHostName();
}
- if (host != NULL) {
- HWND hwnd = FindWindow(0, "winvnc::IPC_Interface");
+ if (host != nullptr) {
+ HWND hwnd = FindWindow(nullptr, "winvnc::IPC_Interface");
if (!hwnd)
throw rdr::Exception("Unable to locate existing VNC Server.");
COPYDATASTRUCT copyData;
@@ -130,12 +130,12 @@ static void processParams(int argc, char** argv) {
}
} else if (strcasecmp(argv[i], "-disconnect") == 0) {
runServer = false;
- HWND hwnd = FindWindow(0, "winvnc::IPC_Interface");
+ HWND hwnd = FindWindow(nullptr, "winvnc::IPC_Interface");
if (!hwnd)
throw rdr::Exception("Unable to locate existing VNC Server.");
COPYDATASTRUCT copyData;
copyData.dwData = 2; // *** DisconnectClients
- copyData.lpData = 0;
+ copyData.lpData = nullptr;
copyData.cbData = 0;
printf("Sending disconnect request to VNC Server...\n");
if (!SendMessage(hwnd, WM_COPYDATA, 0, (LPARAM)&copyData))
@@ -250,7 +250,7 @@ int WINAPI WinMain(HINSTANCE /*inst*/, HINSTANCE /*prevInst*/, char* /*cmdLine*/
freopen("CONIN$", "rb", stdin);
freopen("CONOUT$", "wb", stdout);
freopen("CONOUT$", "wb", stderr);
- setbuf(stderr, 0);
+ setbuf(stderr, nullptr);
initStdIOLoggers();
initFileLogger("C:\\temp\\WinVNC4.log");
logParams.setParam("*:stderr:100");
diff --git a/win/wm_hooks/wm_hooks.cxx b/win/wm_hooks/wm_hooks.cxx
index c864171b..a48a1738 100644
--- a/win/wm_hooks/wm_hooks.cxx
+++ b/win/wm_hooks/wm_hooks.cxx
@@ -69,7 +69,7 @@ ATOM ATOM_Popup_Selection = GlobalAddAtom("RFB.WM_Hooks.PopupSelectionAtom");
// -=- DLL entry point
//
-HINSTANCE dll_instance = 0;
+HINSTANCE dll_instance = nullptr;
BOOL WINAPI DllMain(HANDLE instance, ULONG reason, LPVOID /*reserved*/) {
switch (reason) {
@@ -92,12 +92,12 @@ BOOL WINAPI DllMain(HANDLE instance, ULONG reason, LPVOID /*reserved*/) {
DWORD hook_owner SHARED = 0;
DWORD hook_target SHARED = 0;
-HHOOK hook_CallWndProc SHARED = 0;
-HHOOK hook_CallWndProcRet SHARED = 0;
-HHOOK hook_GetMessage SHARED = 0;
-HHOOK hook_DialogMessage SHARED = 0;
+HHOOK hook_CallWndProc SHARED = nullptr;
+HHOOK hook_CallWndProcRet SHARED = nullptr;
+HHOOK hook_GetMessage SHARED = nullptr;
+HHOOK hook_DialogMessage SHARED = nullptr;
BOOL enable_cursor_shape SHARED = FALSE;
-HCURSOR cursor SHARED = 0;
+HCURSOR cursor SHARED = nullptr;
#ifdef _DEBUG
UINT diagnostic_min SHARED =1;
UINT diagnostic_max SHARED =0;
@@ -138,8 +138,8 @@ bool NotifyRectangle(RECT* rect) {
LPARAM l = MAKELONG((SHORT)rect->right, (SHORT)rect->bottom);
return NotifyHookOwner(WM_HK_RectangleChanged, w, l);
}
-bool NotifyCursor(HCURSOR cursor) {
- return NotifyHookOwner(WM_HK_CursorChanged, 0, (LPARAM)cursor);
+bool NotifyCursor(HCURSOR cursor_) {
+ return NotifyHookOwner(WM_HK_CursorChanged, 0, (LPARAM)cursor_);
}
void ProcessWindowMessage(UINT msg, HWND wnd, WPARAM wParam, LPARAM /*lParam*/) {
@@ -252,7 +252,7 @@ void ProcessWindowMessage(UINT msg, HWND wnd, WPARAM wParam, LPARAM /*lParam*/)
if (buffsize != 0)
{
buff = (RGNDATA *) new BYTE [buffsize];
- if (buff == NULL)
+ if (buff == nullptr)
break;
// Now get the region data
@@ -277,7 +277,7 @@ void ProcessWindowMessage(UINT msg, HWND wnd, WPARAM wParam, LPARAM /*lParam*/)
}
// Now free the region
- if (region != NULL)
+ if (region != nullptr)
DeleteObject(region);
}
*/
@@ -353,19 +353,19 @@ BOOL WM_Hooks_Remove(DWORD owner) {
if (owner != hook_owner) return FALSE;
if (hook_CallWndProc) {
UnhookWindowsHookEx(hook_CallWndProc);
- hook_CallWndProc = 0;
+ hook_CallWndProc = nullptr;
}
if (hook_CallWndProcRet) {
UnhookWindowsHookEx(hook_CallWndProcRet);
- hook_CallWndProcRet = 0;
+ hook_CallWndProcRet = nullptr;
}
if (hook_GetMessage) {
UnhookWindowsHookEx(hook_GetMessage);
- hook_GetMessage = 0;
+ hook_GetMessage = nullptr;
}
if (hook_DialogMessage) {
UnhookWindowsHookEx(hook_DialogMessage);
- hook_DialogMessage = 0;
+ hook_DialogMessage = nullptr;
}
hook_owner = 0;
hook_target = 0;
@@ -376,8 +376,8 @@ BOOL WM_Hooks_Remove(DWORD owner) {
// -=- User input hooks
//
-HHOOK hook_keyboard SHARED = 0;
-HHOOK hook_pointer SHARED = 0;
+HHOOK hook_keyboard SHARED = nullptr;
+HHOOK hook_pointer SHARED = nullptr;
bool enable_real_ptr SHARED = true;
bool enable_synth_ptr SHARED = true;
bool enable_real_kbd SHARED = true;
@@ -414,11 +414,11 @@ bool RefreshInputHooks() {
bool set_kbd_hook = !enable_real_kbd || !enable_synth_kbd;
if (hook_keyboard && !set_kbd_hook) {
UnhookWindowsHookEx(hook_keyboard);
- hook_keyboard = 0;
+ hook_keyboard = nullptr;
}
if (hook_pointer && !set_ptr_hook) {
UnhookWindowsHookEx(hook_pointer);
- hook_pointer = 0;
+ hook_pointer = nullptr;
}
if (!hook_keyboard && set_kbd_hook) {
hook_keyboard = SetWindowsHookEx(WH_KEYBOARD_LL, HookKeyboardHook, dll_instance, 0);