do not pretend sha1write returns errors
authorJeff King <peff@peff.net>
Sat, 21 Dec 2013 14:13:25 +0000 (09:13 -0500)
committerJunio C Hamano <gitster@pobox.com>
Thu, 26 Dec 2013 19:50:20 +0000 (11:50 -0800)
The sha1write function returns an int, but it will always be
"0". The failure-prone parts of the function happen in the
"flush" callback, which cannot pass an error back to us. So
we just end up calling die() during the flush.

Let's just drop the return value altogether, as it only
confuses callers into thinking that it might be useful.

Only one call site actually checked the return value. We can
drop that check, since it just led to a die() anyway.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/pack-objects.c
csum-file.c
csum-file.h
pack-write.c
index dfb4d84caa506cee874fd972bc0e9df1a4121362..541667f1026d7ba62be8e029c31138d5661f65c7 100644 (file)
@@ -737,8 +737,6 @@ static void write_pack_file(void)
                        f = create_tmp_packfile(&pack_tmp_name);
 
                offset = write_pack_header(f, nr_remaining);
-               if (!offset)
-                       die_errno("unable to write pack header");
                nr_written = 0;
                for (; i < nr_objects; i++) {
                        struct object_entry *e = write_order[i];
index 53f5375b6ca3368de6647cf5edcd7fb4dec79657..b30e4f28942e8fc8872f9dafa81efad5164691b8 100644 (file)
@@ -86,7 +86,7 @@ int sha1close(struct sha1file *f, unsigned char *result, unsigned int flags)
        return fd;
 }
 
-int sha1write(struct sha1file *f, void *buf, unsigned int count)
+void sha1write(struct sha1file *f, void *buf, unsigned int count)
 {
        while (count) {
                unsigned offset = f->offset;
@@ -116,7 +116,6 @@ int sha1write(struct sha1file *f, void *buf, unsigned int count)
                }
                f->offset = offset;
        }
-       return 0;
 }
 
 struct sha1file *sha1fd(int fd, const char *name)
index 3b540bdc21d2edf8d3d6fc2b5e52cc840aa19395..6a55c7d729ee0e5073df7f7dfdef2f59275bfdaf 100644 (file)
@@ -34,7 +34,7 @@ extern struct sha1file *sha1fd(int fd, const char *name);
 extern struct sha1file *sha1fd_check(const char *name);
 extern struct sha1file *sha1fd_throughput(int fd, const char *name, struct progress *tp);
 extern int sha1close(struct sha1file *, unsigned char *, unsigned int);
-extern int sha1write(struct sha1file *, void *, unsigned int);
+extern void sha1write(struct sha1file *, void *, unsigned int);
 extern void sha1flush(struct sha1file *f);
 extern void crc32_begin(struct sha1file *);
 extern uint32_t crc32_end(struct sha1file *);
index ca9e63be18f9333bf0f603ddb9ddd923588be0aa..676ed4ce9ad9f4fdfeaaaac13f91f8d0e8a95dae 100644 (file)
@@ -189,8 +189,7 @@ off_t write_pack_header(struct sha1file *f, uint32_t nr_entries)
        hdr.hdr_signature = htonl(PACK_SIGNATURE);
        hdr.hdr_version = htonl(PACK_VERSION);
        hdr.hdr_entries = htonl(nr_entries);
-       if (sha1write(f, &hdr, sizeof(hdr)))
-               return 0;
+       sha1write(f, &hdr, sizeof(hdr));
        return sizeof(hdr);
 }