-minor code cleanup
authorChristian Grothoff <christian@grothoff.org>
Wed, 18 Jul 2012 09:15:40 +0000 (09:15 +0000)
committerChristian Grothoff <christian@grothoff.org>
Wed, 18 Jul 2012 09:15:40 +0000 (09:15 +0000)
src/include/gnunet_disk_lib.h
src/util/disk.c
src/util/network.c
src/util/os_priority.c

index 1e2ab8c19ccbd32f2f5dfec8a13dfbc8c92e3b86..51f58565542b96f5fb98439fd8071cac66fde3ac 100644 (file)
  */
 struct GNUNET_DISK_PipeHandle;
 
-
+/**
+ * Type of a handle.
+ */
 enum GNUNET_FILE_Type
 {
-  GNUNET_DISK_FILE, GNUNET_PIPE
+  /**
+   * Handle represents a file.
+   */ 
+  GNUNET_DISK_HANLDE_TYPE_FILE, 
+
+  /**
+   * Handle represents a pipe.
+   */
+  GNUNET_DISK_HANLDE_TYPE_PIPE
 };
 
 /**
index 941546a5d867ad414a174d0515fb699f57955d0e..24a33d49792e55bf94fdd983b163d2dd0120bf42 100644 (file)
@@ -801,7 +801,7 @@ GNUNET_DISK_file_read (const struct GNUNET_DISK_FileHandle * h, void *result,
 #ifdef MINGW
   DWORD bytesRead;
 
-  if (h->type != GNUNET_PIPE)
+  if (h->type != GNUNET_DISK_HANLDE_TYPE_PIPE)
   {
     if (!ReadFile (h->h, result, len, &bytesRead, NULL))
     {
@@ -854,7 +854,7 @@ GNUNET_DISK_file_read_non_blocking (const struct GNUNET_DISK_FileHandle * h,
 #ifdef MINGW
   DWORD bytesRead;
 
-  if (h->type != GNUNET_PIPE)
+  if (h->type != GNUNET_DISK_HANLDE_TYPE_PIPE)
   {
     if (!ReadFile (h->h, result, len, &bytesRead, NULL))
     {
@@ -944,7 +944,7 @@ GNUNET_DISK_file_write (const struct GNUNET_DISK_FileHandle * h,
 #ifdef MINGW
   DWORD bytesWritten;
 
-  if (h->type != GNUNET_PIPE)
+  if (h->type != GNUNET_DISK_HANLDE_TYPE_PIPE)
   {
     if (!WriteFile (h->h, buffer, n, &bytesWritten, NULL))
     {
@@ -1731,7 +1731,7 @@ GNUNET_DISK_file_open (const char *fn, enum GNUNET_DISK_OpenFlags flags,
   ret = GNUNET_malloc (sizeof (struct GNUNET_DISK_FileHandle));
 #ifdef MINGW
   ret->h = h;
-  ret->type = GNUNET_DISK_FILE;
+  ret->type = GNUNET_DISK_HANLDE_TYPE_FILE;
 #else
   ret->fd = fd;
 #endif
@@ -1798,14 +1798,14 @@ GNUNET_DISK_get_handle_from_native (FILE *fd)
 
 #if MINGW
   osfh = _get_osfhandle (fno);
-  if (osfh == INVALID_HANDLE_VALUE)
+  if (INVALID_HANDLE_VALUE == (HANDLE) osfh)
     return NULL;
 #endif
 
   fh = GNUNET_malloc (sizeof (struct GNUNET_DISK_FileHandle));
 
 #if MINGW
-  fh->h = osfh;
+  fh->h = (HANDLE) osfh;
   /* Assume it to be a pipe. TODO: use some kind of detection
    * function to figure out handle type.
    * Note that we can't make it overlapped if it isn't already.
@@ -1815,7 +1815,7 @@ GNUNET_DISK_get_handle_from_native (FILE *fd)
    * otherwise we're screwed, as selecting on non-overlapped handle
    * will block.
    */
-  fh->type = GNUNET_PIPE;
+  fh->type = GNUNET_DISK_HANLDE_TYPE_PIPE;
   fh->oOverlapRead = GNUNET_malloc (sizeof (OVERLAPPED));
   fh->oOverlapWrite = GNUNET_malloc (sizeof (OVERLAPPED));
   fh->oOverlapRead->hEvent = CreateEvent (NULL, FALSE, FALSE, NULL);
