From 9ce3cfc9309c55cc01018c88c1ca82779fd74431 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 16 Jan 2014 22:19:49 +0100 Subject: correct some style/performance/warnings from cppcheck The most "visible" change is from utime to utimensat/futimens as the first one isn't part of POSIX anymore. Reported-By: cppcheck Git-Dch: Ignore --- apt-inst/dirstream.cc | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'apt-inst') diff --git a/apt-inst/dirstream.cc b/apt-inst/dirstream.cc index 65d1aa188..b62bdcae1 100644 --- a/apt-inst/dirstream.cc +++ b/apt-inst/dirstream.cc @@ -20,7 +20,6 @@ #include #include #include -#include #include #include /*}}}*/ @@ -93,19 +92,18 @@ bool pkgDirStream::FinishedFile(Item &Itm,int Fd) { if (Fd < 0) return true; - - if (close(Fd) != 0) - return _error->Errno("close",_("Failed to close file %s"),Itm.Name); /* Set the modification times. The only way it can fail is if someone has futzed with our file, which is intolerable :> */ - struct utimbuf Time; - Time.actime = Itm.MTime; - Time.modtime = Itm.MTime; - if (utime(Itm.Name,&Time) != 0) - _error->Errno("utime",_("Failed to close file %s"),Itm.Name); - - return true; + struct timespec times[2]; + times[0].tv_sec = times[1].tv_sec = Itm.MTime; + times[0].tv_nsec = times[1].tv_nsec = 0; + if (futimens(Fd, times) != 0) + _error->Errno("futimens", "Failed to set modification time for %s",Itm.Name); + + if (close(Fd) != 0) + return _error->Errno("close",_("Failed to close file %s"),Itm.Name); + return true; } /*}}}*/ // DirStream::Fail - Failed processing a file /*{{{*/ -- cgit v1.2.3 From 246bbb611d4cd5e2a13ecffb6cbe0e76390eae6f Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 10 Feb 2014 21:52:38 +0100 Subject: use utimes instead of utimensat/futimens cppcheck complains about the obsolete utime as it was removed in POSIX1.2008 and recommends usage of utimensat/futimens instead as those are in POSIX and so commit 9ce3cfc9 switched to them. It is just that they aren't as portable as the standard suggests: At least our kFreeBSD and Hurd ports stumble over it at runtime. So to make both, the ports and cppcheck happy, we use utimes instead. Closes: 738567 --- apt-inst/dirstream.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'apt-inst') diff --git a/apt-inst/dirstream.cc b/apt-inst/dirstream.cc index b62bdcae1..e06c30a57 100644 --- a/apt-inst/dirstream.cc +++ b/apt-inst/dirstream.cc @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -95,11 +96,11 @@ bool pkgDirStream::FinishedFile(Item &Itm,int Fd) /* Set the modification times. The only way it can fail is if someone has futzed with our file, which is intolerable :> */ - struct timespec times[2]; + struct timeval times[2]; times[0].tv_sec = times[1].tv_sec = Itm.MTime; - times[0].tv_nsec = times[1].tv_nsec = 0; - if (futimens(Fd, times) != 0) - _error->Errno("futimens", "Failed to set modification time for %s",Itm.Name); + times[0].tv_usec = times[1].tv_usec = 0; + if (utimes(Itm.Name, times) != 0) + _error->Errno("utimes", "Failed to set modification time for %s",Itm.Name); if (close(Fd) != 0) return _error->Errno("close",_("Failed to close file %s"),Itm.Name); -- cgit v1.2.3 From 1e3f4083db29bba600b9725e9456b0e140975c99 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Sat, 22 Feb 2014 18:34:33 +0100 Subject: Fix typos in documentation (codespell) --- apt-inst/contrib/arfile.cc | 2 +- apt-inst/contrib/extracttar.cc | 2 +- apt-inst/extract.cc | 4 ++-- apt-inst/filelist.cc | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) (limited to 'apt-inst') diff --git a/apt-inst/contrib/arfile.cc b/apt-inst/contrib/arfile.cc index 9d84c1784..77dbc55d6 100644 --- a/apt-inst/contrib/arfile.cc +++ b/apt-inst/contrib/arfile.cc @@ -6,7 +6,7 @@ AR File - Handle an 'AR' archive AR Archives have plain text headers at the start of each file - section. The headers are aligned on a 2 byte boundry. + section. The headers are aligned on a 2 byte boundary. Information about the structure of AR files can be found in ar(5) on a BSD system, or in the binutils source. diff --git a/apt-inst/contrib/extracttar.cc b/apt-inst/contrib/extracttar.cc index fb4db42f8..2437c9749 100644 --- a/apt-inst/contrib/extracttar.cc +++ b/apt-inst/contrib/extracttar.cc @@ -6,7 +6,7 @@ Extract a Tar - Tar Extractor Some performance measurements showed that zlib performed quite poorly - in comparision to a forked gzip process. This tar extractor makes use + in comparison to a forked gzip process. This tar extractor makes use of the fact that dup'd file descriptors have the same seek pointer and that gzip will not read past the end of a compressed stream, even if there is more data. We use the dup property to track extraction diff --git a/apt-inst/extract.cc b/apt-inst/extract.cc index 2c95fba92..b3dfccfc6 100644 --- a/apt-inst/extract.cc +++ b/apt-inst/extract.cc @@ -10,7 +10,7 @@ object is unpacked to '.dpkg.new' then the original is hardlinked to '.dpkg.tmp' and finally the new object is renamed to overwrite the old one. From an external perspective the file never ceased to exist. - After the archive has been sucessfully unpacked the .dpkg.tmp files + After the archive has been successfully unpacked the .dpkg.tmp files are erased. A failure causes all the .dpkg.tmp files to be restored. Decisions about unpacking go like this: @@ -22,7 +22,7 @@ [Note, this is reduced to only check if a file was expected to be there] - If the existing link/file is not a directory then it is replaced - irregardless + regardless - If the existing link/directory is being replaced by a directory then absolutely nothing happens. - If the existing link/directory is being replaced by a link then diff --git a/apt-inst/filelist.cc b/apt-inst/filelist.cc index 879c07855..defc4f4df 100644 --- a/apt-inst/filelist.cc +++ b/apt-inst/filelist.cc @@ -5,14 +5,14 @@ File Listing - Manages a Cache of File -> Package names. - Diversions add some signficant complexity to the system. To keep + Diversions add some significant complexity to the system. To keep storage space down in the very special case of a diverted file no extra bytes are allocated in the Node structure. Instead a diversion is inserted directly into the hash table and its flag bit set. Every lookup for that filename will always return the diversion. The hash buckets are stored in sorted form, with diversions having - the higest sort order. Identical files are assigned the same file + the highest sort order. Identical files are assigned the same file pointer, thus after a search all of the nodes owning that file can be found by iterating down the bucket. -- cgit v1.2.3 From 3255db2d02358e0026c3e6d0d8cc1519bcd48faf Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sun, 16 Feb 2014 23:29:13 +0100 Subject: ExtractTar: Allow an empty decompressor program This allows for uncompressed tar files, as the decompressor process will not get interposed in-between the file descriptors. --- apt-inst/contrib/extracttar.cc | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'apt-inst') diff --git a/apt-inst/contrib/extracttar.cc b/apt-inst/contrib/extracttar.cc index 2437c9749..41301d1a6 100644 --- a/apt-inst/contrib/extracttar.cc +++ b/apt-inst/contrib/extracttar.cc @@ -111,6 +111,12 @@ bool ExtractTar::Done(bool Force) gzip will efficiently ignore the extra bits. */ bool ExtractTar::StartGzip() { + if (DecompressProg.empty()) + { + InFd.OpenDescriptor(File.Fd(), FileFd::ReadOnly, FileFd::None, false); + return true; + } + int Pipes[2]; if (pipe(Pipes) != 0) return _error->Errno("pipe",_("Failed to create pipes")); -- cgit v1.2.3 From 50b942e9a228337a2ca20931036c7cfd8cdba90d Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Mon, 17 Feb 2014 22:02:38 +0100 Subject: DebFile: Refactor ExtractTarMember() out from ExtractArchive() Generalize DebFile::ExtractArchive() to take a member base name, so that we can reuse it for control.tar member extraction too. --- apt-inst/deb/debfile.cc | 17 ++++++++++++----- apt-inst/deb/debfile.h | 1 + 2 files changed, 13 insertions(+), 5 deletions(-) (limited to 'apt-inst') diff --git a/apt-inst/deb/debfile.cc b/apt-inst/deb/debfile.cc index 79434d8b5..15db1a7fc 100644 --- a/apt-inst/deb/debfile.cc +++ b/apt-inst/deb/debfile.cc @@ -88,21 +88,20 @@ const ARArchive::Member *debDebFile::GotoMember(const char *Name) return Member; } /*}}}*/ -// DebFile::ExtractArchive - Extract the archive data itself /*{{{*/ +// DebFile::ExtractTarMember - Extract the contents of a tar member /*{{{*/ // --------------------------------------------------------------------- /* Simple wrapper around tar.. */ -bool debDebFile::ExtractArchive(pkgDirStream &Stream) +bool debDebFile::ExtractTarMember(pkgDirStream &Stream,const char *Name) { // Get the archive member const ARArchive::Member *Member = NULL; std::string Compressor; - std::string const data = "data.tar"; std::vector compressor = APT::Configuration::getCompressors(); for (std::vector::const_iterator c = compressor.begin(); c != compressor.end(); ++c) { - Member = AR.FindMember(std::string(data).append(c->Extension).c_str()); + Member = AR.FindMember(std::string(Name).append(c->Extension).c_str()); if (Member == NULL) continue; Compressor = c->Binary; @@ -111,7 +110,7 @@ bool debDebFile::ExtractArchive(pkgDirStream &Stream) if (Member == NULL) { - std::string ext = "data.tar.{"; + std::string ext = std::string(Name) + ".{"; for (std::vector::const_iterator c = compressor.begin(); c != compressor.end(); ++c) ext.append(c->Extension.substr(1)); @@ -129,6 +128,14 @@ bool debDebFile::ExtractArchive(pkgDirStream &Stream) return Tar.Go(Stream); } /*}}}*/ +// DebFile::ExtractArchive - Extract the archive data itself /*{{{*/ +// --------------------------------------------------------------------- +/* Simple wrapper around DebFile::ExtractTarMember. */ +bool debDebFile::ExtractArchive(pkgDirStream &Stream) +{ + return ExtractTarMember(Stream, "data.tar"); +} + /*}}}*/ // DebFile::ControlExtract::DoItem - Control Tar Extraction /*{{{*/ // --------------------------------------------------------------------- diff --git a/apt-inst/deb/debfile.h b/apt-inst/deb/debfile.h index 38211fb0f..ecef71d21 100644 --- a/apt-inst/deb/debfile.h +++ b/apt-inst/deb/debfile.h @@ -48,6 +48,7 @@ class debDebFile class ControlExtract; class MemControlExtract; + bool ExtractTarMember(pkgDirStream &Stream, const char *Name); bool ExtractArchive(pkgDirStream &Stream); const ARArchive::Member *GotoMember(const char *Name); inline FileFd &GetFile() {return File;}; -- cgit v1.2.3 From e7f56293f029505f59670be2bad244f6d9912369 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sun, 16 Feb 2014 23:30:48 +0100 Subject: Add support for data.tar, control.tar and control.tar.xz Sync the deb(5) format support with latest dpkg, by allowing uncompressed tar members and xz compressed control.tar. This also refactors the control.tar member extraction by using ExtractTarMember(), which also means future changes only need to be implemented in a single place. --- apt-inst/deb/debfile.cc | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'apt-inst') diff --git a/apt-inst/deb/debfile.cc b/apt-inst/deb/debfile.cc index 15db1a7fc..a811bbe88 100644 --- a/apt-inst/deb/debfile.cc +++ b/apt-inst/deb/debfile.cc @@ -42,12 +42,15 @@ debDebFile::debDebFile(FileFd &File) : File(File), AR(File) return; } - if (!CheckMember("control.tar.gz")) { - _error->Error(_("This is not a valid DEB archive, missing '%s' member"), "control.tar.gz"); + if (!CheckMember("control.tar") && + !CheckMember("control.tar.gz") && + !CheckMember("control.tar.xz")) { + _error->Error(_("This is not a valid DEB archive, missing '%s' member"), "control.tar"); return; } - if (!CheckMember("data.tar.gz") && + if (!CheckMember("data.tar") && + !CheckMember("data.tar.gz") && !CheckMember("data.tar.bz2") && !CheckMember("data.tar.lzma") && !CheckMember("data.tar.xz")) { @@ -108,6 +111,9 @@ bool debDebFile::ExtractTarMember(pkgDirStream &Stream,const char *Name) break; } + if (Member == NULL) + Member = AR.FindMember(std::string(Name).c_str()); + if (Member == NULL) { std::string ext = std::string(Name) + ".{"; @@ -201,14 +207,7 @@ bool debDebFile::MemControlExtract::Process(Item &Itm,const unsigned char *Data, it parses it into a tag section parser. */ bool debDebFile::MemControlExtract::Read(debDebFile &Deb) { - // Get the archive member and positition the file - const ARArchive::Member *Member = Deb.GotoMember("control.tar.gz"); - if (Member == 0) - return false; - - // Extract it. - ExtractTar Tar(Deb.GetFile(),Member->Size,"gzip"); - if (Tar.Go(*this) == false) + if (Deb.ExtractTarMember(*this, "control.tar") == false) return false; if (Control == 0) -- cgit v1.2.3 From d3e8fbb395f57954acd7a2095f02ce530a05ec6a Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 27 Feb 2014 01:20:53 +0100 Subject: =?UTF-8?q?warning:=20extra=20=E2=80=98;=E2=80=99=20[-Wpedantic]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Git-Dch: Ignore Reported-By: gcc -Wpedantic --- apt-inst/filelist.h | 152 ++++++++++++++++++++++++++-------------------------- 1 file changed, 76 insertions(+), 76 deletions(-) (limited to 'apt-inst') diff --git a/apt-inst/filelist.h b/apt-inst/filelist.h index 0405d61df..8c4891bcf 100644 --- a/apt-inst/filelist.h +++ b/apt-inst/filelist.h @@ -42,25 +42,25 @@ class pkgFLCache struct Package; struct Diversion; struct ConfFile; - + class NodeIterator; class DirIterator; class PkgIterator; class DiverIterator; - + protected: std::string CacheFile; DynamicMMap ⤅ map_ptrloc LastTreeLookup; unsigned long LastLookupSize; - + // Helpers for the addition algorithms map_ptrloc TreeLookup(map_ptrloc *Base,const char *Text,const char *TextEnd, unsigned long Size,unsigned int *Count = 0, bool Insert = false); - + public: - + // Pointers to the arrays of items Header *HeaderP; Node *NodeP; @@ -70,10 +70,10 @@ class pkgFLCache ConfFile *ConfP; char *StrP; unsigned char *AnyP; - + // Quick accessors Node *FileHash; - + // Accessors Header &Head() {return *HeaderP;}; void PrintTree(map_ptrloc Base,unsigned long Size); @@ -89,7 +89,7 @@ class pkgFLCache void DropNode(map_ptrloc Node); inline DiverIterator DiverBegin(); - + // Diversion control void BeginDiverLoad(); void FinishDiverLoad(); @@ -97,7 +97,7 @@ class pkgFLCache const char *To); bool AddConfFile(const char *Name,const char *NameEnd, PkgIterator const &Owner,const unsigned char *Sum); - + pkgFLCache(DynamicMMap &Map); // ~pkgFLCache(); }; @@ -109,7 +109,7 @@ struct pkgFLCache::Header short MajorVersion; short MinorVersion; bool Dirty; - + // Size of structure values unsigned HeaderSz; unsigned NodeSz; @@ -117,7 +117,7 @@ struct pkgFLCache::Header unsigned PackageSz; unsigned DiversionSz; unsigned ConfFileSz; - + // Structure Counts; unsigned int NodeCount; unsigned int DirCount; @@ -126,13 +126,13 @@ struct pkgFLCache::Header unsigned int ConfFileCount; unsigned int HashSize; unsigned long UniqNodes; - + // Offsets map_ptrloc FileHash; map_ptrloc DirTree; map_ptrloc Packages; map_ptrloc Diversions; - + /* Allocation pools, there should be one of these for each structure excluding the header */ DynamicMMap::Pool Pools[5]; @@ -177,7 +177,7 @@ struct pkgFLCache::Diversion map_ptrloc OwnerPkg; // Package map_ptrloc DivertFrom; // Node map_ptrloc DivertTo; // String - + map_ptrloc Next; // Diversion unsigned long Flags; @@ -194,120 +194,120 @@ class pkgFLCache::PkgIterator { Package *Pkg; pkgFLCache *Owner; - + public: - + inline bool end() const {return Owner == 0 || Pkg == Owner->PkgP?true:false;} - + // Accessors - inline Package *operator ->() {return Pkg;}; - inline Package const *operator ->() const {return Pkg;}; - inline Package const &operator *() const {return *Pkg;}; - inline operator Package *() {return Pkg == Owner->PkgP?0:Pkg;}; - inline operator Package const *() const {return Pkg == Owner->PkgP?0:Pkg;}; - - inline unsigned long Offset() const {return Pkg - Owner->PkgP;}; - inline const char *Name() const {return Pkg->Name == 0?0:Owner->StrP + Pkg->Name;}; + inline Package *operator ->() {return Pkg;} + inline Package const *operator ->() const {return Pkg;} + inline Package const &operator *() const {return *Pkg;} + inline operator Package *() {return Pkg == Owner->PkgP?0:Pkg;} + inline operator Package const *() const {return Pkg == Owner->PkgP?0:Pkg;} + + inline unsigned long Offset() const {return Pkg - Owner->PkgP;} + inline const char *Name() const {return Pkg->Name == 0?0:Owner->StrP + Pkg->Name;} inline pkgFLCache::NodeIterator Files() const; - PkgIterator() : Pkg(0), Owner(0) {}; - PkgIterator(pkgFLCache &Owner,Package *Trg) : Pkg(Trg), Owner(&Owner) {}; + PkgIterator() : Pkg(0), Owner(0) {} + PkgIterator(pkgFLCache &Owner,Package *Trg) : Pkg(Trg), Owner(&Owner) {} }; class pkgFLCache::DirIterator { Directory *Dir; pkgFLCache *Owner; - + public: - + // Accessors - inline Directory *operator ->() {return Dir;}; - inline Directory const *operator ->() const {return Dir;}; - inline Directory const &operator *() const {return *Dir;}; - inline operator Directory *() {return Dir == Owner->DirP?0:Dir;}; - inline operator Directory const *() const {return Dir == Owner->DirP?0:Dir;}; + inline Directory *operator ->() {return Dir;} + inline Directory const *operator ->() const {return Dir;} + inline Directory const &operator *() const {return *Dir;} + inline operator Directory *() {return Dir == Owner->DirP?0:Dir;} + inline operator Directory const *() const {return Dir == Owner->DirP?0:Dir;} - inline const char *Name() const {return Dir->Name == 0?0:Owner->StrP + Dir->Name;}; + inline const char *Name() const {return Dir->Name == 0?0:Owner->StrP + Dir->Name;} - DirIterator() : Dir(0), Owner(0) {}; - DirIterator(pkgFLCache &Owner,Directory *Trg) : Dir(Trg), Owner(&Owner) {}; + DirIterator() : Dir(0), Owner(0) {} + DirIterator(pkgFLCache &Owner,Directory *Trg) : Dir(Trg), Owner(&Owner) {} }; class pkgFLCache::DiverIterator { Diversion *Diver; pkgFLCache *Owner; - + public: // Iteration - void operator ++(int) {if (Diver != Owner->DiverP) Diver = Owner->DiverP + Diver->Next;}; - inline void operator ++() {operator ++(0);}; - inline bool end() const {return Owner == 0 || Diver == Owner->DiverP;}; + void operator ++(int) {if (Diver != Owner->DiverP) Diver = Owner->DiverP + Diver->Next;} + inline void operator ++() {operator ++(0);} + inline bool end() const {return Owner == 0 || Diver == Owner->DiverP;} // Accessors - inline Diversion *operator ->() {return Diver;}; - inline Diversion const *operator ->() const {return Diver;}; - inline Diversion const &operator *() const {return *Diver;}; - inline operator Diversion *() {return Diver == Owner->DiverP?0:Diver;}; - inline operator Diversion const *() const {return Diver == Owner->DiverP?0:Diver;}; + inline Diversion *operator ->() {return Diver;} + inline Diversion const *operator ->() const {return Diver;} + inline Diversion const &operator *() const {return *Diver;} + inline operator Diversion *() {return Diver == Owner->DiverP?0:Diver;} + inline operator Diversion const *() const {return Diver == Owner->DiverP?0:Diver;} - inline PkgIterator OwnerPkg() const {return PkgIterator(*Owner,Owner->PkgP + Diver->OwnerPkg);}; + inline PkgIterator OwnerPkg() const {return PkgIterator(*Owner,Owner->PkgP + Diver->OwnerPkg);} inline NodeIterator DivertFrom() const; inline NodeIterator DivertTo() const; DiverIterator() : Diver(0), Owner(0) {}; - DiverIterator(pkgFLCache &Owner,Diversion *Trg) : Diver(Trg), Owner(&Owner) {}; + DiverIterator(pkgFLCache &Owner,Diversion *Trg) : Diver(Trg), Owner(&Owner) {} }; class pkgFLCache::NodeIterator { Node *Nde; - enum {NdePkg, NdeHash} Type; + enum {NdePkg, NdeHash} Type; pkgFLCache *Owner; - + public: - + // Iteration - void operator ++(int) {if (Nde != Owner->NodeP) Nde = Owner->NodeP + - (Type == NdePkg?Nde->NextPkg:Nde->Next);}; - inline void operator ++() {operator ++(0);}; - inline bool end() const {return Owner == 0 || Nde == Owner->NodeP;}; + void operator ++(int) {if (Nde != Owner->NodeP) Nde = Owner->NodeP + + (Type == NdePkg?Nde->NextPkg:Nde->Next);} + inline void operator ++() {operator ++(0);} + inline bool end() const {return Owner == 0 || Nde == Owner->NodeP;} // Accessors - inline Node *operator ->() {return Nde;}; - inline Node const *operator ->() const {return Nde;}; - inline Node const &operator *() const {return *Nde;}; - inline operator Node *() {return Nde == Owner->NodeP?0:Nde;}; - inline operator Node const *() const {return Nde == Owner->NodeP?0:Nde;}; - inline unsigned long Offset() const {return Nde - Owner->NodeP;}; - inline DirIterator Dir() const {return DirIterator(*Owner,Owner->DirP + Nde->Dir);}; - inline DiverIterator Diversion() const {return DiverIterator(*Owner,Owner->DiverP + Nde->Pointer);}; - inline const char *File() const {return Nde->File == 0?0:Owner->StrP + Nde->File;}; - inline const char *DirN() const {return Owner->StrP + Owner->DirP[Nde->Dir].Name;}; + inline Node *operator ->() {return Nde;} + inline Node const *operator ->() const {return Nde;} + inline Node const &operator *() const {return *Nde;} + inline operator Node *() {return Nde == Owner->NodeP?0:Nde;} + inline operator Node const *() const {return Nde == Owner->NodeP?0:Nde;} + inline unsigned long Offset() const {return Nde - Owner->NodeP;} + inline DirIterator Dir() const {return DirIterator(*Owner,Owner->DirP + Nde->Dir);} + inline DiverIterator Diversion() const {return DiverIterator(*Owner,Owner->DiverP + Nde->Pointer);} + inline const char *File() const {return Nde->File == 0?0:Owner->StrP + Nde->File;} + inline const char *DirN() const {return Owner->StrP + Owner->DirP[Nde->Dir].Name;} Package *RealPackage() const; - + NodeIterator() : Nde(0), Type(NdeHash), Owner(0) {}; - NodeIterator(pkgFLCache &Owner) : Nde(Owner.NodeP), Type(NdeHash), Owner(&Owner) {}; - NodeIterator(pkgFLCache &Owner,Node *Trg) : Nde(Trg), Type(NdeHash), Owner(&Owner) {}; - NodeIterator(pkgFLCache &Owner,Node *Trg,Package *) : Nde(Trg), Type(NdePkg), Owner(&Owner) {}; + NodeIterator(pkgFLCache &Owner) : Nde(Owner.NodeP), Type(NdeHash), Owner(&Owner) {} + NodeIterator(pkgFLCache &Owner,Node *Trg) : Nde(Trg), Type(NdeHash), Owner(&Owner) {} + NodeIterator(pkgFLCache &Owner,Node *Trg,Package *) : Nde(Trg), Type(NdePkg), Owner(&Owner) {} }; /* Inlines with forward references that cannot be included directly in their respsective classes */ -inline pkgFLCache::NodeIterator pkgFLCache::DiverIterator::DivertFrom() const - {return NodeIterator(*Owner,Owner->NodeP + Diver->DivertFrom);}; +inline pkgFLCache::NodeIterator pkgFLCache::DiverIterator::DivertFrom() const + {return NodeIterator(*Owner,Owner->NodeP + Diver->DivertFrom);} inline pkgFLCache::NodeIterator pkgFLCache::DiverIterator::DivertTo() const - {return NodeIterator(*Owner,Owner->NodeP + Diver->DivertTo);}; + {return NodeIterator(*Owner,Owner->NodeP + Diver->DivertTo);} inline pkgFLCache::NodeIterator pkgFLCache::PkgIterator::Files() const - {return NodeIterator(*Owner,Owner->NodeP + Pkg->Files,Pkg);}; + {return NodeIterator(*Owner,Owner->NodeP + Pkg->Files,Pkg);} inline pkgFLCache::DiverIterator pkgFLCache::DiverBegin() - {return DiverIterator(*this,DiverP + HeaderP->Diversions);}; + {return DiverIterator(*this,DiverP + HeaderP->Diversions);} -inline pkgFLCache::PkgIterator pkgFLCache::GetPkg(const char *Name,bool Insert) - {return GetPkg(Name,Name+strlen(Name),Insert);}; +inline pkgFLCache::PkgIterator pkgFLCache::GetPkg(const char *Name,bool Insert) + {return GetPkg(Name,Name+strlen(Name),Insert);} #endif -- cgit v1.2.3 From cf4ff3b78dc347188949370db914fe6329be6c99 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 27 Feb 2014 01:54:10 +0100 Subject: warning: cast from type A to type B casts away qualifiers [-Wcast-qual] Git-Dch: Ignore Reported-By: gcc -Wcast-qual --- apt-inst/contrib/extracttar.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'apt-inst') diff --git a/apt-inst/contrib/extracttar.cc b/apt-inst/contrib/extracttar.cc index 41301d1a6..41c509809 100644 --- a/apt-inst/contrib/extracttar.cc +++ b/apt-inst/contrib/extracttar.cc @@ -120,7 +120,7 @@ bool ExtractTar::StartGzip() int Pipes[2]; if (pipe(Pipes) != 0) return _error->Errno("pipe",_("Failed to create pipes")); - + // Fork off the process GZPid = ExecFork(); @@ -136,9 +136,9 @@ bool ExtractTar::StartGzip() dup2(Fd,STDERR_FILENO); close(Fd); SetCloseExec(STDOUT_FILENO,false); - SetCloseExec(STDIN_FILENO,false); + SetCloseExec(STDIN_FILENO,false); SetCloseExec(STDERR_FILENO,false); - + const char *Args[3]; string confvar = string("dir::bin::") + DecompressProg; string argv0 = _config->Find(confvar.c_str(),DecompressProg.c_str()); -- cgit v1.2.3 From 655122418d714f342b5d9789f45f8035f3fe8b9a Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 1 Mar 2014 15:11:42 +0100 Subject: =?UTF-8?q?warning:=20unused=20parameter=20=E2=80=98foo=E2=80=99?= =?UTF-8?q?=20[-Wunused-parameter]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reported-By: gcc -Wunused-parameter Git-Dch: Ignore --- apt-inst/deb/debfile.cc | 2 +- apt-inst/dirstream.cc | 2 +- apt-inst/dirstream.h | 4 ++-- apt-inst/extract.cc | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) (limited to 'apt-inst') diff --git a/apt-inst/deb/debfile.cc b/apt-inst/deb/debfile.cc index a811bbe88..8684f03f7 100644 --- a/apt-inst/deb/debfile.cc +++ b/apt-inst/deb/debfile.cc @@ -194,7 +194,7 @@ bool debDebFile::MemControlExtract::DoItem(Item &Itm,int &Fd) // --------------------------------------------------------------------- /* Just memcopy the block from the tar extractor and put it in the right place in the pre-allocated memory block. */ -bool debDebFile::MemControlExtract::Process(Item &Itm,const unsigned char *Data, +bool debDebFile::MemControlExtract::Process(Item &/*Itm*/,const unsigned char *Data, unsigned long Size,unsigned long Pos) { memcpy(Control + Pos, Data,Size); diff --git a/apt-inst/dirstream.cc b/apt-inst/dirstream.cc index e06c30a57..085a0dcbf 100644 --- a/apt-inst/dirstream.cc +++ b/apt-inst/dirstream.cc @@ -110,7 +110,7 @@ bool pkgDirStream::FinishedFile(Item &Itm,int Fd) // DirStream::Fail - Failed processing a file /*{{{*/ // --------------------------------------------------------------------- /* */ -bool pkgDirStream::Fail(Item &Itm,int Fd) +bool pkgDirStream::Fail(Item &/*Itm*/, int Fd) { if (Fd < 0) return true; diff --git a/apt-inst/dirstream.h b/apt-inst/dirstream.h index 9d1af2188..1be2688a1 100644 --- a/apt-inst/dirstream.h +++ b/apt-inst/dirstream.h @@ -49,8 +49,8 @@ class pkgDirStream virtual bool DoItem(Item &Itm,int &Fd); virtual bool Fail(Item &Itm,int Fd); virtual bool FinishedFile(Item &Itm,int Fd); - virtual bool Process(Item &Itm,const unsigned char *Data, - unsigned long Size,unsigned long Pos) {return true;}; + virtual bool Process(Item &/*Itm*/,const unsigned char * /*Data*/, + unsigned long /*Size*/,unsigned long /*Pos*/) {return true;}; virtual ~pkgDirStream() {}; }; diff --git a/apt-inst/extract.cc b/apt-inst/extract.cc index b3dfccfc6..60edc702e 100644 --- a/apt-inst/extract.cc +++ b/apt-inst/extract.cc @@ -79,7 +79,7 @@ pkgExtract::pkgExtract(pkgFLCache &FLCache,pkgCache::VerIterator Ver) : // Extract::DoItem - Handle a single item from the stream /*{{{*/ // --------------------------------------------------------------------- /* This performs the setup for the extraction.. */ -bool pkgExtract::DoItem(Item &Itm,int &Fd) +bool pkgExtract::DoItem(Item &Itm, int &/*Fd*/) { /* Strip any leading/trailing /s from the filename, then copy it to the temp buffer and re-apply the leading / We use a class variable -- cgit v1.2.3 From 453b82a388013e522b3a1b9fcd6ed0810dab1f4f Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 5 Mar 2014 22:11:25 +0100 Subject: cleanup headers and especially #includes everywhere Beside being a bit cleaner it hopefully also resolves oddball problems I have with high levels of parallel jobs. Git-Dch: Ignore Reported-By: iwyu (include-what-you-use) --- apt-inst/contrib/arfile.cc | 4 +++- apt-inst/contrib/extracttar.cc | 6 ++++-- apt-inst/deb/debfile.cc | 12 +++++++++--- apt-inst/deb/debfile.h | 6 +++++- apt-inst/dirstream.cc | 1 - apt-inst/extract.cc | 9 ++++++++- apt-inst/extract.h | 5 +++-- apt-inst/filelist.cc | 2 -- 8 files changed, 32 insertions(+), 13 deletions(-) (limited to 'apt-inst') diff --git a/apt-inst/contrib/arfile.cc b/apt-inst/contrib/arfile.cc index 77dbc55d6..905110781 100644 --- a/apt-inst/contrib/arfile.cc +++ b/apt-inst/contrib/arfile.cc @@ -21,7 +21,9 @@ #include #include -#include +#include +#include +#include #include /*}}}*/ diff --git a/apt-inst/contrib/extracttar.cc b/apt-inst/contrib/extracttar.cc index 41c509809..0ba3f0521 100644 --- a/apt-inst/contrib/extracttar.cc +++ b/apt-inst/contrib/extracttar.cc @@ -23,9 +23,11 @@ #include #include #include -#include +#include -#include +#include +#include +#include #include #include #include diff --git a/apt-inst/deb/debfile.cc b/apt-inst/deb/debfile.cc index 8684f03f7..3803329fa 100644 --- a/apt-inst/deb/debfile.cc +++ b/apt-inst/deb/debfile.cc @@ -21,11 +21,17 @@ #include #include #include -#include #include - +#include +#include +#include +#include + +#include +#include +#include #include -#include + #include /*}}}*/ diff --git a/apt-inst/deb/debfile.h b/apt-inst/deb/debfile.h index ecef71d21..880bcf6c5 100644 --- a/apt-inst/deb/debfile.h +++ b/apt-inst/deb/debfile.h @@ -27,11 +27,15 @@ #include #include #include -#include + +#include #ifndef APT_8_CLEANER_HEADERS #include #endif +#ifndef APT_10_CLEANER_HEADERS +#include +#endif class FileFd; diff --git a/apt-inst/dirstream.cc b/apt-inst/dirstream.cc index 085a0dcbf..39ebb3bb4 100644 --- a/apt-inst/dirstream.cc +++ b/apt-inst/dirstream.cc @@ -18,7 +18,6 @@ #include #include -#include #include #include #include diff --git a/apt-inst/extract.cc b/apt-inst/extract.cc index 60edc702e..b2956d91d 100644 --- a/apt-inst/extract.cc +++ b/apt-inst/extract.cc @@ -50,13 +50,20 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include #include #include -#include #include #include #include + #include /*}}}*/ using namespace std; diff --git a/apt-inst/extract.h b/apt-inst/extract.h index 7143fa409..8ad9ac629 100644 --- a/apt-inst/extract.h +++ b/apt-inst/extract.h @@ -17,11 +17,12 @@ #ifndef PKGLIB_EXTRACT_H #define PKGLIB_EXTRACT_H - - #include #include #include +#include + +#include class pkgExtract : public pkgDirStream { diff --git a/apt-inst/filelist.cc b/apt-inst/filelist.cc index defc4f4df..b4a4f3d9d 100644 --- a/apt-inst/filelist.cc +++ b/apt-inst/filelist.cc @@ -39,8 +39,6 @@ #include #include -#include -#include #include #include #include -- cgit v1.2.3 From a02db58fd50ef7fc2f0284852c6b3f98e458a232 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 6 Mar 2014 00:33:10 +0100 Subject: follow method attribute suggestions by gcc Git-Dch: Ignore Reported-By: gcc -Wsuggest-attribute={pure,const,noreturn} --- apt-inst/extract.cc | 2 +- apt-inst/filelist.cc | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'apt-inst') diff --git a/apt-inst/extract.cc b/apt-inst/extract.cc index b2956d91d..b60784450 100644 --- a/apt-inst/extract.cc +++ b/apt-inst/extract.cc @@ -260,7 +260,7 @@ bool pkgExtract::DoItem(Item &Itm, int &/*Fd*/) // Extract::Finished - Sequence finished, erase the temp files /*{{{*/ // --------------------------------------------------------------------- /* */ -bool pkgExtract::Finished() +APT_CONST bool pkgExtract::Finished() { return true; } diff --git a/apt-inst/filelist.cc b/apt-inst/filelist.cc index b4a4f3d9d..4dbc4a2d7 100644 --- a/apt-inst/filelist.cc +++ b/apt-inst/filelist.cc @@ -85,7 +85,7 @@ pkgFLCache::Header::Header() // FLCache::Header::CheckSizes - Check if the two headers have same *sz /*{{{*/ // --------------------------------------------------------------------- /* Compare to make sure we are matching versions */ -bool pkgFLCache::Header::CheckSizes(Header &Against) const +APT_PURE bool pkgFLCache::Header::CheckSizes(Header &Against) const { if (HeaderSz == Against.HeaderSz && NodeSz == Against.NodeSz && @@ -353,7 +353,7 @@ pkgFLCache::NodeIterator pkgFLCache::GetNode(const char *Name, // --------------------------------------------------------------------- /* This is one of two hashing functions. The other is inlined into the GetNode routine. */ -pkgFLCache::Node *pkgFLCache::HashNode(NodeIterator const &Nde) +APT_PURE pkgFLCache::Node *pkgFLCache::HashNode(NodeIterator const &Nde) { // Hash the node unsigned long HashPos = 0; @@ -570,7 +570,7 @@ bool pkgFLCache::AddConfFile(const char *Name,const char *NameEnd, // --------------------------------------------------------------------- /* Since the package pointer is indirected in all sorts of interesting ways this is used to get a pointer to the owning package */ -pkgFLCache::Package *pkgFLCache::NodeIterator::RealPackage() const +APT_PURE pkgFLCache::Package *pkgFLCache::NodeIterator::RealPackage() const { if (Nde->Pointer == 0) return 0; -- cgit v1.2.3 From b68ce88357daf362e60d7f8f131041289c8db690 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 17 Mar 2014 13:43:12 +0100 Subject: apt-inst: Do not try to create a substring of an empty string in error reporting One of our compressors (the empty one) has an empty extension. Calling substr on it fails. --- apt-inst/deb/debfile.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'apt-inst') diff --git a/apt-inst/deb/debfile.cc b/apt-inst/deb/debfile.cc index 3803329fa..a63cb6716 100644 --- a/apt-inst/deb/debfile.cc +++ b/apt-inst/deb/debfile.cc @@ -124,8 +124,10 @@ bool debDebFile::ExtractTarMember(pkgDirStream &Stream,const char *Name) { std::string ext = std::string(Name) + ".{"; for (std::vector::const_iterator c = compressor.begin(); - c != compressor.end(); ++c) - ext.append(c->Extension.substr(1)); + c != compressor.end(); ++c) { + if (!c->Extension.empty()) + ext.append(c->Extension.substr(1)); + } ext.append("}"); return _error->Error(_("Internal error, could not locate member %s"), ext.c_str()); } -- cgit v1.2.3