diff gtk3/dw.c @ 2855:86286f528adf

Fix new safety warnings reported by the new GCC on Linux. The semaphore code is used on other platforms... make sure all platforms using this code are the same.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 15 Nov 2022 03:50:00 +0000
parents 8a5131cbbe93
children 59106bf7f9f4
line wrap: on
line diff
--- a/gtk3/dw.c	Tue Nov 15 02:29:56 2022 +0000
+++ b/gtk3/dw.c	Tue Nov 15 03:50:00 2022 +0000
@@ -8605,15 +8605,15 @@
    return DW_ERROR_NONE;
 }
 
-struct _seminfo {
+struct _dw_seminfo {
    int fd;
    int waiting;
 };
 
-static void _handle_sem(int *tmpsock)
+static void _dw_handle_sem(int *tmpsock)
 {
    fd_set rd;
-   struct _seminfo *array = (struct _seminfo *)malloc(sizeof(struct _seminfo));
+   struct _dw_seminfo *array = (struct _dw_seminfo *)malloc(sizeof(struct _dw_seminfo));
    int listenfd = tmpsock[0];
    int bytesread, connectcount = 1, maxfd, z, posted = 0;
    char command;
@@ -8660,14 +8660,14 @@
 
       if(FD_ISSET(listenfd, &rd))
       {
-         struct _seminfo *newarray;
+         struct _dw_seminfo *newarray;
          int newfd = accept(listenfd, 0, 0);
 
          if(newfd > -1)
          {
             /* Add new connections to the set */
-            newarray = (struct _seminfo *)malloc(sizeof(struct _seminfo)*(connectcount+1));
-            memcpy(newarray, array, sizeof(struct _seminfo)*(connectcount));
+            newarray = (struct _dw_seminfo *)malloc(sizeof(struct _dw_seminfo)*(connectcount+1));
+            memcpy(newarray, array, sizeof(struct _dw_seminfo)*(connectcount));
 
             newarray[connectcount].fd = newfd;
             newarray[connectcount].waiting = 0;
@@ -8687,17 +8687,17 @@
          {
             if((bytesread = read(array[z].fd, &command, 1)) < 1)
             {
-               struct _seminfo *newarray;
+               struct _dw_seminfo *newarray;
 
                /* Remove this connection from the set */
-               newarray = (struct _seminfo *)malloc(sizeof(struct _seminfo)*(connectcount-1));
+               newarray = (struct _dw_seminfo *)malloc(sizeof(struct _dw_seminfo)*(connectcount-1));
                if(!z)
-                  memcpy(newarray, &array[1], sizeof(struct _seminfo)*(connectcount-1));
+                  memcpy(newarray, &array[1], sizeof(struct _dw_seminfo)*(connectcount-1));
                else
                {
-                  memcpy(newarray, array, sizeof(struct _seminfo)*z);
+                  memcpy(newarray, array, sizeof(struct _dw_seminfo)*z);
                   if(z!=(connectcount-1))
-                     memcpy(&newarray[z], &array[z+1], sizeof(struct _seminfo)*(z-connectcount-1));
+                     memcpy(&newarray[z], &array[z+1], sizeof(struct _dw_seminfo)*(connectcount-(z+1)));
                }
                connectcount--;
 
@@ -8807,7 +8807,7 @@
    }
 
    /* Create a thread to handle this event semaphore */
-   pthread_create(&dwthread, NULL, (void *)_handle_sem, (void *)tmpsock);
+   pthread_create(&dwthread, NULL, (void *)_dw_handle_sem, (void *)tmpsock);
    return GINT_TO_POINTER(ev);
 }
 
@@ -8935,7 +8935,7 @@
 int dw_named_event_close(HEV eve)
 {
    /* Finally close the domain socket,
-    * cleanup will continue in _handle_sem.
+    * cleanup will continue in _dw_handle_sem.
     */
    close(GPOINTER_TO_INT(eve));
    return DW_ERROR_NONE;