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>
This commit is contained in:

committed by
Junio C Hamano

parent
6fdfaf15a0
commit
85e72be15d
@ -125,24 +125,23 @@ static struct reftable_block_source_vtable file_vtable = {
|
|||||||
int reftable_block_source_from_file(struct reftable_block_source *bs,
|
int reftable_block_source_from_file(struct reftable_block_source *bs,
|
||||||
const char *name)
|
const char *name)
|
||||||
{
|
{
|
||||||
struct stat st = { 0 };
|
struct file_block_source *p;
|
||||||
int err = 0;
|
struct stat st;
|
||||||
int fd = open(name, O_RDONLY);
|
int fd;
|
||||||
struct file_block_source *p = NULL;
|
|
||||||
|
fd = open(name, O_RDONLY);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
if (errno == ENOENT) {
|
if (errno == ENOENT)
|
||||||
return REFTABLE_NOT_EXIST_ERROR;
|
return REFTABLE_NOT_EXIST_ERROR;
|
||||||
}
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = fstat(fd, &st);
|
if (fstat(fd, &st) < 0) {
|
||||||
if (err < 0) {
|
|
||||||
close(fd);
|
close(fd);
|
||||||
return REFTABLE_IO_ERROR;
|
return REFTABLE_IO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
p = reftable_calloc(sizeof(struct file_block_source));
|
p = reftable_calloc(sizeof(*p));
|
||||||
p->size = st.st_size;
|
p->size = st.st_size;
|
||||||
p->fd = fd;
|
p->fd = fd;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user