From d832304e06838275446a0b787899591061f39160 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 26 Jul 2013 11:42:02 +0200 Subject: use FileFd::Write instead of fwrite for errors Using the static FileFd::Write method gives us error messages for free so we use it here to avoid failing silently (with a fail silent error). Git-Dch: Ignore --- cmdline/apt-cache.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-cache.cc b/cmdline/apt-cache.cc index 5d1ee5615..e847de875 100644 --- a/cmdline/apt-cache.cc +++ b/cmdline/apt-cache.cc @@ -1187,7 +1187,8 @@ bool DisplayRecord(pkgCacheFile &CacheFile, pkgCache::VerIterator V) DescP = Buffer + Vf->Size; // Write all but Description - if (fwrite(Buffer,1,DescP - Buffer,stdout) < (size_t)(DescP - Buffer)) + size_t const length = DescP - Buffer; + if (length != 0 && FileFd::Write(STDOUT_FILENO, Buffer, length) == false) { delete [] Buffer; return false; @@ -1223,7 +1224,7 @@ bool DisplayRecord(pkgCacheFile &CacheFile, pkgCache::VerIterator V) DescP = skipDescriptionFields(End + strlen("Description")); } size_t const length = End - Start; - if (fwrite(Start, 1, length, stdout) < length) + if (length != 0 && FileFd::Write(STDOUT_FILENO, Start, length) == false) { delete [] Buffer; return false; @@ -1232,8 +1233,8 @@ bool DisplayRecord(pkgCacheFile &CacheFile, pkgCache::VerIterator V) // write a final newline after the last field cout<