xserver: Branch 'master' - 11 commits

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sun Mar 3 23:06:29 UTC 2024


 hw/xwin/InitOutput.c            |    8 ++++-
 hw/xwin/win.h                   |    3 ++
 hw/xwin/winallpriv.c            |   10 +------
 hw/xwin/winclipboard/debug.c    |   20 +++++---------
 hw/xwin/wincreatewnd.c          |   18 +++++--------
 hw/xwin/winmultiwindowicons.c   |    2 +
 hw/xwin/winmultiwindowwm.c      |   11 ++------
 hw/xwin/winmultiwindowwndproc.c |   14 ++++------
 hw/xwin/winprefs.c              |    2 +
 hw/xwin/winshadddnl.c           |   54 +++++++++++++++++-----------------------
 hw/xwin/winshadgdi.c            |   10 ++-----
 hw/xwin/winwndproc.c            |   12 +++-----
 include/os.h                    |    2 -
 os/access.c                     |   15 +----------
 os/connection.c                 |    4 ++
 os/osdep.h                      |   11 ++++++++
 os/strcasestr.c                 |    2 +
 os/utils.c                      |   53 ++-------------------------------------
 18 files changed, 92 insertions(+), 159 deletions(-)

New commits:
commit 77f9792911e2a3c48bb6e5d17b9f3090f1b0c343
Author: Enrico Weigelt, metux IT consult <info at metux.net>
Date:   Wed Feb 14 17:59:08 2024 +0100

    os: simplify win32 uname()
    
    Just define struct utsname and a tiny uname() function instead of
    cluttering the code with ifdef's.
    
    Signed-off-by: Enrico Weigelt, metux IT consult <info at metux.net>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1295>

diff --git a/os/access.c b/os/access.c
index 6b3cad4ca..cf784248d 100644
--- a/os/access.c
+++ b/os/access.c
@@ -446,15 +446,7 @@ DefineSelf(int fd)
     caddr_t addr;
     int family;
     register HOST *host;
-
-#ifndef WIN32
     struct utsname name;
-#else
-    struct {
-        char nodename[512];
-    } name;
-#endif
-
     register struct hostent *hp;
 
     union {
@@ -480,11 +472,7 @@ DefineSelf(int fd)
      * uname() lets me access to the whole string (it smashes release, you
      * see), whereas gethostname() kindly truncates it for me.
      */
-#ifndef WIN32
     uname(&name);
-#else
-    gethostname(name.nodename, sizeof(name.nodename));
-#endif
 
     hp = _XGethostbyname(name.nodename, hparams);
     if (hp != NULL) {
diff --git a/os/osdep.h b/os/osdep.h
index f5ad07705..385eddc44 100644
--- a/os/osdep.h
+++ b/os/osdep.h
@@ -133,4 +133,15 @@ extern void GenerateRandomData(int len, char *buf);
 void TimerInit(void);
 Bool TimerForce(OsTimerPtr timer);
 
+#ifdef WIN32
+#include <X11/Xwinsock.h>
+struct utsname {
+    char nodename[512];
+};
+
+static inline void uname(struct utsname *uts) {
+    gethostname(uts->nodename, sizeof(uts->nodename));
+}
+#endif /* WIN32 */
+
 #endif                          /* _OSDEP_H_ */
commit 02b5696e2bf6229975aecfd3f02cea45c361a4fc
Author: Enrico Weigelt, metux IT consult <info at metux.net>
Date:   Wed Feb 14 14:46:05 2024 +0100

    xwin: winsock.h needs to be included earlier
    
    [374/383] Compiling C object hw/xwin/Xming.exe.p/winmultiwindowicons.c.obj
    791In file included from /usr/i686-w64-mingw32/include/X11/Xwinsock.h:57,
    792                 from /usr/i686-w64-mingw32/include/xcb/xcb_windefs.h:34,
    793                 from /usr/i686-w64-mingw32/include/xcb/xcb.h:41,
    794                 from ../hw/xwin/winmultiwindowicons.c:43:
    795/usr/share/mingw-w64/include/winsock2.h:15:2: warning: #warning Please include winsock2.h before windows.h [-Wcpp]
    796   15 | #warning Please include winsock2.h before windows.h
    797      |  ^~~~~~~
    
    Signed-off-by: Enrico Weigelt, metux IT consult <info at metux.net>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1295>

diff --git a/hw/xwin/winmultiwindowicons.c b/hw/xwin/winmultiwindowicons.c
index 0ef666d89..e5b09e48d 100644
--- a/hw/xwin/winmultiwindowicons.c
+++ b/hw/xwin/winmultiwindowicons.c
@@ -44,6 +44,8 @@
 #include <xcb/xcb_icccm.h>
 #include <xcb/xcb_image.h>
 
+#include <winsock2.h>
+
 #include "winresource.h"
 #include "winprefs.h"
 #include "winmsg.h"
commit 7bd19a9580edd9e019c14fe41a63408132dda4ef
Author: Enrico Weigelt, metux IT consult <info at metux.net>
Date:   Wed Feb 14 12:01:17 2024 +0100

    xwin: replace ZeroMemory()
    
    replace Windows specific ZeroMemory (macro just calling memset())
    by static initialization, calloc() and memset().
    
    Signed-off-by: Enrico Weigelt, metux IT consult <info at metux.net>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1295>

diff --git a/hw/xwin/winallpriv.c b/hw/xwin/winallpriv.c
index 818805cb1..f8f7a8ec7 100644
--- a/hw/xwin/winallpriv.c
+++ b/hw/xwin/winallpriv.c
@@ -58,15 +58,12 @@ winAllocatePrivates(ScreenPtr pScreen)
     }
 
     /* Allocate memory for the screen private structure */
-    pScreenPriv = malloc(sizeof(winPrivScreenRec));
+    pScreenPriv = calloc(sizeof(winPrivScreenRec), 1);
     if (!pScreenPriv) {
         ErrorF("winAllocateScreenPrivates - malloc () failed\n");
         return FALSE;
     }
 
-    /* Initialize the memory of the private structure */
-    ZeroMemory(pScreenPriv, sizeof(winPrivScreenRec));
-
     /* Initialize private structure members */
     pScreenPriv->fActive = TRUE;
 
@@ -143,15 +140,12 @@ winAllocateCmapPrivates(ColormapPtr pCmap)
     }
 
     /* Allocate memory for our private structure */
