preserve errno
authorChristian Grothoff <christian@grothoff.org>
Sun, 15 Mar 2015 17:30:28 +0000 (17:30 +0000)
committerChristian Grothoff <christian@grothoff.org>
Sun, 15 Mar 2015 17:30:28 +0000 (17:30 +0000)
src/util/disk.c

index b0a8ad7b0bd22b8f0ee081763a9502bce5252352..da78a1e1d5444560e0cb33bfadc31e36fc80ab51 100644 (file)
@@ -868,7 +868,9 @@ GNUNET_DISK_file_read (const struct GNUNET_DISK_FileHandle *h,
     {
       if (GetLastError () != ERROR_IO_PENDING)
       {
-        LOG (GNUNET_ERROR_TYPE_DEBUG, "Error reading from pipe: %u\n", GetLastError ());
+        LOG (GNUNET_ERROR_TYPE_DEBUG,
+             "Error reading from pipe: %u\n",
+             GetLastError ());
         SetErrnoFromWinError (GetLastError ());
         return GNUNET_SYSERR;
       }
@@ -983,6 +985,7 @@ GNUNET_DISK_fn_read (const char *fn,
 {
   struct GNUNET_DISK_FileHandle *fh;
   ssize_t ret;
+  int eno;
 
   fh = GNUNET_DISK_file_open (fn,
                               GNUNET_DISK_OPEN_READ,
@@ -990,8 +993,9 @@ GNUNET_DISK_fn_read (const char *fn,
   if (NULL == fh)
     return GNUNET_SYSERR;
   ret = GNUNET_DISK_file_read (fh, result, len);
+  eno = errno;
   GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fh));
-
+  errno = eno;
   return ret;
 }