shell32: Simplify check for empty string (PVS-Studio)

Michael Stefaniuc mstefani at redhat.de
Fri Nov 7 03:22:01 CST 2014


---
 dlls/shell32/shellord.c        |  2 +-
 dlls/shell32/tests/ebrowser.c  |  2 +-
 dlls/shell32/tests/shlfolder.c | 14 +++++++-------
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/dlls/shell32/shellord.c b/dlls/shell32/shellord.c
index 56c9fe9..914dc5a 100644
--- a/dlls/shell32/shellord.c
+++ b/dlls/shell32/shellord.c
@@ -947,7 +947,7 @@ void WINAPI SHAddToRecentDocs (UINT uFlags,LPCVOID pv)
 		/* buffer size looks good */
 		ptr += 12; /* get to string */
 		len = bufused - (ptr-buffer);  /* get length of buf remaining */
-		if ((lstrlenA(ptr) > 0) && (lstrlenA(ptr) <= len-1)) {
+                if (ptr[0] && (lstrlenA(ptr) <= len-1)) {
 		    /* appears to be good string */
 		    lstrcpyA(old_lnk_name, link_dir);
 		    PathAppendA(old_lnk_name, ptr);
diff --git a/dlls/shell32/tests/ebrowser.c b/dlls/shell32/tests/ebrowser.c
index 1936cf9..4c255a1 100644
--- a/dlls/shell32/tests/ebrowser.c
+++ b/dlls/shell32/tests/ebrowser.c
@@ -1381,7 +1381,7 @@ static void test_navigation(void)
     ok(pSHCreateShellItem != NULL, "pSHCreateShellItem unexpectedly missing.\n");
 
     GetCurrentDirectoryW(MAX_PATH, current_path);
-    if(!lstrlenW(current_path))
+    if(!current_path[0])
     {
         skip("Failed to create test-directory.\n");
         return;
diff --git a/dlls/shell32/tests/shlfolder.c b/dlls/shell32/tests/shlfolder.c
index fc37443..1b457bb 100644
--- a/dlls/shell32/tests/shlfolder.c
+++ b/dlls/shell32/tests/shlfolder.c
@@ -81,7 +81,7 @@ static WCHAR *make_wstr(const char *str)
     WCHAR *ret;
     int len;
 
-    if(!str || strlen(str) == 0)
+    if (!str || !str[0])
         return NULL;
 
     len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
@@ -2203,7 +2203,7 @@ static void test_SHCreateShellItem(void)
         return;
     }
 
-    if (!lstrlenA(curdirA))
+    if (!curdirA[0])
     {
         win_skip("GetCurrentDirectoryA returned empty string, skipping test_SHCreateShellItem\n");
         return;
@@ -2780,7 +2780,7 @@ static void test_ShellItemCompare(void)
     }
 
     GetCurrentDirectoryW(MAX_PATH, curdirW);
-    if(!lstrlenW(curdirW))
+    if (!curdirW[0])
     {
         skip("Failed to get current directory, skipping.\n");
         return;
@@ -4387,7 +4387,7 @@ static void test_GetUIObject(void)
     }
 
     GetCurrentDirectoryW(MAX_PATH, path);
-    if(!lstrlenW(path))
+    if (!path[0])
     {
         skip("GetCurrentDirectoryW returned an empty string.\n");
         return;
@@ -4989,8 +4989,8 @@ static void test_SHChangeNotify(BOOL test_new_delivery)
 
         exp_data->missing_events = exp_data->notify_count;
         SHChangeNotify(exp_data->signal, SHCNF_PATHA | SHCNF_FLUSH,
-                strlen(exp_data->path_1) > 0 ? exp_data->path_1 : NULL,
-                strlen(exp_data->path_2) > 0 ? exp_data->path_2 : NULL);
+                exp_data->path_1[0] ? exp_data->path_1 : NULL,
+                exp_data->path_2[0] ? exp_data->path_2 : NULL);
         do_events();
         ok(exp_data->missing_events == 0, "%s: Expected wndproc to be called\n", exp_data->id);
 
@@ -5045,7 +5045,7 @@ static void test_SHCreateDefaultContextMenu(void)
     }
 
     GetCurrentDirectoryW(MAX_PATH, path);
-    if(!lstrlenW(path))
+    if (!path[0])
     {
         skip("GetCurrentDirectoryW returned an empty string.\n");
         return;
-- 
1.9.3



More information about the wine-patches mailing list