Don't TRACE NULL strings

François Gouget fgouget at codeweavers.com
Sat Oct 13 03:15:41 CDT 2001


   On Solaris printf("%s\n",NULL) crashes. This causes new crashes when
TRACEs are turned on :-(

Changelog:

   François Gouget <fgouget at codeweavers.com>

 * dlls/shell32/pidl.c,
   dlls/shell32/shellord.c,
   dlls/winmm/driver.c,
   dlls/winspool/info.c,
   loader/module.c,
   objects/font.c,
   windows/driver.c,
   dlls/user/comm16.c

   Don't print NULL strings (crashes on Solaris)
   Small code maintainability tweak in ShellExecuteExA
   Two typo fixes in winmm

-- 
François Gouget
fgouget at codeweavers.com
-------------- next part --------------
Index: dlls/shell32/pidl.c
===================================================================
RCS file: /home/wine/wine/dlls/shell32/pidl.c,v
retrieving revision 1.60
diff -u -r1.60 pidl.c
--- dlls/shell32/pidl.c	2001/08/16 18:49:57	1.60
+++ dlls/shell32/pidl.c	2001/10/13 06:35:51
@@ -1461,7 +1461,7 @@
 	GUID const * 	riid;
 	char szTemp[MAX_PATH];
 	
-	TRACE("(%p %p %x)\n",pidl,szOut,uOutSize);
+	TRACE("(%p %p %x)\n",pidl,debugstr_a(szOut),uOutSize);
 	
 	if (!pidl) return 0;
 
@@ -1503,7 +1503,7 @@
 	  ERR("-- no text\n");
 	}
 
-	TRACE("-- (%p=%s 0x%08lx)\n",szOut,(char*)szOut,dwReturn);
+	TRACE("-- (%p=%s 0x%08lx)\n",szOut,debugstr_a((char*)szOut),dwReturn);
 	return dwReturn;
 }
 
Index: dlls/shell32/shellord.c
===================================================================
RCS file: /home/wine/wine/dlls/shell32/shellord.c,v
retrieving revision 1.86
diff -u -r1.86 shellord.c
--- dlls/shell32/shellord.c	2001/10/03 18:42:16	1.86
+++ dlls/shell32/shellord.c	2001/10/13 06:35:52
@@ -37,7 +37,7 @@
 	LPSTR dst,
 	DWORD len) 
 {
-	WARN("('%s',0x%08lx,%p,%ld) semi-stub.\n",src,nField,dst,len);
+	WARN("(%s,0x%08lx,%p,%ld) semi-stub.\n",debugstr_a(src),nField,dst,len);
 
 	if (!src || !src[0] || !dst || !len)
 	  return 0;
@@ -973,9 +973,10 @@
 	PROCESS_INFORMATION info;
 			
 	WARN("mask=0x%08lx hwnd=0x%04x verb=%s file=%s parm=%s dir=%s show=0x%08x class=%s incomplete\n",
-		sei->fMask, sei->hwnd, sei->lpVerb, sei->lpFile,
-		sei->lpParameters, sei->lpDirectory, sei->nShow, 
-		(sei->fMask & SEE_MASK_CLASSNAME) ? sei->lpClass : "not used");
+	     sei->fMask, sei->hwnd, debugstr_a(sei->lpVerb),
+	     debugstr_a(sei->lpFile), debugstr_a(sei->lpParameters),
+	     debugstr_a(sei->lpDirectory), sei->nShow, 
+	     (sei->fMask & SEE_MASK_CLASSNAME) ? debugstr_a(sei->lpClass) : "not used");
 
 	ZeroMemory(szApplicationName,MAX_PATH);
 	if (sei->lpFile)
@@ -996,8 +997,9 @@
 	/* launch a document by fileclass like 'Wordpad.Document.1' */
 	if (sei->fMask & SEE_MASK_CLASSNAME)
 	{
+	  /* FIXME: szCommandline should not be of a fixed size. Plus MAX_PATH is way too short! */
 	  /* the commandline contains 'c:\Path\wordpad.exe "%1"' */
-	  HCR_GetExecuteCommand(sei->lpClass, (sei->lpVerb) ? sei->lpVerb : "open", szCommandline, 256);
+	  HCR_GetExecuteCommand(sei->lpClass, (sei->lpVerb) ? sei->lpVerb : "open", szCommandline, sizeof(szCommandline));
 	  /* fixme: get the extension of lpFile, check if it fits to the lpClass */
 	  TRACE("SEE_MASK_CLASSNAME->'%s'\n", szCommandline);
 	}
