From 23a9e0712d76a63c5af1caeb816943f466f0300e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Wed, 3 May 2017 17:16:46 +0700 Subject: use xfopen() in more places MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit xfopen() - provides error details - explains error on reading, or writing, or whatever operation - has l10n support - prints file name in the error Some of these are missing in the places that are replaced with xfopen(), which is a clear win. In some other places, it's just less code (not as clearly a win as the previous case but still is). The only slight regresssion is in remote-testsvn, where we don't report the file class (marks files) in the error messages anymore. But since this is a _test_ svn remote transport, I'm not too concerned. Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- remote-testsvn.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'remote-testsvn.c') diff --git a/remote-testsvn.c b/remote-testsvn.c index f87bf851ba..50404ef343 100644 --- a/remote-testsvn.c +++ b/remote-testsvn.c @@ -124,10 +124,8 @@ static int note2mark_cb(const unsigned char *object_sha1, static void regenerate_marks(void) { int ret; - FILE *marksfile = fopen(marksfilename, "w+"); + FILE *marksfile = xfopen(marksfilename, "w+"); - if (!marksfile) - die_errno("Couldn't create mark file %s.", marksfilename); ret = for_each_note(NULL, 0, note2mark_cb, marksfile); if (ret) die("Regeneration of marks failed, returned %d.", ret); @@ -148,9 +146,7 @@ static void check_or_regenerate_marks(int latestrev) marksfile = fopen(marksfilename, "r"); if (!marksfile) { regenerate_marks(); - marksfile = fopen(marksfilename, "r"); - if (!marksfile) - die_errno("cannot read marks file %s!", marksfilename); + marksfile = xfopen(marksfilename, "r"); fclose(marksfile); } else { strbuf_addf(&sb, ":%d ", latestrev); -- cgit v1.2.1