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 --- methods/server.cc | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'methods/server.cc') diff --git a/methods/server.cc b/methods/server.cc index a2128441c..e12c23c07 100644 --- a/methods/server.cc +++ b/methods/server.cc @@ -17,9 +17,9 @@ #include #include +#include #include #include -#include #include #include #include @@ -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) -- cgit v1.2.3