Index: dlls/winmm/driver.c
===================================================================
RCS file: /home/wine/wine/dlls/winmm/driver.c,v
retrieving revision 1.10
diff -u -r1.10 driver.c
--- dlls/winmm/driver.c	2001/08/21 17:07:17	1.10
+++ dlls/winmm/driver.c	2001/10/13 06:35:53
@@ -329,7 +329,7 @@
     LPSTR		ptr;
     LPCSTR		cause = 0;
 
-    TRACE("('%s', %08lX);\n", fn, lParam2);
+    TRACE("(%s, %08lX);\n", debugstr_a(fn), lParam2);
     
     if ((ptr = strchr(fn, ' ')) != NULL) {
 	*ptr++ = '\0';
@@ -349,14 +349,14 @@
     lpDrv->d.d32.hModule    = hModule;
     lpDrv->d.d32.dwDriverID = 0;
 
-    if (!DRIVER_AddToList(lpDrv, (LPARAM)ptr, lParam2)) {cause = "load faile"; goto exit;}
+    if (!DRIVER_AddToList(lpDrv, (LPARAM)ptr, lParam2)) {cause = "load failed"; goto exit;}
 
     TRACE("=> %p\n", lpDrv);
     return lpDrv;
  exit:
     FreeLibrary(hModule);
     HeapFree(GetProcessHeap(), 0, lpDrv);
-    TRACE("Unable to load 32 bit module \"%s\": %s\n", fn, cause);
+    TRACE("Unable to load 32 bit module %s: %s\n", debugstr_a(fn), cause);
     return NULL;
 }
 
@@ -370,7 +370,7 @@
     LPWINE_DRIVER 	lpDrv = NULL;
     LPCSTR		cause = 0;
 
-    TRACE("('%s', %08lX);\n", sn, lParam2);
+    TRACE("(%s, %08lX);\n", debugstr_a(sn), lParam2);
     
     lpDrv = HeapAlloc(GetProcessHeap(), 0, sizeof(WINE_DRIVER));
     if (lpDrv == NULL) {cause = "OOM"; goto exit;}
@@ -384,13 +384,13 @@
     if (lpDrv->d.d16.hDriver16 == 0) {cause = "Not a 16 bit driver"; goto exit;}
     lpDrv->dwFlags = WINE_GDF_16BIT;
 
-    if (!DRIVER_AddToList(lpDrv, 0, lParam2)) {cause = "load faile"; goto exit;}
+    if (!DRIVER_AddToList(lpDrv, 0, lParam2)) {cause = "load failed"; goto exit;}
 
     TRACE("=> %p\n", lpDrv);
     return lpDrv;
  exit:
     HeapFree(GetProcessHeap(), 0, lpDrv);
-    TRACE("Unable to load 32 bit module \"%s\": %s\n", fn, cause);
+    TRACE("Unable to load 32 bit module %s: %s\n", debugstr_a(fn), cause);
     return NULL;
 }
 
@@ -421,7 +421,7 @@
 	goto the_end;
 
     if (!(lpDrv = DRIVER_TryOpenDriver16(lpDriverName, lpSectionName, lParam2)))
-	TRACE("Failed to open driver %s from system.ini file, section %s\n", lpDriverName, lpSectionName);
+	TRACE("Failed to open driver %s from system.ini file, section %s\n", debugstr_a(lpDriverName), debugstr_a(lpSectionName));
  the_end:
     if (lpDrv)	TRACE("=> %08lx\n", (DWORD)lpDrv);
     return (DWORD)lpDrv;
Index: dlls/winspool/info.c
===================================================================
RCS file: /home/wine/wine/dlls/winspool/info.c,v
retrieving revision 1.44
diff -u -r1.44 info.c
--- dlls/winspool/info.c	2001/09/07 18:35:58	1.44
+++ dlls/winspool/info.c	2001/10/13 06:35:55
@@ -2395,14 +2395,14 @@
     DRIVER_INFO_3A di3;
     HKEY hkeyDrivers, hkeyName;
 
-    TRACE("(%s,%ld,%p)\n",pName,level,pDriverInfo);
+    TRACE("(%s,%ld,%p)\n",debugstr_a(pName),level,pDriverInfo);
 
     if(level != 2 && level != 3) {
         SetLastError(ERROR_INVALID_LEVEL);
 	return FALSE;
     }
     if(pName != NULL) {
-        FIXME("pName= `%s' - unsupported\n", pName);
+        FIXME("pName= %s - unsupported\n", debugstr_a(pName));
 	SetLastError(ERROR_INVALID_PARAMETER);
 	return FALSE;
     }
