wrapper.c: add and use fopen_or_warn()
When fopen() returns NULL, it could be because the given path does not exist, but it could also be some other errors and the caller has to check. Add a wrapper so we don't have to repeat the same error check everywhere. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
11dc1fcb3f
commit
e9d983f116
2
config.c
2
config.c
@ -1422,7 +1422,7 @@ int git_config_from_file(config_fn_t fn, const char *filename, void *data)
|
||||
int ret = -1;
|
||||
FILE *f;
|
||||
|
||||
f = fopen(filename, "r");
|
||||
f = fopen_or_warn(filename, "r");
|
||||
if (f) {
|
||||
flockfile(f);
|
||||
ret = do_config_from_file(fn, CONFIG_ORIGIN_FILE, filename, filename, f, data);
|
||||
|
||||
Reference in New Issue
Block a user