summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2013-07-26 11:42:02 +0200
committerDavid Kalnischkies <kalnischkies@gmail.com>2013-07-26 11:42:02 +0200
commitd832304e06838275446a0b787899591061f39160 (patch)
treebbe470ea5b01ab5042108be48ad932c1c77ad00b
parent8b620f4b490a973bfaeaf4de30b72a270a2ef9f2 (diff)
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
-rw-r--r--cmdline/apt-cache.cc7
1 files changed, 4 insertions, 3 deletions
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<<endl;
- delete [] Buffer;
+ delete [] Buffer;
return true;
}
/*}}}*/