@@ -2440,7 +2440,7 @@
         if(RegOpenKeyA(hkeyDrivers, di3.pName, &hkeyName) == ERROR_SUCCESS) {
 	    RegCloseKey(hkeyName);
 	    RegCloseKey(hkeyDrivers);
-	    WARN("Trying to create existing printer driver `%s'\n", di3.pName);
+	    WARN("Trying to create existing printer driver %s\n", debugstr_a(di3.pName));
 	    SetLastError(ERROR_PRINTER_DRIVER_ALREADY_INSTALLED);
 	    return FALSE;
 	}
Index: loader/module.c
===================================================================
RCS file: /home/wine/wine/loader/module.c,v
retrieving revision 1.139
diff -u -r1.139 module.c
--- loader/module.c	2001/10/02 17:49:20	1.139
+++ loader/module.c	2001/10/13 06:35:59
@@ -1045,7 +1045,7 @@
 
     /* Process the AppName and/or CmdLine to get module name and path */
 
-    TRACE("app '%s' cmdline '%s'\n", lpApplicationName, lpCommandLine );
+    TRACE("app %s cmdline %s\n", debugstr_a(lpApplicationName), debugstr_a(lpCommandLine) );
 
     if (!(tidy_cmdline = get_file_name( lpApplicationName, lpCommandLine, name, sizeof(name) )))
         return FALSE;
Index: objects/font.c
===================================================================
RCS file: /home/wine/wine/objects/font.c,v
retrieving revision 1.53
diff -u -r1.53 font.c
--- objects/font.c	2001/09/24 01:12:08	1.53
+++ objects/font.c	2001/10/13 06:36:01
@@ -1737,7 +1737,8 @@
      * lpszCurrentPath can be NULL
      */
     FIXME("(%ld,%s,%s,%s): stub\n",
-	  fHidden, lpszResourceFile, lpszFontFile, lpszCurrentPath );
+          fHidden, debugstr_a(lpszResourceFile), debugstr_a(lpszFontFile),
+          debugstr_a(lpszCurrentPath) );
     return FALSE; /* create failed */
 }
 
Index: windows/driver.c
===================================================================
RCS file: /home/wine/wine/windows/driver.c,v
retrieving revision 1.38
diff -u -r1.38 driver.c
--- windows/driver.c	2001/07/25 00:43:36	1.38
+++ windows/driver.c	2001/10/13 06:36:02
@@ -260,7 +260,7 @@
     LPWINE_DRIVER	lpDrv = NULL;
     char		drvName[128];
 
-    TRACE("('%s', '%s', %08lX);\n", lpDriverName, lpSectionName, lParam2);
+    TRACE("(%s, %s, %08lX);\n", debugstr_a(lpDriverName), debugstr_a(lpSectionName), lParam2);
 
     if (!lpDriverName || !*lpDriverName) return 0;
 
@@ -277,7 +277,7 @@
 	lpDrv = DRIVER_TryOpenDriver16(drvName, lParam2);
     }
     if (!lpDrv) {
-	TRACE("Failed to open driver %s from system.ini file, section %s\n", lpDriverName, lpSectionName);
+	TRACE("Failed to open driver %s from system.ini file, section %s\n", debugstr_a(lpDriverName), debugstr_a(lpSectionName));
 	return 0;
     }
  the_end:
Index: dlls/user/comm16.c
===================================================================
RCS file: /home/wine/wine/dlls/user/comm16.c,v
retrieving revision 1.3
diff -u -r1.3 comm16.c
--- dlls/user/comm16.c	2001/09/14 00:24:40	1.3
+++ dlls/user/comm16.c	2001/10/13 06:42:17
@@ -149,8 +149,8 @@
 			else {
 				COM[x].handle = 0;
 				strcpy(COM[x].devicename, temp);
+				TRACE("%s = %s\n", option, COM[x].devicename);
 			}
-			TRACE("%s = %s\n", option, COM[x].devicename);
  		}
 
 		strcpy(option, "LPTx");
@@ -176,8 +176,8 @@
 			else {
 				LPT[x].handle = 0;
 				strcpy(LPT[x].devicename, temp);
+				TRACE("%s = %s\n", option, LPT[x].devicename);
 			}
-			TRACE("%s = %s\n", option, LPT[x].devicename);
 		}
 
 	}


More information about the wine-patches mailing list