]> git.ipfire.org Git - thirdparty/git.git/commitdiff
reftable/blocksource: refactor code to match our coding style
authorPatrick Steinhardt <ps@pks.im>
Thu, 11 Jan 2024 10:06:52 +0000 (11:06 +0100)
committerJunio C Hamano <gitster@pobox.com>
Thu, 11 Jan 2024 20:10:59 +0000 (12:10 -0800)
Refactor `reftable_block_source_from_file()` to match our coding style
better.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
reftable/blocksource.c

index a1ea3044292ef2032485bad261ffa5ed178421bc..1e2fb5e9fdd3bd45652c528a7805aac368644c48 100644 (file)
@@ -125,24 +125,23 @@ static struct reftable_block_source_vtable file_vtable = {
 int reftable_block_source_from_file(struct reftable_block_source *bs,
                                    const char *name)
 {
-       struct stat st = { 0 };
-       int err = 0;
-       int fd = open(name, O_RDONLY);
-       struct file_block_source *p = NULL;
+       struct file_block_source *p;
+       struct stat st;
+       int fd;
+
+       fd = open(name, O_RDONLY);
        if (fd < 0) {
-               if (errno == ENOENT) {
+               if (errno == ENOENT)
                        return REFTABLE_NOT_EXIST_ERROR;
-               }
                return -1;
        }
 
-       err = fstat(fd, &st);
-       if (err < 0) {
+       if (fstat(fd, &st) < 0) {
                close(fd);
                return REFTABLE_IO_ERROR;
        }
 
-       p = reftable_calloc(sizeof(struct file_block_source));
+       p = reftable_calloc(sizeof(*p));
        p->size = st.st_size;
        p->fd = fd;