osl-0.1.2.
[osl.git] / util.c
diff --git a/util.c b/util.c
index 64d83c84f3292ffffa87af4f5129c891f4e3796e..572b7a52a4829489c84b1f9d94ead3dab910ae60 100644 (file)
--- a/util.c
+++ b/util.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006-2008 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 2006-2009 Andre Noll <maan@systemlinux.org>
  *
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
@@ -61,8 +61,10 @@ int write_all(int fd, const char *buf, size_t *len)
        *len = 0;
        while (*len < total) {
                int ret = __write(fd, buf + *len, total - *len);
-               if (ret < 0)
+               if (ret < 0) {
+                       ERROR_LOG("write error: %s\n", strerror(errno));
                        return ret;
+               }
                *len += ret;
        }
        return 1;
@@ -108,9 +110,11 @@ int write_file(const char *filename, const void *buf, size_t size)
        if (ret < 0)
                return ret;
        fd = ret;
-       ret = write_all(fd, buf, &size);
-       if (ret < 0)
-               goto out;
+       if (size != 0) {
+               ret = write_all(fd, buf, &size);
+               if (ret < 0)
+                       goto out;
+       }
        ret = 1;
 out:
        close(fd);