sha1_name: implement @{push} shorthand
[gitweb.git] / csum-file.c
index 465971c7f303e29bf9501e6968da1ea71b5af76a..a172199e44bf370cd66ee7073f5a2228fd9679ef 100644 (file)
@@ -86,7 +86,7 @@ int sha1close(struct sha1file *f, unsigned char *result, unsigned int flags)
        return fd;
 }
 
-int sha1write(struct sha1file *f, const void *buf, unsigned int count)
+void sha1write(struct sha1file *f, const void *buf, unsigned int count)
 {
        while (count) {
                unsigned offset = f->offset;
@@ -116,7 +116,6 @@ int sha1write(struct sha1file *f, const void *buf, unsigned int count)
                }
                f->offset = offset;
        }
-       return 0;
 }
 
 struct sha1file *sha1fd(int fd, const char *name)
@@ -131,14 +130,10 @@ struct sha1file *sha1fd_check(const char *name)
 
        sink = open("/dev/null", O_WRONLY);
        if (sink < 0)
-               return NULL;
+               die_errno("unable to open /dev/null");
        check = open(name, O_RDONLY);
-       if (check < 0) {
-               int saved_errno = errno;
-               close(sink);
-               errno = saved_errno;
-               return NULL;
-       }
+       if (check < 0)
+               die_errno("unable to open '%s'", name);
        f = sha1fd(sink, name);
        f->check_fd = check;
        return f;