-dead
[oweals/gnunet.git] / src / util / disk.c
index 24a33d49792e55bf94fdd983b163d2dd0120bf42..7c346dded0f4307bb496e09a07759883088c2d0d 100644 (file)
@@ -274,9 +274,7 @@ GNUNET_DISK_file_seek (const struct GNUNET_DISK_FileHandle * h, OFF_T offset,
   LARGE_INTEGER new_pos;
   BOOL b;
 
-  static DWORD t[] = {[GNUNET_DISK_SEEK_SET] = FILE_BEGIN,
-    [GNUNET_DISK_SEEK_CUR] = FILE_CURRENT,[GNUNET_DISK_SEEK_END] = FILE_END
-  };
+  static DWORD t[] = { FILE_BEGIN, FILE_CURRENT, FILE_END };
   li.QuadPart = offset;
 
   b = SetFilePointerEx (h->h, li, &new_pos, t[whence]);
@@ -287,9 +285,7 @@ GNUNET_DISK_file_seek (const struct GNUNET_DISK_FileHandle * h, OFF_T offset,
   }
   return (OFF_T) new_pos.QuadPart;
 #else
-  static int t[] = {[GNUNET_DISK_SEEK_SET] = SEEK_SET,
-    [GNUNET_DISK_SEEK_CUR] = SEEK_CUR,[GNUNET_DISK_SEEK_END] = SEEK_END
-  };
+  static int t[] = { SEEK_SET, SEEK_CUR, SEEK_END };
 
   return lseek (h->fd, offset, t[whence]);
 #endif
@@ -843,7 +839,8 @@ GNUNET_DISK_file_read (const struct GNUNET_DISK_FileHandle * h, void *result,
  */
 ssize_t
 GNUNET_DISK_file_read_non_blocking (const struct GNUNET_DISK_FileHandle * h,
-    void *result, size_t len)
+                                   void *result, 
+                                   size_t len)
 {
   if (h == NULL)
   {
@@ -891,10 +888,14 @@ GNUNET_DISK_file_read_non_blocking (const struct GNUNET_DISK_FileHandle * h,
   /* set to non-blocking, read, then set back */
   flags = fcntl (h->fd, F_GETFL);
   if (0 == (flags & O_NONBLOCK))
-    fcntl (h->fd, F_SETFL, flags | O_NONBLOCK);
+    (void) fcntl (h->fd, F_SETFL, flags | O_NONBLOCK);
   ret = read (h->fd, result, len);
   if (0 == (flags & O_NONBLOCK))
-    fcntl (h->fd, F_SETFL, flags);
+    {
+      int eno = errno;
+      (void) fcntl (h->fd, F_SETFL, flags);
+      errno = eno;
+    }
   return ret;
 #endif
 }
@@ -1057,10 +1058,10 @@ GNUNET_DISK_file_write_blocking (const struct GNUNET_DISK_FileHandle * h,
   /* set to blocking, write, then set back */
   flags = fcntl (h->fd, F_GETFL);
   if (0 != (flags & O_NONBLOCK))
-    fcntl (h->fd, F_SETFL, flags - O_NONBLOCK);
+    (void) fcntl (h->fd, F_SETFL, flags - O_NONBLOCK);
   ret = write (h->fd, buffer, n);
   if (0 == (flags & O_NONBLOCK))
-    fcntl (h->fd, F_SETFL, flags);
+    (void) fcntl (h->fd, F_SETFL, flags);
   return ret;
 #endif
 }
@@ -1347,34 +1348,34 @@ remove_helper (void *unused, const char *fn)
  * caution.
  *
  *
- * @param fileName the file to remove
+ * @param filename the file to remove
  * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
 int
-GNUNET_DISK_directory_remove (const char *fileName)
+GNUNET_DISK_directory_remove (const char *filename)
 {
   struct stat istat;
 
-  if (0 != LSTAT (fileName, &istat))
+  if (0 != LSTAT (filename, &istat))
     return GNUNET_NO;           /* file may not exist... */
-  CHMOD (fileName, S_IWUSR | S_IRUSR | S_IXUSR);
-  if (UNLINK (fileName) == 0)
+  (void) CHMOD (filename, S_IWUSR | S_IRUSR | S_IXUSR);
+  if (UNLINK (filename) == 0)
     return GNUNET_OK;
   if ((errno != EISDIR) &&
       /* EISDIR is not sufficient in all cases, e.g.
        * sticky /tmp directory may result in EPERM on BSD.
        * So we also explicitly check "isDirectory" */
-      (GNUNET_YES != GNUNET_DISK_directory_test (fileName)))
+      (GNUNET_YES != GNUNET_DISK_directory_test (filename)))
   {
-    LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "rmdir", fileName);
+    LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "rmdir", filename);
     return GNUNET_SYSERR;
   }
   if (GNUNET_SYSERR ==
-      GNUNET_DISK_directory_scan (fileName, &remove_helper, NULL))
+      GNUNET_DISK_directory_scan (filename, &remove_helper, NULL))
     return GNUNET_SYSERR;
-  if (0 != RMDIR (fileName))
+  if (0 != RMDIR (filename))
   {
-    LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "rmdir", fileName);
+    LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "rmdir", filename);
     return GNUNET_SYSERR;
   }
   return GNUNET_OK;