From 349655636baae7c92683505396a45a060c364717 Mon Sep 17 00:00:00 2001
From: Andreas Mohr <a.mohr@mailto.de>
Date: Sat, 26 Aug 2000 20:31:48 +0000
Subject: [PATCH] - made the MIDI sequencer error message much better for
 confused users   to be found on #WineHQ - use strerror instead of errno at
 important places - got rid of HAVE_STRERROR macro - removed some #include:s
 (hopefully I didn't break anything)

---
 console/xterm.c                |  1 -
 dlls/commdlg/colordlg.c        |  2 +-
 dlls/dsound/dsound_main.c      |  3 ---
 dlls/gdi/printdrv.c            |  6 +++---
 dlls/ntdll/signal_sparc.c      |  1 -
 dlls/oleaut32/parsedt.c        |  1 -
 dlls/wininet/ftp.c             |  2 +-
 dlls/wininet/http.c            |  5 ++++-
 dlls/winmm/joystick/joystick.c |  2 +-
 dlls/winmm/wineoss/midi.c      | 13 +++++++++++--
 loader/main.c                  |  3 ---
 loader/module.c                |  9 ---------
 loader/ne/segment.c            |  3 ---
 loader/pe_image.c              | 18 ------------------
 misc/comm.c                    | 14 +-------------
 misc/ext_debugger.c            |  8 ++++----
 windows/x11drv/clipboard.c     | 14 --------------
 17 files changed, 26 insertions(+), 79 deletions(-)

diff --git a/console/xterm.c b/console/xterm.c
index ac1e3a971df..1ac37a64a5b 100644
--- a/console/xterm.c
+++ b/console/xterm.c
@@ -15,7 +15,6 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <termios.h>
-#include <errno.h>
 
 #include "console.h"
 #include "options.h"
diff --git a/dlls/commdlg/colordlg.c b/dlls/commdlg/colordlg.c
index a49e27c8d04..aab4d4d61c4 100644
--- a/dlls/commdlg/colordlg.c
+++ b/dlls/commdlg/colordlg.c
@@ -66,7 +66,7 @@ struct CCPRIVATE
  UINT msetrgb;        /* # of SETRGBSTRING message (today not used)  */
  RECT old3angle;    /* last position of l-marker */
  RECT oldcross;     /* last position of color/satuation marker */
- BOOL updating;     /* to prevent recursive WM_COMMAND/EN_UPDATE procesing */
+ BOOL updating;     /* to prevent recursive WM_COMMAND/EN_UPDATE processing */
  int h;
  int s;
  int l;               /* for temporary storing of hue,sat,lum */
diff --git a/dlls/dsound/dsound_main.c b/dlls/dsound/dsound_main.c
index 6988c03f94a..2e200f2a824 100644
--- a/dlls/dsound/dsound_main.c
+++ b/dlls/dsound/dsound_main.c
@@ -25,10 +25,8 @@
 
 #include "config.h"
 #include <assert.h>
-#include <errno.h>
 #include <stdio.h>
 #include <sys/types.h>
-#include <sys/time.h>
 #include <sys/fcntl.h>
 #include <unistd.h>
 #include <stdlib.h>
@@ -40,7 +38,6 @@
 #include "winuser.h"
 #include "winerror.h"
 #include "mmsystem.h"
-#include "thread.h"
 #include "debugtools.h"
 
 #include "initguid.h"
diff --git a/dlls/gdi/printdrv.c b/dlls/gdi/printdrv.c
index 8d0e331a16c..ade53907faf 100644
--- a/dlls/gdi/printdrv.c
+++ b/dlls/gdi/printdrv.c
@@ -488,7 +488,7 @@ static int CreateSpoolFile(LPCSTR pszOutput)
     {
         DOS_FULL_NAME fullName;
 
-        TRACE("Just assume its a file\n");
+        TRACE("Just assume it's a file\n");
 
         /**
          * The file name can be dos based, we have to find its
@@ -498,8 +498,8 @@ static int CreateSpoolFile(LPCSTR pszOutput)
 
         if ((fd = open(fullName.long_name, O_CREAT | O_TRUNC | O_WRONLY , 0600)) < 0)
         {
-            ERR("Failed to create spool file %s, errno = %d\n", 
-                fullName.long_name, errno);
+            ERR("Failed to create spool file %s (%s)\n", 
+                fullName.long_name, strerror(errno));
         }
     }
     return fd;
diff --git a/dlls/ntdll/signal_sparc.c b/dlls/ntdll/signal_sparc.c
index d64b5c06bc7..b2ebff91189 100644
--- a/dlls/ntdll/signal_sparc.c
+++ b/dlls/ntdll/signal_sparc.c
@@ -8,7 +8,6 @@
 
 #include "config.h"
 
-#include <errno.h>
 #include <signal.h>
 #include <stdlib.h>
 #include <unistd.h>
diff --git a/dlls/oleaut32/parsedt.c b/dlls/oleaut32/parsedt.c
index 8b9697a8711..96913f2ba46 100644
--- a/dlls/oleaut32/parsedt.c
+++ b/dlls/oleaut32/parsedt.c
@@ -38,7 +38,6 @@ PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 #include <math.h>
 #include <string.h>
 #include <sys/types.h>
-#include <errno.h>
 #include <limits.h>
 #include <sys/timeb.h>
 
diff --git a/dlls/wininet/ftp.c b/dlls/wininet/ftp.c
index b6f1ca984c6..5631963d917 100644
--- a/dlls/wininet/ftp.c
+++ b/dlls/wininet/ftp.c
@@ -1283,7 +1283,7 @@ HINTERNET FTP_Connect(HINTERNET hInternet, LPCSTR lpszServerName,
 
     if (connect(nsocket, (struct sockaddr *)&socketAddr, sizeof(socketAddr)) < 0)
     {
-	ERR("Unable to connect: errno(%d)\n", errno);
+	ERR("Unable to connect (%s)\n", strerror(errno));
 	INTERNET_SetLastError(ERROR_INTERNET_CANNOT_CONNECT);
     }
     else
diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c
index 3f9496c9bb5..e2c2e593d0e 100644
--- a/dlls/wininet/http.c
+++ b/dlls/wininet/http.c
@@ -243,6 +243,9 @@ INTERNETAPI HINTERNET WINAPI HTTP_HttpOpenRequestA(HINTERNET hHttpSession,
         InternetCrackUrlA(lpszReferrer, 0, 0, &UrlComponents);
         if (strlen(UrlComponents.lpszHostName))
             lpwhr->lpszHostName = HEAP_strdupA(GetProcessHeap(), 0, UrlComponents.lpszHostName);
+    } else {
+        lpwhr->lpszHostName = HEAP_strdupA(GetProcessHeap(), 0,
+					   lpwhs->lpszServerName);
     }
 
     if (hIC->lpfnStatusCB)
@@ -821,7 +824,7 @@ BOOL HTTP_OpenConnection(LPWININETHTTPREQA lpwhr)
 
     if (SOCKET_ERROR == result)
     {
-       WARN("Unable to connect to host: %d\n", errno);
+       WARN("Unable to connect to host (%s)\n", strerror(errno));
        goto lend;
     }
 
diff --git a/dlls/winmm/joystick/joystick.c b/dlls/winmm/joystick/joystick.c
index 9ef0abb869d..2eebf4432d6 100644
--- a/dlls/winmm/joystick/joystick.c
+++ b/dlls/winmm/joystick/joystick.c
@@ -281,7 +281,7 @@ static LONG	JSTCK_GetPosEx(DWORD dwDevID, LPJOYINFOEX lpInfo)
     /* EAGAIN is returned when the queue is empty */
     if (errno != EAGAIN) {
 	/* FIXME: error should not be ignored */
-	ERR("Error while reading joystick state (%d)\n", errno);
+	ERR("Error while reading joystick state (%s)\n", strerror(errno));
     }
 #else
     dev_stat = read(dev, &js, sizeof(js));
diff --git a/dlls/winmm/wineoss/midi.c b/dlls/winmm/wineoss/midi.c
index 9fdbeebe758..5363c760691 100644
--- a/dlls/winmm/wineoss/midi.c
+++ b/dlls/winmm/wineoss/midi.c
@@ -382,8 +382,17 @@ static int midiOpenSeq(void)
 	midiSeqFD = open(MIDI_SEQ, O_RDWR, 0);
 	if (midiSeqFD == -1) {
 	    if (midi_warn)
-		MESSAGE("Can't open MIDI device '%s', errno %d (%s) !\n",
-					MIDI_SEQ, errno, strerror(errno));
+	    {
+		MESSAGE("Can't open MIDI device '%s' ! (%s)%s\n",
+			MIDI_SEQ, strerror(errno),
+			errno == ENOENT ?
+			": create it ! (\"man MAKEDEV\" ?)" :
+			errno == ENODEV ?
+			": Load MIDI sequencer kernel driver !" :
+			errno == EACCES ?
+			": Grant access ! (\"man chmod\")" : ""
+		);
+	    }
 	    midi_warn = 0;
 	    return -1;
 	}
diff --git a/loader/main.c b/loader/main.c
index 44cb3d20c76..4e60ebbcc00 100644
--- a/loader/main.c
+++ b/loader/main.c
@@ -2,21 +2,18 @@
  * Main initialization code
  */
 
-#include <assert.h>
 #include <stdlib.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <unistd.h>
 #include <string.h>
-#include <errno.h>
 #include "windef.h"
 #include "wine/winbase16.h"
 #include "main.h"
 #include "drive.h"
 #include "file.h"
 #include "options.h"
-#include "process.h"
 #include "shell.h"
 #include "debugtools.h"
 #include "server.h"
diff --git a/loader/module.c b/loader/module.c
index 2f3729181e2..a68f4081fde 100644
--- a/loader/module.c
+++ b/loader/module.c
@@ -11,22 +11,13 @@
 #include <string.h>
 #include <sys/types.h>
 #include <unistd.h>
-#include "windef.h"
 #include "wine/winbase16.h"
 #include "winerror.h"
-#include "file.h"
-#include "global.h"
 #include "heap.h"
-#include "module.h"
-#include "snoop.h"
 #include "neexe.h"
-#include "dosexe.h"
 #include "process.h"
 #include "syslevel.h"
-#include "thread.h"
 #include "selectors.h"
-#include "stackframe.h"
-#include "task.h"
 #include "debugtools.h"
 #include "callback.h"
 #include "loadorder.h"
diff --git a/loader/ne/segment.c b/loader/ne/segment.c
index 2c89b2acbe8..1c652651fc2 100644
--- a/loader/ne/segment.c
+++ b/loader/ne/segment.c
@@ -14,19 +14,16 @@
 #include <unistd.h>
 #include <ctype.h>
 #include <string.h>
-#include <errno.h>
 
 #include "wine/winbase16.h"
 #include "neexe.h"
 #include "global.h"
 #include "task.h"
-#include "selectors.h"
 #include "file.h"
 #include "module.h"
 #include "stackframe.h"
 #include "builtin16.h"
 #include "debugtools.h"
-#include "toolhelp.h"
 
 DECLARE_DEBUG_CHANNEL(dll);
 DECLARE_DEBUG_CHANNEL(fixup);
diff --git a/loader/pe_image.c b/loader/pe_image.c
index 8775c1f423f..9c53fe4cda7 100644
--- a/loader/pe_image.c
+++ b/loader/pe_image.c
@@ -23,31 +23,13 @@
  *   NE_MODULE.module32.
  */
 
-#include "config.h"
-
-#include <errno.h>
-#include <assert.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
 #ifdef HAVE_SYS_MMAN_H
 #include <sys/mman.h>
 #endif
-#include "windef.h"
-#include "winbase.h"
 #include "wine/winbase16.h"
 #include "winerror.h"
-#include "callback.h"
-#include "file.h"
-#include "heap.h"
 #include "neexe.h"
 #include "process.h"
-#include "thread.h"
-#include "module.h"
-#include "global.h"
-#include "task.h"
 #include "snoop.h"
 #include "server.h"
 #include "debugtools.h"
diff --git a/misc/comm.c b/misc/comm.c
index 94322d7ab45..f93aef810c4 100644
--- a/misc/comm.c
+++ b/misc/comm.c
@@ -468,7 +468,7 @@ INT16 WINAPI OpenComm16(LPCSTR device,UINT16 cbInQueue,UINT16 cbOutQueue)
 
 		fd = open(COM[port].devicename, O_RDWR | O_NONBLOCK);
 		if (fd == -1) {
-			ERR("error=%d\n", errno);
+			ERR("Couldn't open %s ! (%s)\n", COM[port].devicename, strerror(errno));
 			return IE_HARDWARE;
 		} else {
                         unknown[port] = SEGPTR_ALLOC(40);
@@ -1992,11 +1992,7 @@ BOOL WINAPI SetCommState(HANDLE handle,LPDCB lpdcb)
          int save_error = errno;
          commerror = WinError();
          close( fd );
-#ifdef HAVE_STRERROR
          ERR("tcgetattr error '%s'\n", strerror(save_error));
-#else
-         ERR("tcgetattr error %d\n", save_error);
-#endif
          return FALSE;
      }
 
@@ -2260,11 +2256,7 @@ BOOL WINAPI SetCommState(HANDLE handle,LPDCB lpdcb)
 	        int save_error=errno;
 		commerror = WinError();	
                 close( fd );
-#ifdef HAVE_STRERROR
                 ERR("tcgetattr error '%s'\n", strerror(save_error));
-#else
-                ERR("tcgetattr error %d\n", save_error);
-#endif
 		return FALSE;
 	} else {
 		commerror = 0;
@@ -2291,11 +2283,7 @@ BOOL WINAPI GetCommState(HANDLE handle, LPDCB lpdcb)
        }
      if (tcgetattr(fd, &port) == -1) {
                 int save_error=errno;
-#ifdef HAVE_STRERROR
                 ERR("tcgetattr error '%s'\n", strerror(save_error));
-#else
-                ERR("tcgetattr error %d\n", save_error);
-#endif
 		commerror = WinError();	
                 close( fd );
 		return FALSE;
diff --git a/misc/ext_debugger.c b/misc/ext_debugger.c
index 95c72ca4174..b18f06a71f4 100644
--- a/misc/ext_debugger.c
+++ b/misc/ext_debugger.c
@@ -128,11 +128,11 @@ void DEBUG_ExternalDebugger(void)
     if (status == -1)
     {
       if (dbg_no_xterm)
-        fprintf(stderr, "DEBUG_ExternalDebugger failed to execute \"%s %s %s\", errno = %d\n", 
-                dbg_external, dbg_wine_location, pid_string, errno);
+        fprintf(stderr, "DEBUG_ExternalDebugger failed to execute \"%s %s %s\" (%s)\n", 
+                dbg_external, dbg_wine_location, pid_string, strerror(errno));
       else
-        fprintf(stderr, "DEBUG_ExternalDebugger failed to execute \"xterm -e %s %s %s\", errno = %d\n", 
-                dbg_external, dbg_wine_location, pid_string, errno);
+        fprintf(stderr, "DEBUG_ExternalDebugger failed to execute \"xterm -e %s %s %s\" (%s)\n", 
+                dbg_external, dbg_wine_location, pid_string, strerror(errno));
     }
 
   }
diff --git a/windows/x11drv/clipboard.c b/windows/x11drv/clipboard.c
index 8c855016e6e..d9290a72cbc 100644
--- a/windows/x11drv/clipboard.c
+++ b/windows/x11drv/clipboard.c
@@ -45,27 +45,16 @@
  *
  */
 
-#include "config.h"
-
-#include <X11/Xatom.h>
-
 #include "ts_xlib.h"
 
-#include <errno.h>
 #include <string.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <fcntl.h>
 
-#include "windef.h"
-#include "wingdi.h"
-#include "wine/winuser16.h"
 #include "clipboard.h"
-#include "message.h"
 #include "win.h"
 #include "x11drv.h"
-#include "bitmap.h"
-#include "heap.h"
 #include "options.h"
 #include "debugtools.h"
 
@@ -297,9 +286,6 @@ BOOL X11DRV_CLIPBOARD_LaunchServer()
         ERR("Could not create wait object. Clipboard server won't start!\n");
     else
     {
-        /* Make the event object's handle global */
-        selectionClearEvent = ConvertToGlobalHandle(selectionClearEvent);
-        
         /* Wait until we lose the selection, timing out after a minute */
 
         TRACE("Waiting for clipboard server to acquire selection\n");
-- 
GitLab