changeset 1107:884951ef2e7f

Fixed some warnings on recent versions of Linux/gcc regarding return values. Also switched to using the DW_ERROR_ constants instead of raw values.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 26 Jul 2011 09:39:36 +0000
parents eb6b27d17fe7
children 772d4c692ea5
files gtk/dw.c
diffstat 1 files changed, 25 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/gtk/dw.c	Tue Jul 26 09:32:50 2011 +0000
+++ b/gtk/dw.c	Tue Jul 26 09:39:36 2011 +0000
@@ -8644,6 +8644,7 @@
    {
       FD_ZERO(&rd);
       FD_SET(listenfd, &rd);
+      int result;
 
       maxfd = listenfd;
 
@@ -8731,7 +8732,7 @@
                          * continue.
                          */
                         if(array[s].waiting)
-                           write(array[s].fd, &tmp, 1);
+                           result = write(array[s].fd, &tmp, 1);
                      }
                   }
                   break;
@@ -8744,7 +8745,7 @@
 
                      /* If we are posted exit immeditately */
                      if(posted)
-                        write(array[z].fd, &tmp, 1);
+                        result = write(array[z].fd, &tmp, 1);
                   }
                   break;
                case 3:
@@ -8847,11 +8848,11 @@
    char tmp = (char)0;
 
    if(GPOINTER_TO_INT(eve) < 0)
-      return 0;
+      return DW_ERROR_NONE;
 
    if(write(GPOINTER_TO_INT(eve), &tmp, 1) == 1)
-      return 0;
-   return 1;
+      return DW_ERROR_NONE;
+   return DW_ERROR_GENERAL;
 }
 
 /* Sets the posted state of an event semaphore, any threads
@@ -8867,11 +8868,11 @@
    char tmp = (char)1;
 
    if(GPOINTER_TO_INT(eve) < 0)
-      return 0;
+      return DW_ERROR_NONE;
 
    if(write(GPOINTER_TO_INT(eve), &tmp, 1) == 1)
-      return 0;
-   return 1;
+      return DW_ERROR_NONE;
+   return DW_ERROR_GENERAL;
 }
 
 /* Waits on the specified semaphore until it becomes
@@ -8908,13 +8909,15 @@
 
    /* Signal wait */
    tmp = (char)2;
-   write(GPOINTER_TO_INT(eve), &tmp, 1);
-
-   retval = select(GPOINTER_TO_INT(eve)+1, &rd, NULL, NULL, useme);
+   retval = write(GPOINTER_TO_INT(eve), &tmp, 1);
+
+   if(retval == 1)
+      retval = select(GPOINTER_TO_INT(eve)+1, &rd, NULL, NULL, useme);
 
    /* Signal done waiting. */
    tmp = (char)3;
-   write(GPOINTER_TO_INT(eve), &tmp, 1);
+   if(retval == 1)
+      retval = write(GPOINTER_TO_INT(eve), &tmp, 1);
 
    if(retval == 0)
       return DW_ERROR_TIMEOUT;
@@ -8924,8 +8927,9 @@
    /* Clear the entry from the pipe so
     * we don't loop endlessly. :)
     */
-   read(GPOINTER_TO_INT(eve), &tmp, 1);
-   return 0;
+   if(read(GPOINTER_TO_INT(eve), &tmp, 1) == 1)
+	return DW_ERROR_NONE;
+   return DW_ERROR_GENERAL;
 }
 
 /* Release this semaphore, if there are no more open
@@ -8940,7 +8944,7 @@
     * cleanup will continue in _handle_sem.
     */
    close(GPOINTER_TO_INT(eve));
-   return 0;
+   return DW_ERROR_NONE;
 }
 
 /*
@@ -8989,7 +8993,12 @@
       return NULL;
    }
 
-   ftruncate(handle->fd, size);
+   if(ftruncate(handle->fd, size))
+   {
+       close(handle->fd);
+       free(handle);
+       return NULL;
+   }
 
    /* attach the shared memory segment to our process's address space. */
    *dest = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, handle->fd, 0);