@@ -2274,8 +2274,8 @@ GNUNET_DISK_pipe (int blocking_read, int blocking_write, int inherit_read, int i
   CloseHandle (p->fd[1]->h);
   p->fd[1]->h = tmp_handle;
 
-  p->fd[0]->type = GNUNET_PIPE;
-  p->fd[1]->type = GNUNET_PIPE;
+  p->fd[0]->type = GNUNET_DISK_HANLDE_TYPE_PIPE;
+  p->fd[1]->type = GNUNET_DISK_HANLDE_TYPE_PIPE;
 
   p->fd[0]->oOverlapRead = GNUNET_malloc (sizeof (OVERLAPPED));
   p->fd[0]->oOverlapWrite = GNUNET_malloc (sizeof (OVERLAPPED));
@@ -2387,7 +2387,7 @@ GNUNET_DISK_pipe_from_fd (int blocking_read, int blocking_write, int fd[2])
 
   if (p->fd[0]->h != INVALID_HANDLE_VALUE)
   {
-    p->fd[0]->type = GNUNET_PIPE;
+    p->fd[0]->type = GNUNET_DISK_HANLDE_TYPE_PIPE;
     p->fd[0]->oOverlapRead = GNUNET_malloc (sizeof (OVERLAPPED));
     p->fd[0]->oOverlapWrite = GNUNET_malloc (sizeof (OVERLAPPED));
     p->fd[0]->oOverlapRead->hEvent = CreateEvent (NULL, FALSE, FALSE, NULL);
@@ -2396,7 +2396,7 @@ GNUNET_DISK_pipe_from_fd (int blocking_read, int blocking_write, int fd[2])
 
   if (p->fd[1]->h != INVALID_HANDLE_VALUE)
   {
-    p->fd[1]->type = GNUNET_PIPE;
+    p->fd[1]->type = GNUNET_DISK_HANLDE_TYPE_PIPE;
     p->fd[1]->oOverlapRead = GNUNET_malloc (sizeof (OVERLAPPED));
     p->fd[1]->oOverlapWrite = GNUNET_malloc (sizeof (OVERLAPPED));
     p->fd[1]->oOverlapRead->hEvent = CreateEvent (NULL, FALSE, FALSE, NULL);
index 012b1af0bdfbb0066c9612fe85226b0a31bd4aa2..d6ef9c72942575990929324297c6c26b8ab5b238 100644 (file)
@@ -1409,7 +1409,7 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
 
       fh = (struct GNUNET_DISK_FileHandle *) GNUNET_CONTAINER_slist_get (&i,
                                                                          NULL);
-      if (fh->type == GNUNET_PIPE)
+      if (fh->type == GNUNET_DISK_HANLDE_TYPE_PIPE)
       {
         /* Read zero bytes to check the status of the pipe */
         LOG (GNUNET_ERROR_TYPE_DEBUG, "Reading 0 bytes from the pipe 0x%x\n",
@@ -1470,7 +1470,7 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
 
       fh = (struct GNUNET_DISK_FileHandle *) GNUNET_CONTAINER_slist_get (&i,
                                                                          NULL);
-      if (fh->type == GNUNET_PIPE)
+      if (fh->type == GNUNET_DISK_HANLDE_TYPE_PIPE)
       {
         if (!PeekNamedPipe (fh->h, NULL, 0, NULL, &dwBytes, NULL))
         {
@@ -1632,7 +1632,7 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
 
       fh = (struct GNUNET_DISK_FileHandle *) GNUNET_CONTAINER_slist_get (&t,
                                                                          NULL);
-      if (fh->type == GNUNET_PIPE)
+      if (fh->type == GNUNET_DISK_HANLDE_TYPE_PIPE)
       {
         CancelIo (fh->h);
       }
index 979511d8e33a3f63845bebbd498a995aab4dc0d8..33c84e80436373b513d20ffca4455568f8388223 100644 (file)
@@ -161,7 +161,7 @@ npipe_create (char **fn, enum GNUNET_DISK_OpenFlags flags,
   }
   ret = GNUNET_malloc (sizeof (struct GNUNET_DISK_FileHandle));
   ret->h = h;
-  ret->type = GNUNET_PIPE;
+  ret->type = GNUNET_DISK_HANLDE_TYPE_PIPE;
   ret->oOverlapRead = GNUNET_malloc (sizeof (OVERLAPPED));
   ret->oOverlapWrite = GNUNET_malloc (sizeof (OVERLAPPED));
   ret->oOverlapRead->hEvent = CreateEvent (NULL, FALSE, FALSE, NULL);
@@ -202,7 +202,7 @@ npipe_open (const char *fn, enum GNUNET_DISK_OpenFlags flags)
 
   ret = GNUNET_malloc (sizeof (struct GNUNET_DISK_FileHandle));
   ret->h = h;
-  ret->type = GNUNET_PIPE;
+  ret->type = GNUNET_DISK_HANLDE_TYPE_PIPE;
   ret->oOverlapRead = GNUNET_malloc (sizeof (OVERLAPPED));
   ret->oOverlapWrite = GNUNET_malloc (sizeof (OVERLAPPED));
   ret->oOverlapRead->hEvent = CreateEvent (NULL, FALSE, FALSE, NULL);