diff options
author | Pierre Ossman <ossman@cendio.se> | 2024-04-21 02:18:22 +0200 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2024-06-24 14:22:35 +0200 |
commit | 12b3f4021641537b90727b23d42de5dff59006cd (patch) | |
tree | d494cda8c019a53989099a44b05aca2e0a4fff8a /win | |
parent | 4a71ac5bb79e3cd53499255f231c490fc9a5627b (diff) | |
download | tigervnc-12b3f4021641537b90727b23d42de5dff59006cd.tar.gz tigervnc-12b3f4021641537b90727b23d42de5dff59006cd.zip |
Avoid shadowing variables
It's a source of confusion and possibly bugs to reuse the same variable
name for multiple things.
Diffstat (limited to 'win')
-rw-r--r-- | win/rfb_win32/DeviceFrameBuffer.cxx | 8 | ||||
-rw-r--r-- | win/rfb_win32/Dialog.cxx | 20 | ||||
-rw-r--r-- | win/rfb_win32/Registry.cxx | 6 | ||||
-rw-r--r-- | win/rfb_win32/Service.cxx | 30 | ||||
-rw-r--r-- | win/rfb_win32/SocketManager.cxx | 8 | ||||
-rw-r--r-- | win/vncconfig/vncconfig.cxx | 1 | ||||
-rw-r--r-- | win/winvnc/VNCServerWin32.cxx | 3 | ||||
-rw-r--r-- | win/wm_hooks/wm_hooks.cxx | 4 |
8 files changed, 39 insertions, 41 deletions
diff --git a/win/rfb_win32/DeviceFrameBuffer.cxx b/win/rfb_win32/DeviceFrameBuffer.cxx index 090846f2..bba1dbdb 100644 --- a/win/rfb_win32/DeviceFrameBuffer.cxx +++ b/win/rfb_win32/DeviceFrameBuffer.cxx @@ -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/Dialog.cxx b/win/rfb_win32/Dialog.cxx index 7c1574e9..432439ce 100644 --- a/win/rfb_win32/Dialog.cxx +++ b/win/rfb_win32/Dialog.cxx @@ -151,7 +151,7 @@ BOOL Dialog::dialogProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) } -PropSheetPage::PropSheetPage(HINSTANCE inst, const char* id) : Dialog(inst), propSheet(nullptr) { +PropSheetPage::PropSheetPage(HINSTANCE inst_, const char* id) : Dialog(inst_), propSheet(nullptr) { page.dwSize = sizeof(page); page.dwFlags = 0; // PSP_USECALLBACK; page.hInstance = inst; @@ -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; @@ -276,7 +276,7 @@ bool PropSheet::showPropSheet(HWND owner, bool showApply, bool showCtxtHelp, boo handle = (HWND)PropertySheet(&header); 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,8 +314,8 @@ 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, nullptr, 0, 0)) { @@ -324,11 +324,11 @@ bool PropSheet::showPropSheet(HWND owner, bool showApply, bool showCtxtHelp, boo 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 diff --git a/win/rfb_win32/Registry.cxx b/win/rfb_win32/Registry.cxx index 3b12dab9..bcb98704 100644 --- a/win/rfb_win32/Registry.cxx +++ b/win/rfb_win32/Registry.cxx @@ -244,11 +244,11 @@ std::string RegKey::getRepresentation(const char* valname) const { 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 ""; } diff --git a/win/rfb_win32/Service.cxx b/win/rfb_win32/Service.cxx index 0d6cd578..dafa38b5 100644 --- a/win/rfb_win32/Service.cxx +++ b/win/rfb_win32/Service.cxx @@ -338,17 +338,17 @@ bool rfb::win32::registerService(const char* name, 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(), nullptr, nullptr, nullptr, nullptr, nullptr); - if (!service) + 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; @@ -383,10 +383,10 @@ bool rfb::win32::unregisterService(const char* name) { 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 @@ -410,12 +410,12 @@ bool rfb::win32::startService(const char* name) { 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, nullptr)) + if (!StartService(handle, 0, nullptr)) throw rdr::SystemException("unable to start the service", GetLastError()); Sleep(500); @@ -430,13 +430,13 @@ bool rfb::win32::stopService(const char* name) { 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); @@ -451,13 +451,13 @@ DWORD rfb::win32::getServiceState(const char* name) { 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 7d6038cb..57b65aef 100644 --- a/win/rfb_win32/SocketManager.cxx +++ b/win/rfb_win32/SocketManager.cxx @@ -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/vncconfig/vncconfig.cxx b/win/vncconfig/vncconfig.cxx index b32f7607..b8cb5dc8 100644 --- a/win/vncconfig/vncconfig.cxx +++ b/win/vncconfig/vncconfig.cxx @@ -86,7 +86,6 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE /*prev*/, char* /*cmdLine*/, int /* freopen("CONOUT$","wb",stderr); setbuf(stderr, nullptr); initStdIOLoggers(); - LogWriter vlog("main"); logParams.setParam("*:stderr:100"); vlog.info("Starting vncconfig applet"); #endif diff --git a/win/winvnc/VNCServerWin32.cxx b/win/winvnc/VNCServerWin32.cxx index 0a7128f1..140d82ad 100644 --- a/win/winvnc/VNCServerWin32.cxx +++ b/win/winvnc/VNCServerWin32.cxx @@ -179,13 +179,12 @@ 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, nullptr, 0, 0); if (result < 0) diff --git a/win/wm_hooks/wm_hooks.cxx b/win/wm_hooks/wm_hooks.cxx index ecff85cb..a48a1738 100644 --- a/win/wm_hooks/wm_hooks.cxx +++ b/win/wm_hooks/wm_hooks.cxx @@ -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*/) { |