http.c: use error_errno() and warning_errno()
[gitweb.git] / entry.c
diff --git a/entry.c b/entry.c
index 582c40071a3034af9a391cf438dd74ddb34e15ff..519e04227b72f92a338836ce457d2a5be2b80218 100644 (file)
--- a/entry.c
+++ b/entry.c
@@ -6,7 +6,7 @@
 static void create_directories(const char *path, int path_len,
                               const struct checkout *state)
 {
-       char *buf = xmalloc(path_len + 1);
+       char *buf = xmallocz(path_len);
        int len = 0;
 
        while (len < path_len) {
@@ -168,8 +168,8 @@ static int write_entry(struct cache_entry *ce,
                        ret = symlink(new, path);
                        free(new);
                        if (ret)
-                               return error("unable to create symlink %s (%s)",
-                                            path, strerror(errno));
+                               return error_errno("unable to create symlink %s",
+                                                  path);
                        break;
                }
 
@@ -186,8 +186,7 @@ static int write_entry(struct cache_entry *ce,
                fd = open_output_fd(path, ce, to_tempfile);
                if (fd < 0) {
                        free(new);
-                       return error("unable to create file %s (%s)",
-                               path, strerror(errno));
+                       return error_errno("unable to create file %s", path);
                }
 
                wrote = write_in_full(fd, new, size);
@@ -284,8 +283,7 @@ int checkout_entry(struct cache_entry *ce,
                                return error("%s is a directory", path.buf);
                        remove_subtree(&path);
                } else if (unlink(path.buf))
-                       return error("unable to unlink old '%s' (%s)",
-                                    path.buf, strerror(errno));
+                       return error_errno("unable to unlink old '%s'", path.buf);
        } else if (state->not_new)
                return 0;