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.
This commit is contained in:
Joey Hess 2012-04-18 13:17:30 -04:00
parent f089430167
commit d75771b0ab

View file

@ -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;