Browse Source

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
tags/debian/0.9.15.1
David Kalnischkies 7 years ago
parent
commit
9ce3cfc930
22 changed files with 133 additions and 142 deletions
  1. +9
    -11
      apt-inst/dirstream.cc
  2. +1
    -1
      apt-pkg/contrib/fileutl.cc
  3. +2
    -3
      apt-pkg/contrib/gpgv.cc
  4. +2
    -3
      apt-pkg/contrib/hashes.cc
  5. +3
    -4
      apt-pkg/contrib/hashsum.cc
  6. +3
    -6
      apt-pkg/deb/dpkgpm.cc
  7. +1
    -1
      apt-pkg/install-progress.cc
  8. +6
    -6
      apt-private/private-list.cc
  9. +4
    -4
      apt-private/private-search.cc
  10. +4
    -6
      ftparchive/multicompress.cc
  11. +3
    -3
      methods/connect.cc
  12. +9
    -9
      methods/copy.cc
  13. +26
    -23
      methods/ftp.cc
  14. +14
    -12
      methods/gzip.cc
  15. +1
    -3
      methods/http.cc
  16. +5
    -5
      methods/https.cc
  17. +1
    -1
      methods/https.h
  18. +4
    -4
      methods/mirror.cc
  19. +18
    -18
      methods/rsh.cc
  20. +12
    -13
      methods/server.cc
  21. +1
    -1
      methods/server.h
  22. +4
    -5
      test/interactive-helper/rpmver.cc

+ 9
- 11
apt-inst/dirstream.cc View File

@@ -20,7 +20,6 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <errno.h>
#include <utime.h>
#include <unistd.h>
#include <apti18n.h>
/*}}}*/
@@ -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 /*{{{*/


+ 1
- 1
apt-pkg/contrib/fileutl.cc View File

@@ -319,7 +319,7 @@ bool CreateDirectory(string const &Parent, string const &Path)
return false;

// we are not going to create directories "into the blue"
if (Path.find(Parent, 0) != 0)
if (Path.compare(0, Parent.length(), Parent) != 0)
return false;

vector<string> const dirs = VectorizeString(Path.substr(Parent.size()), '/');


+ 2
- 3
apt-pkg/contrib/gpgv.cc View File

