From d75771b0ab88ebec9b573fb1b3ef257e3b19c3ef Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 18 Apr 2012 13:17:30 -0400 Subject: clear errno after successful call When preparing the debian stable backport, I am seeing a call to statvfs() succeed, but also set errno to 2 (ENOENT). Not sure why this happens; I am in a schroot when it does happen, or perhaps stable's libc is a little broken and sets errno incorrectly. Anyway, it should be perfectly fine to clear errno after the successful call, rather than before it. --- Utility/libdiskfree.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'Utility/libdiskfree.c') diff --git a/Utility/libdiskfree.c b/Utility/libdiskfree.c index b68abd0c4..54e8c0894 100644 --- a/Utility/libdiskfree.c +++ b/Utility/libdiskfree.c @@ -58,9 +58,10 @@ unsigned long long int diskfree(const char *path) { unsigned long long int available, blocksize; struct STATSTRUCT buf; - errno = 0; - if (STATCALL(path, &buf) != 0) + if (STATCALL(path, &buf) != 0) { return 0; /* errno is set */ + } + errno = 0; available = buf.f_bavail; blocksize = buf.f_bsize; -- cgit v1.2.3