reftable/blocksource: refactor code to match our coding style

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>

Patrick Steinhardt committed Jan 11, 2024 at 11:06 UTC 85e72be15d9eed0fc9373a8f4f8bc0fcc75041b3
1 file changed +8 -9
reftable/blocksource.c
+8 -9
@@ -125,24 +125,23 @@ static struct reftable_block_source_vtable file_vtable = {
125 int reftable_block_source_from_file(struct reftable_block_source *bs,
126 const char *name)
127 {
128 - struct stat st = { 0 };
129 - int err = 0;
130 - int fd = open(name, O_RDONLY);
131 - struct file_block_source *p = NULL;
128 + struct file_block_source *p;
129 + struct stat st;
130 + int fd;
131 +
132 + fd = open(name, O_RDONLY);
133 if (fd < 0) {
133 - if (errno == ENOENT) {
134 + if (errno == ENOENT)
135 return REFTABLE_NOT_EXIST_ERROR;
135 - }
136 return -1;
137 }
138
139 - err = fstat(fd, &st);
140 - if (err < 0) {
139 + if (fstat(fd, &st) < 0) {
140 close(fd);
141 return REFTABLE_IO_ERROR;
142 }
143
145 - p = reftable_calloc(sizeof(struct file_block_source));
144 + p = reftable_calloc(sizeof(*p));
145 p->size = st.st_size;
146 p->fd = fd;
147