Skip to content

Commit 85e72be

Browse files
pks-tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6fdfaf1 commit 85e72be

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

reftable/blocksource.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -125,24 +125,23 @@ static struct reftable_block_source_vtable file_vtable = {
125125
int reftable_block_source_from_file(struct reftable_block_source *bs,
126126
const char *name)
127127
{
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);
132133
if (fd < 0) {
133-
if (errno == ENOENT) {
134+
if (errno == ENOENT)
134135
return REFTABLE_NOT_EXIST_ERROR;
135-
}
136136
return -1;
137137
}
138138

139-
err = fstat(fd, &st);
140-
if (err < 0) {
139+
if (fstat(fd, &st) < 0) {
141140
close(fd);
142141
return REFTABLE_IO_ERROR;
143142
}
144143

145-
p = reftable_calloc(sizeof(struct file_block_source));
144+
p = reftable_calloc(sizeof(*p));
146145
p->size = st.st_size;
147146
p->fd = fd;
148147

0 commit comments

Comments
 (0)