@@ -260,8 +260,7 @@ bool SplitClearSignedFile(std::string const &InFile, FileFd * const ContentFile,

char *buf = NULL;
size_t buf_size = 0;
ssize_t line_len = 0;
while ((line_len = getline(&buf, &buf_size, in)) != -1)
while (getline(&buf, &buf_size, in) != -1)
{
_strrstrip(buf);
if (found_message_start == false)
@@ -355,7 +354,7 @@ bool OpenMaybeClearSignedFile(std::string const &ClearSignedFileName, FileFd &Me
return _error->Error("Couldn't open temporary file to work with %s", ClearSignedFileName.c_str());

_error->PushToStack();
bool const splitDone = SplitClearSignedFile(ClearSignedFileName.c_str(), &MessageFile, NULL, NULL);
bool const splitDone = SplitClearSignedFile(ClearSignedFileName, &MessageFile, NULL, NULL);
bool const errorDone = _error->PendingError();
_error->MergeWithStack();
if (splitDone == false)


+ 2
- 3
apt-pkg/contrib/hashes.cc View File

@@ -129,13 +129,12 @@ bool Hashes::AddFD(int const Fd,unsigned long long Size, bool const addMD5,
bool const addSHA1, bool const addSHA256, bool const addSHA512)
{
unsigned char Buf[64*64];
ssize_t Res = 0;
int ToEOF = (Size == 0);
bool const ToEOF = (Size == 0);
while (Size != 0 || ToEOF)
{
unsigned long long n = sizeof(Buf);
if (!ToEOF) n = std::min(Size, n);
Res = read(Fd,Buf,n);
ssize_t const Res = read(Fd,Buf,n);
if (Res < 0 || (!ToEOF && Res != (ssize_t) n)) // error, or short read
return false;
if (ToEOF && Res == 0) // EOF


+ 3
- 4
apt-pkg/contrib/hashsum.cc View File

@@ -9,13 +9,12 @@
/* */
bool SummationImplementation::AddFD(int const Fd, unsigned long long Size) {
unsigned char Buf[64 * 64];
ssize_t Res = 0;
int ToEOF = (Size == 0);
bool const ToEOF = (Size == 0);
while (Size != 0 || ToEOF)
{
unsigned long long n = sizeof(Buf);
if (!ToEOF) n = std::min(Size, n);
Res = read(Fd, Buf, n);
ssize_t const Res = read(Fd, Buf, n);
if (Res < 0 || (!ToEOF && Res != (ssize_t) n)) // error, or short read
return false;
if (ToEOF && Res == 0) // EOF
@@ -27,7 +26,7 @@ bool SummationImplementation::AddFD(int const Fd, unsigned long long Size) {
}
bool SummationImplementation::AddFD(FileFd &Fd, unsigned long long Size) {
unsigned char Buf[64 * 64];
bool ToEOF = (Size == 0);
bool const ToEOF = (Size == 0);
while (Size != 0 || ToEOF)
{
unsigned long long n = sizeof(Buf);


+ 3
- 6
apt-pkg/deb/dpkgpm.cc View File

@@ -568,7 +568,6 @@ void pkgDPkgPM::ProcessDpkgStatusLine(char *line)
std::string prefix = APT::String::Strip(list[0]);
std::string pkgname;
std::string action;
ostringstream status;

// "processing" has the form "processing: action: pkg or trigger"
// with action = ["install", "configure", "remove", "purge", "disappear",
@@ -1652,7 +1651,7 @@ void pkgDPkgPM::WriteApportReport(const char *pkgpath, const char *errormsg)
io_errors.push_back(string("failed in write on buffer copy for %s"));
io_errors.push_back(string("short read on buffer copy for %s"));

for (vector<string>::iterator I = io_errors.begin(); I != io_errors.end(); I++)
for (vector<string>::iterator I = io_errors.begin(); I != io_errors.end(); ++I)
{
vector<string> list = VectorizeString(dgettext("dpkg", (*I).c_str()), '%');
if (list.size() > 1) {
@@ -1767,13 +1766,11 @@ void pkgDPkgPM::WriteApportReport(const char *pkgpath, const char *errormsg)
string histfile_name = _config->FindFile("Dir::Log::History");
if (!histfile_name.empty())
{
FILE *log = NULL;
char buf[1024];

fprintf(report, "DpkgHistoryLog:\n");
log = fopen(histfile_name.c_str(),"r");
FILE* log = fopen(histfile_name.c_str(),"r");
if(log != NULL)
{
char buf[1024];
while( fgets(buf, sizeof(buf), log) != NULL)
fprintf(report, " %s", buf);
fclose(log);


+ 1
- 1
apt-pkg/install-progress.cc View File

@@ -242,7 +242,7 @@ PackageManagerFancy::~PackageManagerFancy()
void PackageManagerFancy::staticSIGWINCH(int signum)
{
std::vector<PackageManagerFancy *>::const_iterator I;
for(I = instances.begin(); I != instances.end(); I++)
for(I = instances.begin(); I != instances.end(); ++I)
(*I)->HandleSIGWINCH(signum);
}



+ 6
- 6
apt-private/private-list.cc View File

@@ -61,7 +61,7 @@ class PackageNameMatcher : public Matcher /*{{{*/
public:
PackageNameMatcher(const char **patterns)
{
for(int i=0; patterns[i] != NULL; i++)
for(int i=0; patterns[i] != NULL; ++i)
{
std::string pattern = patterns[i];
#ifdef PACKAGE_MATCHER_ABI_COMPAT
@@ -79,12 +79,12 @@ class PackageNameMatcher : public Matcher /*{{{*/
}
virtual ~PackageNameMatcher()
{
for(J=filters.begin(); J != filters.end(); J++)
for(J=filters.begin(); J != filters.end(); ++J)
delete *J;
}
virtual bool operator () (const pkgCache::PkgIterator &P)
{
for(J=filters.begin(); J != filters.end(); J++)
for(J=filters.begin(); J != filters.end(); ++J)
{
APT::CacheFilter::PackageMatcher *cachefilter = *J;
if((*cachefilter)(P))
@@ -104,7 +104,7 @@ void ListAllVersions(pkgCacheFile &CacheFile, pkgRecords &records, /*{{{*/
std::ostream &outs)
{
for (pkgCache::VerIterator Ver = P.VersionList();
Ver.end() == false; Ver++)
Ver.end() == false; ++Ver)
ListSingleVersion(CacheFile, records, Ver, outs);
}
/*}}}*/
@@ -142,7 +142,7 @@ bool List(CommandLine &Cmd)
Cache->Head().PackageCount,
_("Listing"));
GetLocalitySortedVersionSet(CacheFile, bag, matcher, progress);
for (LocalitySortedVersionSet::iterator V = bag.begin(); V != bag.end(); V++)
for (LocalitySortedVersionSet::iterator V = bag.begin(); V != bag.end(); ++V)
{
std::stringstream outs;
if(_config->FindB("APT::Cmd::All-Versions", false) == true)
@@ -159,7 +159,7 @@ bool List(CommandLine &Cmd)

// FIXME: SORT! and make sorting flexible (alphabetic, by pkg status)
// output the sorted map
for (K = output_map.begin(); K != output_map.end(); K++)
for (K = output_map.begin(); K != output_map.end(); ++K)
std::cout << (*K).second << std::endl;




+ 4
- 4
apt-private/private-search.cc View File

@@ -61,18 +61,18 @@ bool FullTextSearch(CommandLine &CmdL) /*{{{*/
progress.OverallProgress(50, 100, 50, _("Full Text Search"));
progress.SubProgress(bag.size());
int Done = 0;
for ( ;V != bag.end(); V++)
for ( ;V != bag.end(); ++V)
{
if (Done%500 == 0)
progress.Progress(Done);
Done++;
++Done;
int i;
pkgCache::DescIterator Desc = V.TranslatedDescription();
pkgRecords::Parser &parser = records.Lookup(Desc.FileList());
bool all_found = true;
for(i=0; patterns[i] != NULL; i++)
for(i=0; patterns[i] != NULL; ++i)
{
// FIXME: use regexp instead of simple find()
const char *pattern = patterns[i];
@@ -93,7 +93,7 @@ bool FullTextSearch(CommandLine &CmdL) /*{{{*/

// FIXME: SORT! and make sorting flexible (alphabetic, by pkg status)
// output the sorted map
for (K = output_map.begin(); K != output_map.end(); K++)
for (K = output_map.begin(); K != output_map.end(); ++K)
std::cout << (*K).second << std::endl;

return true;


+ 4
- 6
ftparchive/multicompress.cc View File

@@ -21,9 +21,9 @@
#include <apt-pkg/error.h>
#include <apt-pkg/md5.h>

#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <utime.h>
#include <unistd.h>
#include <iostream>

@@ -234,14 +234,12 @@ bool MultiCompress::Finalize(unsigned long long &OutSize)
else
{
// Update the mtime if necessary
if (UpdateMTime > 0 &&
if (UpdateMTime > 0 &&
(Now - St.st_mtime > (signed)UpdateMTime || St.st_mtime > Now))
{
struct utimbuf Buf;
Buf.actime = Buf.modtime = Now;
utime(I->Output.c_str(),&Buf);
utimensat(AT_FDCWD, I->Output.c_str(), NULL, AT_SYMLINK_NOFOLLOW);
Changed = true;
}
}
}
// Force the file permissions


+ 3
- 3
methods/connect.cc View File

@@ -142,9 +142,9 @@ bool Connect(std::string Host,int Port,const char *Service,int DefPort,int &Fd,
// Convert the port name/number
char ServStr[300];
if (Port != 0)
snprintf(ServStr,sizeof(ServStr),"%u",Port);
snprintf(ServStr,sizeof(ServStr),"%i", Port);
else
snprintf(ServStr,sizeof(ServStr),"%s",Service);
snprintf(ServStr,sizeof(ServStr),"%s", Service);
/* We used a cached address record.. Yes this is against the spec but
the way we have setup our rotating dns suggests that this is more
@@ -190,7 +190,7 @@ bool Connect(std::string Host,int Port,const char *Service,int DefPort,int &Fd,
{
if (DefPort != 0)
{
snprintf(ServStr,sizeof(ServStr),"%u",DefPort);
snprintf(ServStr, sizeof(ServStr), "%i", DefPort);
DefPort = 0;
continue;
}


+ 9
- 9
methods/copy.cc View File

@@ -18,7 +18,6 @@
#include <apt-pkg/hashes.h>

#include <sys/stat.h>
#include <utime.h>
#include <unistd.h>
#include <apti18n.h>
/*}}}*/
@@ -71,18 +70,19 @@ bool CopyMethod::Fetch(FetchItem *Itm)
}

From.Close();
To.Close();

// Transfer the modification times
struct utimbuf TimeBuf;
TimeBuf.actime = Buf.st_atime;
TimeBuf.modtime = Buf.st_mtime;
if (utime(Itm->DestFile.c_str(),&TimeBuf) != 0)
struct timespec times[2];
times[0].tv_sec = Buf.st_atime;
times[1].tv_sec = Buf.st_mtime;
times[0].tv_nsec = times[1].tv_nsec = 0;
if (futimens(To.Fd(), times) != 0)
{
To.OpFail();
return _error->Errno("utime",_("Failed to set modification time"));
return _error->Errno("futimens",_("Failed to set modification time"));
}
To.Close();

Hashes Hash;
FileFd Fd(Res.Filename, FileFd::ReadOnly);
Hash.AddFD(Fd);


+ 26
- 23
methods/ftp.cc View File

@@ -26,7 +26,6 @@

#include <sys/stat.h>
#include <sys/time.h>
#include <utime.h>
#include <unistd.h>
#include <signal.h>
#include <stdio.h>
@@ -953,14 +952,16 @@ void FtpMethod::SigTerm(int)
{
if (FailFd == -1)
_exit(100);
close(FailFd);

// Timestamp
struct utimbuf UBuf;
UBuf.actime = FailTime;
UBuf.modtime = FailTime;
utime(FailFile.c_str(),&UBuf);
struct timespec times[2];
times[0].tv_sec = FailTime;
times[1].tv_sec = FailTime;
times[0].tv_nsec = times[1].tv_nsec = 0;
futimens(FailFd, times);

close(FailFd);

_exit(100);
}
/*}}}*/
@@ -1059,13 +1060,14 @@ bool FtpMethod::Fetch(FetchItem *Itm)
if (Server->Get(File,Fd,Res.ResumePoint,Hash,Missing) == false)
{
Fd.Close();
// Timestamp
struct utimbuf UBuf;
UBuf.actime = FailTime;
UBuf.modtime = FailTime;
utime(FailFile.c_str(),&UBuf);
struct timespec times[2];
times[0].tv_sec = FailTime;
times[1].tv_sec = FailTime;
times[0].tv_nsec = times[1].tv_nsec = 0;
futimens(FailFd, times);

// If the file is missing we hard fail and delete the destfile
// otherwise transient fail
if (Missing == true) {
@@ -1077,20 +1079,21 @@ bool FtpMethod::Fetch(FetchItem *Itm)
}

Res.Size = Fd.Size();

// Timestamp
struct timespec times[2];
times[0].tv_sec = FailTime;
times[1].tv_sec = FailTime;
times[0].tv_nsec = times[1].tv_nsec = 0;
futimens(Fd.Fd(), times);
FailFd = -1;
}
Res.LastModified = FailTime;
Res.TakeHashes(Hash);
// Timestamp
struct utimbuf UBuf;
UBuf.actime = FailTime;
UBuf.modtime = FailTime;
utime(Queue->DestFile.c_str(),&UBuf);
FailFd = -1;

URIDone(Res);

return true;
}
/*}}}*/


+ 14
- 12
methods/gzip.cc View File

@@ -19,7 +19,6 @@

#include <sys/stat.h>
#include <unistd.h>
#include <utime.h>
#include <stdio.h>
#include <errno.h>
#include <apti18n.h>
@@ -94,32 +93,35 @@ bool GzipMethod::Fetch(FetchItem *Itm)
}
From.Close();
To.Close();

if (Failed == true)
return false;
// Transfer the modification times
struct stat Buf;
if (stat(Path.c_str(),&Buf) != 0)
return _error->Errno("stat",_("Failed to stat"));

struct utimbuf TimeBuf;
TimeBuf.actime = Buf.st_atime;
TimeBuf.modtime = Buf.st_mtime;
if (utime(Itm->DestFile.c_str(),&TimeBuf) != 0)
return _error->Errno("utime",_("Failed to set modification time"));
struct timespec times[2];
times[0].tv_sec = Buf.st_atime;
times[1].tv_sec = Buf.st_mtime;
times[0].tv_nsec = times[1].tv_nsec = 0;
if (futimens(To.Fd(), times) != 0)
{
To.OpFail();
return _error->Errno("futimens",_("Failed to set modification time"));
}
Res.Size = To.FileSize();
To.Close();

if (stat(Itm->DestFile.c_str(),&Buf) != 0)
return _error->Errno("stat",_("Failed to stat"));
// Return a Done response
Res.LastModified = Buf.st_mtime;
Res.Size = Buf.st_size;
Res.TakeHashes(Hash);

URIDone(Res);
return true;
}
/*}}}*/


+ 1
- 3
methods/http.cc View File

@@ -97,8 +97,6 @@ void CircleBuf::Reset()
is non-blocking.. */
bool CircleBuf::Read(int Fd)
{
unsigned long long BwReadMax;

while (1)
{
// Woops, buffer is full
@@ -106,7 +104,7 @@ bool CircleBuf::Read(int Fd)
return true;

// what's left to read in this tick
BwReadMax = CircleBuf::BwReadLimit/BW_HZ;
unsigned long long const BwReadMax = CircleBuf::BwReadLimit/BW_HZ;

if(CircleBuf::BwReadLimit) {
struct timeval now;


+ 5
- 5
methods/https.cc View File

@@ -21,7 +21,6 @@

#include <sys/stat.h>
#include <sys/time.h>
#include <utime.h>
#include <unistd.h>
#include <signal.h>
#include <stdio.h>
@@ -405,10 +404,11 @@ bool HttpsMethod::Fetch(FetchItem *Itm)
curl_easy_getinfo(curl, CURLINFO_FILETIME, &Res.LastModified);
if (Res.LastModified != -1)
{
struct utimbuf UBuf;
UBuf.actime = Res.LastModified;
UBuf.modtime = Res.LastModified;
utime(File->Name().c_str(),&UBuf);
struct timespec times[2];
times[0].tv_sec = Res.LastModified;
times[1].tv_sec = Res.LastModified;
times[0].tv_nsec = times[1].tv_nsec = 0;
futimens(File->Fd(), times);
}
else
Res.LastModified = resultStat.st_mtime;


+ 1
- 1
methods/https.h View File

@@ -65,7 +65,7 @@ class HttpsMethod : public pkgAcqMethod
public:
FileFd *File;
HttpsMethod() : pkgAcqMethod("1.2",Pipeline | SendConfig)
HttpsMethod() : pkgAcqMethod("1.2",Pipeline | SendConfig), File(NULL)
{
File = 0;
curl = curl_easy_init();


+ 4
- 4
methods/mirror.cc View File

@@ -114,7 +114,7 @@ bool MirrorMethod::Clean(string Dir)
for(I=list.begin(); I != list.end(); ++I)
{
string uri = (*I)->GetURI();
if(uri.find("mirror://") != 0)
if(uri.compare(0, strlen("mirror://"), "mirror://") != 0)
continue;
string BaseUri = uri.substr(0,uri.size()-1);
if (URItoFileName(BaseUri) == Dir->d_name)
@@ -198,9 +198,9 @@ bool MirrorMethod::RandomizeMirrorFile(string mirror_file)
// "stable" on the same machine. this is to avoid running into out-of-sync
// issues (i.e. Release/Release.gpg different on each mirror)
struct utsname buf;
int seed=1, i;
int seed=1;
if(uname(&buf) == 0) {
for(i=0,seed=1; buf.nodename[i] != 0; i++) {
for(int i=0,seed=1; buf.nodename[i] != 0; ++i) {
seed = seed * 31 + buf.nodename[i];
}
}
@@ -306,7 +306,7 @@ bool MirrorMethod::InitMirrors()
if (s.size() == 0)
continue;
// ignore non http lines
if (s.find("http://") != 0)
if (s.compare(0, strlen("http://"), "http://") != 0)
continue;

AllMirrors.push_back(s);


+ 18
- 18
methods/rsh.cc View File

@@ -20,7 +20,6 @@

#include <sys/stat.h>
#include <sys/time.h>
#include <utime.h>
#include <unistd.h>
#include <signal.h>
#include <stdio.h>
@@ -395,13 +394,14 @@ void RSHMethod::SigTerm(int sig)
{
if (FailFd == -1)
_exit(100);
close(FailFd);

// Timestamp
struct utimbuf UBuf;
UBuf.actime = FailTime;
UBuf.modtime = FailTime;
utime(FailFile.c_str(),&UBuf);
// Transfer the modification times
struct timespec times[2];
times[0].tv_sec = FailTime;
times[1].tv_sec = FailTime;
times[0].tv_nsec = times[1].tv_nsec = 0;
futimens(FailFd, times);
close(FailFd);

_exit(100);
}
@@ -488,10 +488,11 @@ bool RSHMethod::Fetch(FetchItem *Itm)
Fd.Close();

// Timestamp
struct utimbuf UBuf;
UBuf.actime = FailTime;
UBuf.modtime = FailTime;
utime(FailFile.c_str(),&UBuf);
struct timespec times[2];
times[0].tv_sec = FailTime;
times[1].tv_sec = FailTime;
times[0].tv_nsec = times[1].tv_nsec = 0;
futimens(FailFd, times);

// If the file is missing we hard fail otherwise transient fail
if (Missing == true)
@@ -501,18 +502,17 @@ bool RSHMethod::Fetch(FetchItem *Itm)
}

Res.Size = Fd.Size();
struct timespec times[2];
times[0].tv_sec = FailTime;
times[1].tv_sec = FailTime;
times[0].tv_nsec = times[1].tv_nsec = 0;
futimens(Fd.Fd(), times);
FailFd = -1;
}

Res.LastModified = FailTime;
Res.TakeHashes(Hash);

// Timestamp
struct utimbuf UBuf;
UBuf.actime = FailTime;
UBuf.modtime = FailTime;
utime(Queue->DestFile.c_str(),&UBuf);
FailFd = -1;

URIDone(Res);

return true;


+ 12
- 13
methods/server.cc View File

@@ -17,9 +17,9 @@
#include <apt-pkg/hashes.h>
#include <apt-pkg/netrc.h>

#include <fcntl.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <utime.h>
#include <unistd.h>
#include <signal.h>
#include <stdio.h>
@@ -368,14 +368,14 @@ void ServerMethod::SigTerm(int)
{
if (FailFd == -1)
_exit(100);

struct timespec times[2];
times[0].tv_sec = FailTime;
times[1].tv_sec = FailTime;
times[0].tv_nsec = times[1].tv_nsec = 0;
futimens(FailFd, times);
close(FailFd);
// Timestamp
struct utimbuf UBuf;
UBuf.actime = FailTime;
UBuf.modtime = FailTime;
utime(FailFile.c_str(),&UBuf);

_exit(100);
}
/*}}}*/
@@ -539,11 +539,10 @@ int ServerMethod::Loop()
File = 0;
// Timestamp
struct utimbuf UBuf;
time(&UBuf.actime);
UBuf.actime = Server->Date;
UBuf.modtime = Server->Date;
utime(Queue->DestFile.c_str(),&UBuf);
struct timespec times[2];
times[0].tv_sec = times[1].tv_sec = Server->Date;
times[0].tv_nsec = times[1].tv_nsec = 0;
utimensat(AT_FDCWD, Queue->DestFile.c_str(), times, AT_SYMLINK_NOFOLLOW);

// Send status to APT
if (Result == true)


+ 1
- 1
methods/server.h View File

@@ -137,7 +137,7 @@ class ServerMethod : public pkgAcqMethod
virtual ServerState * CreateServerState(URI uri) = 0;
virtual void RotateDNS() = 0;

ServerMethod(const char *Ver,unsigned long Flags = 0) : pkgAcqMethod(Ver, Flags), PipelineDepth(0), AllowRedirect(false), Debug(false) {};
ServerMethod(const char *Ver,unsigned long Flags = 0) : pkgAcqMethod(Ver, Flags), Server(NULL), File(NULL), PipelineDepth(0), AllowRedirect(false), Debug(false) {};
virtual ~ServerMethod() {};
};



+ 4
- 5
test/interactive-helper/rpmver.cc View File

@@ -2,6 +2,7 @@
#include <rpm/rpmio.h>
#include <rpm/misc.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>

#define xisdigit(x) isdigit(x)
@@ -12,10 +13,8 @@ using namespace std;

int rpmvercmp(const char * a, const char * b)
{
char oldch1, oldch2;
char * str1, * str2;
char * one, * two;
int rc;
int isnum;

/* easy comparison to see if versions are identical */
@@ -53,9 +52,9 @@ int rpmvercmp(const char * a, const char * b)

/* save character at the end of the alpha or numeric segment */
/* so that they can be restored after the comparison */
oldch1 = *str1;
char oldch1 = *str1;
*str1 = '\0';
oldch2 = *str2;
char oldch2 = *str2;
*str2 = '\0';

/* take care of the case where the two version segments are */
@@ -81,7 +80,7 @@ int rpmvercmp(const char * a, const char * b)
/* segments are alpha or if they are numeric. don't return */
/* if they are equal because there might be more segments to */
/* compare */
rc = strcmp(one, two);
int rc = strcmp(one, two);
if (rc) return rc;

/* restore character that was replaced by null above */


Loading…
Cancel
Save