summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-04-18 13:17:30 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-04-18 13:22:50 -0400
commitd75771b0ab88ebec9b573fb1b3ef257e3b19c3ef (patch)
treef723ee71049bf8ca79dde4f5bcd957c1069e0c59
parentf08943016708f8d4f25c557f255ef81e387bc522 (diff)
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.
-rw-r--r--Utility/libdiskfree.c5
1 files changed, 3 insertions, 2 deletions
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;