summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib/fileutl.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2014-02-06 21:46:29 +0100
committerDavid Kalnischkies <david@kalnischkies.de>2014-02-10 18:07:50 +0100
commit6008b79adf1d7ea5607fab87a355d664c8725026 (patch)
tree2150659195c28b9c03465d55392dacb830a40454 /apt-pkg/contrib/fileutl.cc
parenta7250ed08e4761dd40870ea7350ca2c83457e890 (diff)
simplify code to make compilers happy
Does the same as before, but is a bit simpler on the logic for humans as well as compilers. scan-build complained about it at least with: "Result of operation is garbage or undefined" Reported-By: scan-build
Diffstat (limited to 'apt-pkg/contrib/fileutl.cc')
-rw-r--r--apt-pkg/contrib/fileutl.cc12
1 files changed, 9 insertions, 3 deletions
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc
index 37155b688..71ac9c73f 100644
--- a/apt-pkg/contrib/fileutl.cc
+++ b/apt-pkg/contrib/fileutl.cc
@@ -1594,11 +1594,17 @@ unsigned long long FileFd::Tell()
unsigned long long FileFd::FileSize()
{
struct stat Buf;
- if ((d == NULL || d->pipe == false) && fstat(iFd,&Buf) != 0)
- return FileFdErrno("fstat","Unable to determine the file size");
+
+ bool ispipe = (d != NULL && d->pipe == true);
+ if (ispipe == false)
+ {
+ if (fstat(iFd,&Buf) != 0)
+ return FileFdErrno("fstat","Unable to determine the file size");
+ ispipe = S_ISFIFO(Buf.st_mode);
+ }
// for compressor pipes st_size is undefined and at 'best' zero
- if ((d != NULL && d->pipe == true) || S_ISFIFO(Buf.st_mode))
+ if (ispipe == true)
{
// we set it here, too, as we get the info here for free
// in theory the Open-methods should take care of it already