Author: dchapyshev Date: Sat Jul 30 16:00:10 2016 New Revision: 72059
URL: http://svn.reactos.org/svn/reactos?rev=72059&view=rev Log: [WHOAMI] [ARP] [TRACERT] - Incorrect to compare the variable of BOOL type with TRUE. Any non-zero value is considered to be "true".
[FREELDR] - Variable is assigned values twice - The 'strlen' function was called multiple times inside the body of a loop - It is inefficient to identify an empty string by using 'strlen(str) > 0' construct. A more efficient way is to check: str[0] != 0
[NTOBJSHEX] [SLAYER] [CMICONTROL] - It is inefficient to identify an empty string by using 'strlen(str) > 0' construct. A more efficient way is to check: str[0] != 0
[SHELL32] - There is no sense in testing the pointer against null, as the memory was allocated using the 'new' operator. The exception will be generated in the case of memory allocation error - Verifying that a pointer value is not NULL is not required. The 'if (ptr != NULL)' check can be removed - Fix copy-paste error in CMenuFocusManager::PlaceHooks()
[SRCLIENT] - Remove unneeded check. A part of conditional expression is always false.
[DISK] [ATAPI] - Variable is assigned values twice
* All bugs found by PVS-Studio
Modified: trunk/reactos/base/applications/cmdutils/whoami/whoami.c trunk/reactos/base/applications/network/arp/arp.c trunk/reactos/base/applications/network/tracert/tracert.c trunk/reactos/boot/freeldr/freeldr/disk/scsiport.c trunk/reactos/boot/freeldr/freeldr/lib/fs/fs.c trunk/reactos/boot/freeldr/freeldr/ntldr/winldr.c trunk/reactos/boot/freeldr/freeldr/ntldr/wlregistry.c trunk/reactos/dll/shellext/ntobjshex/regfolder.cpp trunk/reactos/dll/shellext/slayer/slayer.c trunk/reactos/dll/win32/shell32/shelldesktop/CDesktopBrowser.cpp trunk/reactos/dll/win32/shell32/shellmenu/CMenuBand.cpp trunk/reactos/dll/win32/shell32/shellmenu/CMenuFocusManager.cpp trunk/reactos/dll/win32/srclient/srclient_main.c trunk/reactos/drivers/storage/class/disk/disk.c trunk/reactos/drivers/storage/ide/atapi/atapi.c trunk/reactos/drivers/wdm/audio/drivers/CMIDriver/cmicontrol/main.cpp
Modified: trunk/reactos/base/applications/cmdutils/whoami/whoami.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils/... ============================================================================== --- trunk/reactos/base/applications/cmdutils/whoami/whoami.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/cmdutils/whoami/whoami.c [iso-8859-1] Sat Jul 30 16:00:10 2016 @@ -753,7 +753,7 @@ { NoHeaderArgCount++;
- if (NoHeader != TRUE) + if (NoHeader == FALSE) { NoHeader = TRUE; // wprintf(L"Headers disabled!\n"); @@ -788,7 +788,7 @@
/* looks like you can't use the "/fo list /nh" options together for some stupid reason */ - if (PrintFormat == list && NoHeader == TRUE) + if (PrintFormat == list && NoHeader != FALSE) { wprintf(WhoamiLoadRcString(IDS_ERROR_NH_LIST)); return 1;
Modified: trunk/reactos/base/applications/network/arp/arp.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/network/a... ============================================================================== --- trunk/reactos/base/applications/network/arp/arp.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/network/arp/arp.c [iso-8859-1] Sat Jul 30 16:00:10 2016 @@ -464,7 +464,7 @@ pDelHost->dwIndex = pIpNetTable->table[0].dwIndex; }
- if (bFlushTable == TRUE) + if (bFlushTable != FALSE) { /* delete arp cache */ if (FlushIpNetTable(pDelHost->dwIndex) != NO_ERROR)
Modified: trunk/reactos/base/applications/network/tracert/tracert.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/network/t... ============================================================================== --- trunk/reactos/base/applications/network/tracert/tracert.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/network/tracert/tracert.c [iso-8859-1] Sat Jul 30 16:00:10 2016 @@ -450,7 +450,7 @@
/* run until we hit either max hops, or find the target */ while ((iHopCount <= pInfo->iMaxHops) && - (bFoundTarget != TRUE)) + (bFoundTarget == FALSE)) { USHORT iSeqNum = 0; INT i; @@ -460,7 +460,7 @@ /* run 3 pings for each hop */ for (i = 0; i < 3; i++) { - if (SetTTL(pInfo->icmpSock, iTTL) != TRUE) + if (SetTTL(pInfo->icmpSock, iTTL) == FALSE) { DebugPrint(_T("error in Setup()\n")); return ret;
Modified: trunk/reactos/boot/freeldr/freeldr/disk/scsiport.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/disk/s... ============================================================================== --- trunk/reactos/boot/freeldr/freeldr/disk/scsiport.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/disk/scsiport.c [iso-8859-1] Sat Jul 30 16:00:10 2016 @@ -607,7 +607,6 @@ else { /* Nothing */ - *Length = 0; PhysicalAddress.QuadPart = (LONGLONG)(SP_UNINITIALIZED_VALUE); }
Modified: trunk/reactos/boot/freeldr/freeldr/lib/fs/fs.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/lib/fs... ============================================================================== --- trunk/reactos/boot/freeldr/freeldr/lib/fs/fs.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/lib/fs/fs.c [iso-8859-1] Sat Jul 30 16:00:10 2016 @@ -385,9 +385,12 @@ ULONG FsGetNumPathParts(PCSTR Path) { size_t i; + size_t len; ULONG num; - - for (i = 0, num = 0; i < strlen(Path); i++) + + len = strlen(Path); + + for (i = 0, num = 0; i < len; i++) { if ((Path[i] == '\') || (Path[i] == '/')) { @@ -410,11 +413,14 @@ VOID FsGetFirstNameFromPath(PCHAR Buffer, PCSTR Path) { size_t i; + size_t len; + + len = strlen(Path);
// Copy all the characters up to the end of the // string or until we hit a '' character // and put them in Buffer - for (i = 0; i < strlen(Path); i++) + for (i = 0; i < len; i++) { if ((Path[i] == '\') || (Path[i] == '/')) {
Modified: trunk/reactos/boot/freeldr/freeldr/ntldr/winldr.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/ntldr/... ============================================================================== --- trunk/reactos/boot/freeldr/freeldr/ntldr/winldr.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/ntldr/winldr.c [iso-8859-1] Sat Jul 30 16:00:10 2016 @@ -650,7 +650,7 @@ }
/* Append a backslash if needed */ - if ((strlen(BootPath) == 0) || BootPath[strlen(BootPath) - 1] != '\') + if ((BootPath[0] == 0) || BootPath[strlen(BootPath) - 1] != '\') strcat(BootPath, "\");
/* Read booting options */
Modified: trunk/reactos/boot/freeldr/freeldr/ntldr/wlregistry.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/ntldr/... ============================================================================== --- trunk/reactos/boot/freeldr/freeldr/ntldr/wlregistry.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/ntldr/wlregistry.c [iso-8859-1] Sat Jul 30 16:00:10 2016 @@ -705,7 +705,7 @@
// Check - if we have a valid ImagePath, if not - we need to build it // like "System32\Drivers\blah.sys" - if (ImagePath && (wcslen(ImagePath) > 0)) + if (ImagePath && (ImagePath[0] != 0)) { // Just copy ImagePath to the corresponding field in the structure PathLength = (USHORT)wcslen(ImagePath) * sizeof(WCHAR) + sizeof(UNICODE_NULL);
Modified: trunk/reactos/dll/shellext/ntobjshex/regfolder.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/shellext/ntobjshex/regf... ============================================================================== --- trunk/reactos/dll/shellext/ntobjshex/regfolder.cpp [iso-8859-1] (original) +++ trunk/reactos/dll/shellext/ntobjshex/regfolder.cpp [iso-8859-1] Sat Jul 30 16:00:10 2016 @@ -471,7 +471,7 @@ SHCONTF grfFlags, IEnumIDList **ppenumIDList) { - if (wcslen(m_NtPath) == 0 && m_hRoot == NULL) + if (m_NtPath[0] == 0 && m_hRoot == NULL) { return GetEnumRegistryRoot(ppenumIDList); }
Modified: trunk/reactos/dll/shellext/slayer/slayer.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/shellext/slayer/slayer.... ============================================================================== --- trunk/reactos/dll/shellext/slayer/slayer.c [iso-8859-1] (original) +++ trunk/reactos/dll/shellext/slayer/slayer.c [iso-8859-1] Sat Jul 30 16:00:10 2016 @@ -161,7 +161,7 @@ }
info->CSelectedItem = NULL; - if (_tcslen(szStr) > 0) + if (szStr[0] != 0) { PCITEM item;
Modified: trunk/reactos/dll/win32/shell32/shelldesktop/CDesktopBrowser.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/shelldesk... ============================================================================== --- trunk/reactos/dll/win32/shell32/shelldesktop/CDesktopBrowser.cpp [iso-8859-1] (original) +++ trunk/reactos/dll/win32/shell32/shelldesktop/CDesktopBrowser.cpp [iso-8859-1] Sat Jul 30 16:00:10 2016 @@ -172,8 +172,7 @@ }
pThis = new CComObject<CDesktopBrowser>; - if (pThis == NULL) - return NULL; + pThis->AddRef();
hRet = pThis->Initialize(hWnd, ShellDesk);
Modified: trunk/reactos/dll/win32/shell32/shellmenu/CMenuBand.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/shellmenu... ============================================================================== --- trunk/reactos/dll/win32/shell32/shellmenu/CMenuBand.cpp [iso-8859-1] (original) +++ trunk/reactos/dll/win32/shell32/shellmenu/CMenuBand.cpp [iso-8859-1] Sat Jul 30 16:00:10 2016 @@ -67,11 +67,8 @@ { CMenuFocusManager::ReleaseManager(m_focusManager);
- if (m_staticToolbar) - delete m_staticToolbar; - - if (m_SFToolbar) - delete m_SFToolbar; + delete m_staticToolbar; + delete m_SFToolbar;
if (m_hmenu) DestroyMenu(m_hmenu);
Modified: trunk/reactos/dll/win32/shell32/shellmenu/CMenuFocusManager.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/shellmenu... ============================================================================== --- trunk/reactos/dll/win32/shell32/shellmenu/CMenuFocusManager.cpp [iso-8859-1] (original) +++ trunk/reactos/dll/win32/shell32/shellmenu/CMenuFocusManager.cpp [iso-8859-1] Sat Jul 30 16:00:10 2016 @@ -680,7 +680,7 @@
HRESULT CMenuFocusManager::PlaceHooks() { - if (m_hMsgFilterHook) + if (m_hGetMsgHook) { WARN("GETMESSAGE hook already placed!\n"); return S_OK;
Modified: trunk/reactos/dll/win32/srclient/srclient_main.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/srclient/srclient... ============================================================================== --- trunk/reactos/dll/win32/srclient/srclient_main.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/srclient/srclient_main.c [iso-8859-1] Sat Jul 30 16:00:10 2016 @@ -35,7 +35,7 @@
DPRINT1("SRSetRestorePointA is unimplemented\n");
- if (!pRestorePtSpec || !pRestorePtSpec->szDescription) + if (!pRestorePtSpec) return FALSE;
RPInfoW.dwEventType = pRestorePtSpec->dwEventType;
Modified: trunk/reactos/drivers/storage/class/disk/disk.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/storage/class/disk/... ============================================================================== --- trunk/reactos/drivers/storage/class/disk/disk.c [iso-8859-1] (original) +++ trunk/reactos/drivers/storage/class/disk/disk.c [iso-8859-1] Sat Jul 30 16:00:10 2016 @@ -505,7 +505,6 @@ // SRB zone elements to allocate. //
- adapterDisk = 0; adapterInfo = (PVOID) buffer;
adapterDisk = ScsiClassFindUnclaimedDevices(InitializationData, adapterInfo);
Modified: trunk/reactos/drivers/storage/ide/atapi/atapi.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/storage/ide/atapi/a... ============================================================================== --- trunk/reactos/drivers/storage/ide/atapi/atapi.c [iso-8859-1] (original) +++ trunk/reactos/drivers/storage/ide/atapi/atapi.c [iso-8859-1] Sat Jul 30 16:00:10 2016 @@ -5483,7 +5483,6 @@ //
deviceExtension->ExpectingInterrupt = FALSE; - status = SRB_STATUS_SUCCESS;
} else {
@@ -5495,7 +5494,6 @@
GetBaseStatus(baseIoAddress1, statusByte); deviceExtension->ExpectingInterrupt = FALSE; - status = SRB_STATUS_SUCCESS;
if (errorByte & IDE_ERROR_DATA_ERROR) {
Modified: trunk/reactos/drivers/wdm/audio/drivers/CMIDriver/cmicontrol/main.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/drivers/C... ============================================================================== --- trunk/reactos/drivers/wdm/audio/drivers/CMIDriver/cmicontrol/main.cpp [iso-8859-1] (original) +++ trunk/reactos/drivers/wdm/audio/drivers/CMIDriver/cmicontrol/main.cpp [iso-8859-1] Sat Jul 30 16:00:10 2016 @@ -943,12 +943,10 @@ ZeroMemory(&cmiTopologyDev, sizeof(CMIDEV)); hWave = NULL;
- if (szCmdLine) { - if (strlen(szCmdLine) > 0) { - int result = parseArguments(szCmdLine); - cleanUp(); - return result; - } + if (szCmdLine && szCmdLine[0] != 0) { + int result = parseArguments(szCmdLine); + cleanUp(); + return result; }
if ((hWndMain = FindWindow("cmiControlPanel", NULL))) {