-    pCmapPriv = malloc(sizeof(winPrivCmapRec));
+    pCmapPriv = calloc(sizeof(winPrivCmapRec), 1);
     if (!pCmapPriv) {
         ErrorF("winAllocateCmapPrivates - malloc () failed\n");
         return FALSE;
     }
 
-    /* Initialize the memory of the private structure */
-    ZeroMemory(pCmapPriv, sizeof(winPrivCmapRec));
-
     /* Register our colourmap private */
     if (!dixRegisterPrivateKey(g_iCmapPrivateKey, PRIVATE_COLORMAP, 0)) {
         ErrorF("winAllocateCmapPrivates - AllocateCmapPrivate () failed\n");
diff --git a/hw/xwin/wincreatewnd.c b/hw/xwin/wincreatewnd.c
index 444e843ec..d57d66a19 100644
--- a/hw/xwin/wincreatewnd.c
+++ b/hw/xwin/wincreatewnd.c
@@ -512,14 +512,12 @@ winGetWorkArea(RECT * prcWorkArea, winScreenInfo * pScreenInfo)
 static Bool
 winTaskbarOnScreenEdge(unsigned int uEdge, winScreenInfo * pScreenInfo)
 {
-    APPBARDATA abd;
-    HWND hwndAutoHide;
+    APPBARDATA abd = (APPBARDATA) {
+        .cbSize = sizeof(APPBARDATA),
+        .uEdge = uEdge
+    };
 
-    ZeroMemory(&abd, sizeof(abd));
-    abd.cbSize = sizeof(abd);
-    abd.uEdge = uEdge;
-
-    hwndAutoHide = (HWND) SHAppBarMessage(ABM_GETAUTOHIDEBAR, &abd);
+    HWND hwndAutoHide = (HWND) SHAppBarMessage(ABM_GETAUTOHIDEBAR, &abd);
     if (hwndAutoHide != NULL) {
         /*
            Found an autohide taskbar on that edge, but is it on the
@@ -541,15 +539,15 @@ winTaskbarOnScreenEdge(unsigned int uEdge, winScreenInfo * pScreenInfo)
 static Bool
 winAdjustForAutoHide(RECT * prcWorkArea, winScreenInfo * pScreenInfo)
 {
-    APPBARDATA abd;
+    APPBARDATA abd = (APPBARDATA) {
+        .cbSize = sizeof(APPBARDATA)
+    };
 
     winDebug("winAdjustForAutoHide - Original WorkArea: %d %d %d %d\n",
              (int) prcWorkArea->top, (int) prcWorkArea->left,
              (int) prcWorkArea->bottom, (int) prcWorkArea->right);
 
     /* Find out if the Windows taskbar is set to auto-hide */
-    ZeroMemory(&abd, sizeof(abd));
-    abd.cbSize = sizeof(abd);
     if (SHAppBarMessage(ABM_GETSTATE, &abd) & ABS_AUTOHIDE)
         winDebug("winAdjustForAutoHide - Taskbar is auto hide\n");
 
diff --git a/hw/xwin/winmultiwindowwm.c b/hw/xwin/winmultiwindowwm.c
index 37f1a7a02..ac0ef6c25 100644
--- a/hw/xwin/winmultiwindowwm.c
+++ b/hw/xwin/winmultiwindowwm.c
@@ -1395,9 +1395,9 @@ winInitWM(void **ppWMInfo,
           pthread_mutex_t * ppmServerStarted,
           int dwScreen, HWND hwndScreen, Bool compositeWM)
 {
-    WMProcArgPtr pArg = malloc(sizeof(WMProcArgRec));
-    WMInfoPtr pWMInfo = malloc(sizeof(WMInfoRec));
-    XMsgProcArgPtr pXMsgArg = malloc(sizeof(XMsgProcArgRec));
+    WMProcArgPtr pArg = calloc(sizeof(WMProcArgRec), 1);
+    WMInfoPtr pWMInfo = calloc(sizeof(WMInfoRec), 1);
+    XMsgProcArgPtr pXMsgArg = calloc(sizeof(XMsgProcArgRec), 1);
 
     /* Bail if the input parameters are bad */
     if (pArg == NULL || pWMInfo == NULL || pXMsgArg == NULL) {
@@ -1408,11 +1408,6 @@ winInitWM(void **ppWMInfo,
         return FALSE;
     }
 
-    /* Zero the allocated memory */
-    ZeroMemory(pArg, sizeof(WMProcArgRec));
-    ZeroMemory(pWMInfo, sizeof(WMInfoRec));
-    ZeroMemory(pXMsgArg, sizeof(XMsgProcArgRec));
-
     /* Set a return pointer to the Window Manager info structure */
     *ppWMInfo = pWMInfo;
     pWMInfo->fCompositeWM = compositeWM;
diff --git a/hw/xwin/winmultiwindowwndproc.c b/hw/xwin/winmultiwindowwndproc.c
index dcb21758a..1c06e183c 100644
--- a/hw/xwin/winmultiwindowwndproc.c
+++ b/hw/xwin/winmultiwindowwndproc.c
@@ -621,13 +621,11 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
 
         /* Are we tracking yet? */
         if (!s_fTracking) {
-            TRACKMOUSEEVENT tme;
-
-            /* Setup data structure */
-            ZeroMemory(&tme, sizeof(tme));
-            tme.cbSize = sizeof(tme);
-            tme.dwFlags = TME_LEAVE;
-            tme.hwndTrack = hwnd;
+            TRACKMOUSEEVENT tme = (TRACKMOUSEEVENT) {
+                .cbSize = sizeof(TRACKMOUSEEVENT),
+                .dwFlags = TME_LEAVE,
+                .hwndTrack = hwnd,
+            };
 
             /* Call the tracking function */
             if (!TrackMouseEvent(&tme))
diff --git a/hw/xwin/winshadddnl.c b/hw/xwin/winshadddnl.c
index 290176920..a604169c5 100644
--- a/hw/xwin/winshadddnl.c
+++ b/hw/xwin/winshadddnl.c
@@ -98,16 +98,14 @@ winCreatePrimarySurfaceShadowDDNL(ScreenPtr pScreen)
 {
     winScreenPriv(pScreen);
     HRESULT ddrval = DD_OK;
-    DDSURFACEDESC2 ddsd;
+    DDSURFACEDESC2 ddsd = (DDSURFACEDESC2) {
+        .dwSize = sizeof(DDSURFACEDESC2),
+        .dwFlags = DDSD_CAPS,
+        .ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE
+    };
 
     winDebug("winCreatePrimarySurfaceShadowDDNL - Creating primary surface\n");
 
-    /* Describe the primary surface */
-    ZeroMemory(&ddsd, sizeof(ddsd));
-    ddsd.dwSize = sizeof(ddsd);
-    ddsd.dwFlags = DDSD_CAPS;
-    ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
-
     /* Create the primary surface */
     ddrval = IDirectDraw4_CreateSurface(pScreenPriv->pdd4,
                                         &ddsd,
@@ -195,9 +193,10 @@ winAllocateFBShadowDDNL(ScreenPtr pScreen)
     winScreenPriv(pScreen);
     winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
     HRESULT ddrval = DD_OK;
-    DDSURFACEDESC2 ddsdShadow;
     char *lpSurface = NULL;
-    DDPIXELFORMAT ddpfPrimary;
+    DDPIXELFORMAT ddpfPrimary = (DDPIXELFORMAT) {
+        .dwSize = sizeof(DDPIXELFORMAT)
+    };
 
 #if CYGDEBUG
     winDebug("winAllocateFBShadowDDNL - w %u h %u d %u\n",
@@ -211,18 +210,12 @@ winAllocateFBShadowDDNL(ScreenPtr pScreen)
                                                pScreenInfo->dwBPP);
 
     /* Allocate memory for our shadow surface */
-    lpSurface = malloc(pScreenInfo->dwPaddedWidth * pScreenInfo->dwHeight);
+    lpSurface = calloc(pScreenInfo->dwPaddedWidth, pScreenInfo->dwHeight);
     if (lpSurface == NULL) {
         ErrorF("winAllocateFBShadowDDNL - Could not allocate bits\n");
         return FALSE;
     }
 
-    /*
-     * Initialize the framebuffer memory so we don't get a
-     * strange display at startup
-     */
-    ZeroMemory(lpSurface, pScreenInfo->dwPaddedWidth * pScreenInfo->dwHeight);
-
     /* Create a clipper */
     ddrval = (*g_fpDirectDrawCreateClipper) (0,
                                              &pScreenPriv->pddcPrimary, NULL);
@@ -275,7 +268,6 @@ winAllocateFBShadowDDNL(ScreenPtr pScreen)
 
     /* Are we full screen? */
     if (pScreenInfo->fFullScreen) {
-        DDSURFACEDESC2 ddsdCurrent;
         DWORD dwRefreshRateCurrent = 0;
         HDC hdc = NULL;
 
@@ -295,8 +287,9 @@ winAllocateFBShadowDDNL(ScreenPtr pScreen)
          * if a refresh rate has been passed on the command line.
          */
         if (pScreenInfo->dwRefreshRate != 0) {
-            ZeroMemory(&ddsdCurrent, sizeof(ddsdCurrent));
-            ddsdCurrent.dwSize = sizeof(ddsdCurrent);
+            DDSURFACEDESC2 ddsdCurrent = (DDSURFACEDESC2) {
+                .dwSize = sizeof(DDSURFACEDESC2)
+            };
 
             /* Get information about current display settings */
             ddrval = IDirectDraw4_GetDisplayMode(pScreenPriv->pdd4,
@@ -390,8 +383,6 @@ winAllocateFBShadowDDNL(ScreenPtr pScreen)
     }
 
     /* Get primary surface's pixel format */
-    ZeroMemory(&ddpfPrimary, sizeof(ddpfPrimary));
-    ddpfPrimary.dwSize = sizeof(ddpfPrimary);
     ddrval = IDirectDrawSurface4_GetPixelFormat(pScreenPriv->pddsPrimary4,
                                                 &ddpfPrimary);
     if (FAILED(ddrval)) {
@@ -418,16 +409,17 @@ winAllocateFBShadowDDNL(ScreenPtr pScreen)
      * so you shouldn't be allocating video memory when
      * you have the option of using system memory instead.
      */
-    ZeroMemory(&ddsdShadow, sizeof(ddsdShadow));
-    ddsdShadow.dwSize = sizeof(ddsdShadow);
-    ddsdShadow.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH
-        | DDSD_LPSURFACE | DDSD_PITCH | DDSD_PIXELFORMAT;
-    ddsdShadow.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
-    ddsdShadow.dwHeight = pScreenInfo->dwHeight;
-    ddsdShadow.dwWidth = pScreenInfo->dwWidth;
-    ddsdShadow.u1.lPitch = pScreenInfo->dwPaddedWidth;
-    ddsdShadow.lpSurface = lpSurface;
-    ddsdShadow.u4.ddpfPixelFormat = ddpfPrimary;
+    DDSURFACEDESC2 ddsdShadow = (DDSURFACEDESC2) {
+        .dwSize = sizeof(ddsdShadow),
+        .dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH
+            | DDSD_LPSURFACE | DDSD_PITCH | DDSD_PIXELFORMAT,
+        .ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY,
+        .dwHeight = pScreenInfo->dwHeight,
+        .dwWidth = pScreenInfo->dwWidth,
+        .u1.lPitch = pScreenInfo->dwPaddedWidth,
+        .lpSurface = lpSurface,
+        .u4.ddpfPixelFormat = ddpfPrimary
+    };
 
     winDebug("winAllocateFBShadowDDNL - lPitch: %d\n",
              (int) pScreenInfo->dwPaddedWidth);
diff --git a/hw/xwin/winshadgdi.c b/hw/xwin/winshadgdi.c
index 25e16bf76..222d5e2f3 100644
--- a/hw/xwin/winshadgdi.c
+++ b/hw/xwin/winshadgdi.c
@@ -106,7 +106,7 @@ winQueryScreenDIBFormat(ScreenPtr pScreen, BITMAPINFOHEADER * pbmih)
     }
 
     /* Initialize our bitmap info header */
-    ZeroMemory(pbmih, sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));
+    memset(pbmih, sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD), 1);
     pbmih->biSize = sizeof(BITMAPINFOHEADER);
 
     /* Get the biBitCount */
@@ -1162,18 +1162,14 @@ winCreateColormapShadowGDI(ColormapPtr pColormap)
     dwEntriesMax = pVisual->ColormapEntries;
 
     /* Allocate a Windows logical color palette with max entries */
-    lpPaletteNew = malloc(sizeof(LOGPALETTE)
-                          + (dwEntriesMax - 1) * sizeof(PALETTEENTRY));
+    lpPaletteNew = calloc(sizeof(LOGPALETTE)
+                          + (dwEntriesMax - 1) * sizeof(PALETTEENTRY), 1);
     if (lpPaletteNew == NULL) {
         ErrorF("winCreateColormapShadowGDI - Couldn't allocate palette "
                "with %d entries\n", (int) dwEntriesMax);
         return FALSE;
     }
 
-    /* Zero out the colormap */
-    ZeroMemory(lpPaletteNew, sizeof(LOGPALETTE)
-               + (dwEntriesMax - 1) * sizeof(PALETTEENTRY));
-
     /* Set the logical palette structure */
     lpPaletteNew->palVersion = 0x0300;
     lpPaletteNew->palNumEntries = dwEntriesMax;
diff --git a/hw/xwin/winwndproc.c b/hw/xwin/winwndproc.c
index c7950880f..3953b66d8 100644
--- a/hw/xwin/winwndproc.c
+++ b/hw/xwin/winwndproc.c
@@ -711,13 +711,11 @@ winWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
 
         /* Are we tracking yet? */
         if (!s_fTracking) {
-            TRACKMOUSEEVENT tme;
-
-            /* Setup data structure */
-            ZeroMemory(&tme, sizeof(tme));
-            tme.cbSize = sizeof(tme);
-            tme.dwFlags = TME_LEAVE;
-            tme.hwndTrack = hwnd;
+            TRACKMOUSEEVENT tme = (TRACKMOUSEEVENT) {
+                tme.cbSize = sizeof(tme),
+                tme.dwFlags = TME_LEAVE,
+                tme.hwndTrack = hwnd
+            };
 
             /* Call the tracking function */
             if (!TrackMouseEvent(&tme))
diff --git a/os/utils.c b/os/utils.c
index dc3fdef82..c5fe86c8f 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -1492,15 +1492,13 @@ Win32TempDir(void)
 int
 System(const char *cmdline)
 {
-    STARTUPINFO si;
-    PROCESS_INFORMATION pi;
+    STARTUPINFO si = (STARTUPINFO) {
+        .cb = sizeof(si),
+    };
+    PROCESS_INFORMATION pi = (PROCESS_INFORMATION){0};
     DWORD dwExitCode;
     char *cmd = strdup(cmdline);
 
-    ZeroMemory(&si, sizeof(si));
-    si.cb = sizeof(si);
-    ZeroMemory(&pi, sizeof(pi));
-
     if (!CreateProcess(NULL, cmd, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) {
         LPVOID buffer;
 
commit c444223da3737b71634cc116d10f66febef7fa6e
Author: Enrico Weigelt, metux IT consult <info at metux.net>
Date:   Wed Feb 14 14:52:16 2024 +0100

    xwin: fix missing prototype for winValidateArgs()
    
    [378/383] Compiling C object hw/xwin/Xming.exe.p/winvalargs.c.obj
    811../hw/xwin/winvalargs.c:57:1: warning: no previous prototype for ‘winValidateArgs’ [-Wmissing-prototypes]
    812   57 | winValidateArgs(void)
    813      | ^~~~~~~~~~~~~~~
    
    Signed-off-by: Enrico Weigelt, metux IT consult <info at metux.net>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1295>

diff --git a/hw/xwin/win.h b/hw/xwin/win.h
index 48795a8b5..3aa158e91 100644
--- a/hw/xwin/win.h
+++ b/hw/xwin/win.h
@@ -1038,6 +1038,9 @@ winCreateMsgWindowThread(void);
 void
 winOS(void);
 
+Bool
+winValidateArgs(void);
+
 /*
  * END DDX and DIX Function Prototypes
  */
commit 123a473e334db9f6263945d09c9089c4766587dd
Author: Enrico Weigelt, metux IT consult <info at metux.net>
Date:   Wed Feb 14 14:42:59 2024 +0100

    xwin: fix possibly missing string termination
    
    ../hw/xwin/InitOutput.c: In function ‘winFixupPaths’:
    747../hw/xwin/InitOutput.c:578:9: warning: ‘strncpy’ output truncated before terminating nul copying 5 bytes from a string of the same length [-Wstringop-truncation]
    748  578 |         strncpy(buffer, "HOME=", 5);
    749      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    Signed-off-by: Enrico Weigelt, metux IT consult <info at metux.net>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1295>

diff --git a/hw/xwin/InitOutput.c b/hw/xwin/InitOutput.c
index b72cc71a5..5a42f43bb 100644
--- a/hw/xwin/InitOutput.c
+++ b/hw/xwin/InitOutput.c
@@ -577,9 +577,9 @@ winFixupPaths(void)
         putenv(buffer);
     }
     if (getenv("HOME") == NULL) {
-        char buffer[MAX_PATH + 5];
+        char buffer[MAX_PATH + 5] = {0};
 
-        strncpy(buffer, "HOME=", 5);
+        strncpy(buffer, "HOME=", 6);
 
         /* query appdata directory */
         if (SHGetFolderPathA
commit f855e35df2428c2b6b65f6e3637060809aafec94
Author: Enrico Weigelt, metux IT consult <info at metux.net>
Date:   Wed Feb 14 14:40:55 2024 +0100

    xwin: winclipboard: fix missing prototypes / missing include
    
    [324/383] Compiling C object hw/xwin/winclipboard/xwinclip.exe.p/debug.c.obj
    666../hw/xwin/winclipboard/debug.c:31:1: warning: no previous prototype for ‘winDebug’ [-Wmissing-prototypes]
    667   31 | winDebug(const char *format, ...)
    668      | ^~~~~~~~
    669../hw/xwin/winclipboard/debug.c: In function ‘winDebug’:
    670../hw/xwin/winclipboard/debug.c:37:3: warning: function ‘winDebug’ might be a candidate for ‘gnu_printf’ format attribute [-Wsuggest-attribute=format]
    671   37 |   count += vfprintf(stderr, format, ap);
    672      |   ^~~~~
    673../hw/xwin/winclipboard/debug.c: At top level:
    674../hw/xwin/winclipboard/debug.c:44:1: warning: no previous prototype for ‘ErrorF’ [-Wmissing-prototypes]
    675   44 | ErrorF(const char *format, ...)
    676      | ^~~~~~
    677../hw/xwin/winclipboard/debug.c: In function ‘ErrorF’:
    678../hw/xwin/winclipboard/debug.c:49:3: warning: function ‘ErrorF’ might be a candidate for ‘gnu_printf’ format attribute [-Wsuggest-attribute=format]
    679   49 |   count = vfprintf(stderr, format, ap);
    680      |   ^~~~~
    
    Signed-off-by: Enrico Weigelt, metux IT consult <info at metux.net>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1295>

diff --git a/hw/xwin/winclipboard/debug.c b/hw/xwin/winclipboard/debug.c
index 78ab6d902..ef8adc11f 100644
--- a/hw/xwin/winclipboard/debug.c
+++ b/hw/xwin/winclipboard/debug.c
@@ -26,27 +26,21 @@
 #include <stdarg.h>
 #include <stdio.h>
 
-#if 1
-int
-winDebug(const char *format, ...)
+#include "internal.h"
+
+void winDebug(const char *format, ...)
 {
-  int count;
   va_list ap;
   va_start(ap, format);
-  count = fprintf(stderr, "xwinclip: ");
-  count += vfprintf(stderr, format, ap);
+  fprintf(stderr, "xwinclip: ");
+  vfprintf(stderr, format, ap);
   va_end(ap);
-  return count;
 }
-#endif
 
-int
-ErrorF(const char *format, ...)
+void ErrorF(const char *format, ...)
 {
-  int count;
   va_list ap;
   va_start(ap, format);
-  count = vfprintf(stderr, format, ap);
+  vfprintf(stderr, format, ap);
   va_end(ap);
-  return count;
 }
commit b93c614176dedb25f0dcd58b02c67578acce6dc3
Author: Enrico Weigelt, metux IT consult <info at metux.net>
Date:   Wed Feb 14 13:45:45 2024 +0100

    xwin: fix unused variables
    
    ../hw/xwin/winmultiwindowwndproc.c:418:17: warning: unused variable ‘ps’ [-Wunused-variable]
    744  418 |     PAINTSTRUCT ps;
    745      |                 ^~
    
    ../hw/xwin/InitOutput.c:114:13: warning: ‘noDriExtension’ defined but not used [-Wunused-variable]
    752  114 | static Bool noDriExtension;
    753      |             ^~~~~~~~~~~~~~
    
    375/383] Compiling C object hw/xwin/Xming.exe.p/winprefs.c.obj
    799../hw/xwin/winprefs.c: In function ‘LoadImageComma’:
    800../hw/xwin/winprefs.c:545:14: warning: unused variable ‘convert’ [-Wunused-variable]
    801  545 |         Bool convert = FALSE;
    802      |              ^~~~~~~
    
    Signed-off-by: Enrico Weigelt, metux IT consult <info at metux.net>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1295>

diff --git a/hw/xwin/InitOutput.c b/hw/xwin/InitOutput.c
index 7a03bfb91..b72cc71a5 100644
--- a/hw/xwin/InitOutput.c
+++ b/hw/xwin/InitOutput.c
@@ -111,7 +111,11 @@ static PixmapFormatRec g_PixmapFormats[] = {
     {32, 32, BITMAP_SCANLINE_PAD}
 };
 
+#ifdef GLXEXT
+#ifdef XWIN_WINDOWS_DRI
 static Bool noDriExtension;
+#endif
+#endif
 
 static const ExtensionModule xwinExtensions[] = {
 #ifdef GLXEXT
diff --git a/hw/xwin/winmultiwindowwndproc.c b/hw/xwin/winmultiwindowwndproc.c
index 31b5d6307..dcb21758a 100644
--- a/hw/xwin/winmultiwindowwndproc.c
+++ b/hw/xwin/winmultiwindowwndproc.c
@@ -415,7 +415,6 @@ LRESULT CALLBACK
 winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
 {
     POINT ptMouse;
-    PAINTSTRUCT ps;
     WindowPtr pWin = NULL;
     winPrivWinPtr pWinPriv = NULL;
     ScreenPtr s_pScreen = NULL;
@@ -578,6 +577,7 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
 
 #ifdef XWIN_GLX_WINDOWS
         if (pWinPriv->fWglUsed) {
+            PAINTSTRUCT ps;
             /*
                For regions which are being drawn by GL, the shadow framebuffer doesn't have the
                correct bits, so don't bitblt from the shadow framebuffer
diff --git a/hw/xwin/winprefs.c b/hw/xwin/winprefs.c
index d0b2ef2e7..8cf45fd51 100644
--- a/hw/xwin/winprefs.c
+++ b/hw/xwin/winprefs.c
@@ -542,7 +542,9 @@ LoadImageComma(char *fname, char *iconDirectory, int sx, int sy, int flags)
     }
     else {
         char *file = malloc(PATH_MAX + NAME_MAX + 2);
+#ifdef  __CYGWIN__
         Bool convert = FALSE;
+#endif
 
         if (!file)
             return NULL;
commit de34a20dc3f636cce71578d600a464263beeb32a
Author: Enrico Weigelt, metux IT consult <info at metux.net>
Date:   Wed Feb 14 14:33:50 2024 +0100

    os: fix mising prototype / include on WIN32 builds
    
    [90/383] Compiling C object os/liblibxlibc.a.p/strcasestr.c.obj
    359../os/strcasestr.c:45:1: warning: no previous prototype for ‘xstrcasestr’ [-Wmissing-prototypes]
    360   45 | xstrcasestr(const char *s, const char *find)
    361      | ^~~~~~~~~~~
    
    Signed-off-by: Enrico Weigelt, metux IT consult <info at metux.net>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1295>

diff --git a/os/strcasestr.c b/os/strcasestr.c
index 3189cf21e..4e483a940 100644
--- a/os/strcasestr.c
+++ b/os/strcasestr.c
@@ -37,6 +37,8 @@
 #include <ctype.h>
 #include <string.h>
 
+#include "os.h"
+
 /*
  * Find the first occurrence of find in s, ignore case.
  */
commit 0706c03f9dec5cb5cbdbd0ef66156eb3fcd8bd33
Author: Enrico Weigelt, metux IT consult <info at metux.net>
Date:   Wed Feb 14 14:37:05 2024 +0100

    os: fix unused variable on WIN32 build
    
    ../os/access.c:443:18: warning: unused variable ‘n’ [-Wunused-variable]
    420  443 |     register int n;
    421      |                  ^
    422
    
    [120/383] Compiling C object os/liblibxserver_os.a.p/connection.c.obj
    431../os/connection.c:137:14: warning: ‘ParentProcess’ defined but not used [-Wunused-variable]
    432  137 | static Pid_t ParentProcess;
    433      |              ^~~~~~~~~~~~~
    
    ../os/connection.c:132:13: warning: ‘RunFromSmartParent’ defined but not used [-Wunused-variable]
    435  132 | static Bool RunFromSmartParent; /* send SIGUSR1 to parent process */
    436      |             ^~~~~~~~~~~~~~~~~~
    
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1295>

diff --git a/os/access.c b/os/access.c
index 4c7151d06..6b3cad4ca 100644
--- a/os/access.c
+++ b/os/access.c
@@ -442,7 +442,6 @@ DefineSelf(int fd)
 #if !defined(TCPCONN) && !defined(UNIXCONN)
     return;
 #else
-    register int n;
     int len;
     caddr_t addr;
     int family;
diff --git a/os/connection.c b/os/connection.c
index d957ad661..f7e10b3ba 100644
--- a/os/connection.c
+++ b/os/connection.c
@@ -124,12 +124,14 @@ struct ospoll   *server_poll;
 Bool NewOutputPending;          /* not yet attempted to write some new output */
 Bool NoListenAll;               /* Don't establish any listening sockets */
 
-static Bool RunFromSmartParent; /* send SIGUSR1 to parent process */
 Bool RunFromSigStopParent;      /* send SIGSTOP to our own process; Upstart (or
                                    equivalent) will send SIGCONT back. */
 static char dynamic_display[7]; /* display name */
 Bool PartialNetwork;            /* continue even if unable to bind all addrs */
+#if !defined(WIN32)
 static Pid_t ParentProcess;
+static Bool RunFromSmartParent; /* send SIGUSR1 to parent process */
+#endif
 
 int GrabInProgress = 0;
 
commit 43a6d4eb61e3e1b423a86c9b163e003f81652c8c
Author: Enrico Weigelt, metux IT consult <info at metux.net>
Date:   Wed Feb 14 14:35:15 2024 +0100

    os: fix unused variable on non-IPv6 build
    
    [119/383] Compiling C object os/liblibxserver_os.a.p/access.c.obj
    415../os/access.c: In function ‘DefineSelf’:
    416../os/access.c:468:26: warning: unused variable ‘inet6addr’ [-Wunused-variable]
    417  468 |     struct sockaddr_in6 *inet6addr;
    418      |                          ^~~~~~~~~
    
    Signed-off-by: Enrico Weigelt, metux IT consult <info at metux.net>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1295>

diff --git a/os/access.c b/os/access.c
index 2192fb7d0..4c7151d06 100644
--- a/os/access.c
+++ b/os/access.c
@@ -467,7 +467,9 @@ DefineSelf(int fd)
     } saddr;
 
     struct sockaddr_in *inetaddr;
+#if defined(IPv6) && defined(AF_INET6)
     struct sockaddr_in6 *inet6addr;
+#endif
     struct sockaddr_in broad_addr;
 
 #ifdef XTHREADS_NEEDS_BYNAMEPARAMS
commit 5d2f675ca80517fb01efbff0315e2dfc07c0a19b
Author: Enrico Weigelt, metux IT consult <info at metux.net>
Date:   Tue Jan 30 16:28:01 2024 +0100

    os: utils: drop obsolete System() on non-win32 targets
    
    This function is only used on WIN32 targets, so we can drop the *nix
    implementation.
    
    Signed-off-by: Enrico Weigelt, metux IT consult <info at metux.net>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1295>

diff --git a/include/os.h b/include/os.h
index 29c849b11..fef7a1719 100644
--- a/include/os.h
+++ b/include/os.h
@@ -332,8 +332,6 @@ OsAbort(void)
     _X_NORETURN;
 
 #if !defined(WIN32)
-extern _X_EXPORT int
-System(const char *);
 extern _X_EXPORT void *
 Popen(const char *, const char *);
 extern _X_EXPORT int
diff --git a/os/utils.c b/os/utils.c
index ba8ebf97a..dc3fdef82 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -1297,49 +1297,6 @@ OsAbort(void)
  * as well.  As it is now, xkbcomp messages don't end up in the log file.
  */
 
-int
-System(const char *command)
-{
-    int pid, p;
-    void (*csig) (int);
-    int status;
-
-    if (!command)
-        return 1;
-
-    csig = OsSignal(SIGCHLD, SIG_DFL);
-    if (csig == SIG_ERR) {
-        perror("signal");
-        return -1;
-    }
-    DebugF("System: `%s'\n", command);
-
-    switch (pid = fork()) {
-    case -1:                   /* error */
-        p = -1;
-        break;
-    case 0:                    /* child */
-        if (setgid(getgid()) == -1)
-            _exit(127);
-        if (setuid(getuid()) == -1)
-            _exit(127);
-        execl("/bin/sh", "sh", "-c", command, (char *) NULL);
-        _exit(127);
-    default:                   /* parent */
-        do {
-            p = waitpid(pid, &status, 0);
-        } while (p == -1 && errno == EINTR);
-
-    }
-
-    if (OsSignal(SIGCHLD, csig) == SIG_ERR) {
-        perror("signal");
-        return -1;
-    }
-
-    return p == -1 ? -1 : status;
-}
-
 static struct pid {
     struct pid *next;
     FILE *fp;


More information about the xorg-commit mailing list