gcc: remove redundant struct
Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
parent
9a1f37ecbe
commit
1f21164085
@ -64,7 +64,7 @@ class Timestamp {
|
||||
//! C'tor
|
||||
int read(const std::string& path);
|
||||
//! Read the timestamp from a broken-down time in buffer \em tm.
|
||||
int read(struct tm* tm);
|
||||
int read(tm* tm);
|
||||
//! Set the timestamp of a file
|
||||
int touch(const std::string& path) const;
|
||||
|
||||
@ -74,16 +74,16 @@ class Timestamp {
|
||||
};
|
||||
|
||||
/*!
|
||||
@brief Convert a string "YYYY:MM:DD HH:MI:SS" to a struct tm type,
|
||||
@brief Convert a string "YYYY:MM:DD HH:MI:SS" to a tm type,
|
||||
returns 0 if successful
|
||||
*/
|
||||
int str2Tm(const std::string& timeStr, struct tm* tm);
|
||||
int str2Tm(const std::string& timeStr, tm* tm);
|
||||
|
||||
//! Convert a localtime to a string "YYYY:MM:DD HH:MI:SS", "" on error
|
||||
std::string time2Str(time_t time);
|
||||
|
||||
//! Convert a tm structure to a string "YYYY:MM:DD HH:MI:SS", "" on error
|
||||
std::string tm2Str(const struct tm* tm);
|
||||
std::string tm2Str(const tm* tm);
|
||||
|
||||
/*!
|
||||
@brief Copy metadata from source to target according to Params::copyXyz
|
||||
@ -107,7 +107,7 @@ int metacopy(const std::string& source, const std::string& tgt, Exiv2::ImageType
|
||||
the file to.
|
||||
@return 0 if successful, -1 if the file was skipped, 1 on error.
|
||||
*/
|
||||
int renameFile(std::string& path, const struct tm* tm);
|
||||
int renameFile(std::string& path, const tm* tm);
|
||||
|
||||
/*!
|
||||
@brief Make a file path from the current file path, destination
|
||||
@ -637,7 +637,7 @@ int Rename::run(const std::string& path) {
|
||||
std::cerr << _("Image file creation timestamp not set in the file") << " " << path << "\n";
|
||||
return 1;
|
||||
}
|
||||
struct tm tm;
|
||||
tm tm;
|
||||
if (str2Tm(v, &tm) != 0) {
|
||||
std::cerr << _("Failed to parse timestamp") << " `" << v << "' " << _("in the file") << " " << path << "\n";
|
||||
return 1;
|
||||
@ -1401,7 +1401,7 @@ int Adjust::adjustDateTime(Exiv2::ExifData& exifData, const std::string& key, co
|
||||
std::cout << " " << adjustment_ << _("s");
|
||||
}
|
||||
}
|
||||
struct tm tm;
|
||||
tm tm;
|
||||
if (str2Tm(timeStr, &tm) != 0) {
|
||||
if (Params::instance().verbose_)
|
||||
std::cout << std::endl;
|
||||
@ -1584,7 +1584,7 @@ int Timestamp::read(const std::string& path) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
int Timestamp::read(struct tm* tm) {
|
||||
int Timestamp::read(tm* tm) {
|
||||
int rc = 1;
|
||||
time_t t = mktime(tm); // interpret tm according to current timezone settings
|
||||
if (t != static_cast<time_t>(-1)) {
|
||||
@ -1598,14 +1598,14 @@ int Timestamp::read(struct tm* tm) {
|
||||
int Timestamp::touch(const std::string& path) const {
|
||||
if (0 == actime_)
|
||||
return 1;
|
||||
struct utimbuf buf;
|
||||
utimbuf buf;
|
||||
buf.actime = actime_;
|
||||
buf.modtime = modtime_;
|
||||
return utime(path.c_str(), &buf);
|
||||
}
|
||||
//! @endcond
|
||||
|
||||
int str2Tm(const std::string& timeStr, struct tm* tm) {
|
||||
int str2Tm(const std::string& timeStr, tm* tm) {
|
||||
if (timeStr.empty() || timeStr.front() == ' ')
|
||||
return 1;
|
||||
if (timeStr.length() < 19)
|
||||
@ -1615,7 +1615,7 @@ int str2Tm(const std::string& timeStr, struct tm* tm) {
|
||||
return 3;
|
||||
if (!tm)
|
||||
return 4;
|
||||
std::memset(tm, 0x0, sizeof(struct tm));
|
||||
std::memset(tm, 0x0, sizeof(*tm));
|
||||
tm->tm_isdst = -1;
|
||||
|
||||
int64_t tmp = 0;
|
||||
@ -1656,7 +1656,7 @@ std::string time2Str(time_t time) {
|
||||
return tm2Str(tm);
|
||||
} // time2Str
|
||||
|
||||
std::string tm2Str(const struct tm* tm) {
|
||||
std::string tm2Str(const tm* tm) {
|
||||
if (!tm)
|
||||
return "";
|
||||
|
||||
@ -1831,7 +1831,7 @@ void replace(std::string& text, const std::string& searchText, const std::string
|
||||
}
|
||||
}
|
||||
|
||||
int renameFile(std::string& newPath, const struct tm* tm) {
|
||||
int renameFile(std::string& newPath, const tm* tm) {
|
||||
auto p = fs::path(newPath);
|
||||
std::string path = newPath;
|
||||
auto oldFsPath = fs::path(path);
|
||||
|
||||
@ -963,7 +963,7 @@ void Params::getStdin(Exiv2::DataBuf& buf) {
|
||||
fd_set readfds;
|
||||
FD_ZERO(&readfds);
|
||||
FD_SET(STDIN_FILENO, &readfds);
|
||||
struct timeval timeout = {1, 0}; // yes: set timeout seconds,microseconds
|
||||
timeval timeout = {1, 0}; // yes: set timeout seconds,microseconds
|
||||
|
||||
// if we have something in the pipe, read it
|
||||
if (select(1, &readfds, nullptr, nullptr, &timeout)) {
|
||||
|
||||
@ -332,7 +332,7 @@ EXIV2API bool isHex(const std::string& str, size_t size = 0, const std::string&
|
||||
"2007:05:24 12:31:55" to broken down time format,
|
||||
returns 0 if successful, else 1.
|
||||
*/
|
||||
EXIV2API int exifTime(const char* buf, struct tm* tm);
|
||||
EXIV2API int exifTime(const char* buf, tm* tm);
|
||||
|
||||
/*!
|
||||
@brief Translate a string using the gettext framework. This wrapper hides
|
||||
|
||||
@ -741,7 +741,7 @@ void CrwMap::decode0x180e(const CiffComponent& ciffComponent, const CrwMapping*
|
||||
ULongValue v;
|
||||
v.read(ciffComponent.pData(), 8, byteOrder);
|
||||
time_t t = v.value_.at(0);
|
||||
struct tm r;
|
||||
tm r;
|
||||
#ifdef _WIN32
|
||||
auto tm = localtime_s(&r, &t) ? nullptr : &r;
|
||||
#else
|
||||
@ -930,7 +930,7 @@ void CrwMap::encode0x180e(const Image& image, const CrwMapping* pCrwMapping, Cif
|
||||
time_t t = 0;
|
||||
const ExifKey key(pCrwMapping->tag_, Internal::groupName(pCrwMapping->ifdId_));
|
||||
if (auto ed = image.exifData().findKey(key); ed != image.exifData().end()) {
|
||||
struct tm tm = {};
|
||||
tm tm = {};
|
||||
if (exifTime(ed->toString().c_str(), &tm) == 0) {
|
||||
t = ::mktime(&tm);
|
||||
}
|
||||
|
||||
@ -204,7 +204,7 @@ int Exiv2::http(Exiv2::Dictionary& request, Exiv2::Dictionary& response, std::st
|
||||
int server = -1;
|
||||
|
||||
// fill in the address
|
||||
struct sockaddr_in serv_addr = {};
|
||||
sockaddr_in serv_addr = {};
|
||||
int serv_len = sizeof(serv_addr);
|
||||
|
||||
serv_addr.sin_addr.s_addr = inet_addr(servername_p);
|
||||
@ -226,7 +226,7 @@ int Exiv2::http(Exiv2::Dictionary& request, Exiv2::Dictionary& response, std::st
|
||||
|
||||
////////////////////////////////////
|
||||
// and connect
|
||||
server = connect(sockfd, reinterpret_cast<const struct sockaddr*>(&serv_addr), serv_len);
|
||||
server = connect(sockfd, reinterpret_cast<const sockaddr*>(&serv_addr), serv_len);
|
||||
if (server == SOCKET_ERROR && WSAGetLastError() != WSAEWOULDBLOCK) {
|
||||
closesocket(sockfd);
|
||||
return error(errors, "error - unable to connect to server = %s port = %s wsa_error = %d", servername_p, port_p,
|
||||
|
||||
@ -866,8 +866,7 @@ void JpegBase::doWriteMetadata(BasicIo& outIo) {
|
||||
|
||||
if (outIo.write(tmpBuf.data(), 4) != 4)
|
||||
throw Error(ErrorCode::kerImageWriteFailed);
|
||||
if (outIo.write(reinterpret_cast<byte*>(const_cast<char*>(comment_.data())), comment_.length()) !=
|
||||
comment_.length())
|
||||
if (outIo.write(reinterpret_cast<byte*>(comment_.data()), comment_.length()) != comment_.length())
|
||||
throw Error(ErrorCode::kerImageWriteFailed);
|
||||
if (outIo.putb(0) == EOF)
|
||||
throw Error(ErrorCode::kerImageWriteFailed);
|
||||
|
||||
@ -3104,7 +3104,7 @@ std::ostream& Nikon3MakerNote::printLensId(std::ostream& os, const Value& value,
|
||||
*
|
||||
* www.rottmerhusen.com/objektives/lensid/files/c-header/fmountlens4.h
|
||||
*/
|
||||
const struct FMntLens* pf = fmountlens;
|
||||
const FMntLens* pf = fmountlens;
|
||||
while (pf->lid && pf->lensname) {
|
||||
if (pf->lid == vid) {
|
||||
break;
|
||||
|
||||
@ -488,7 +488,7 @@ bool isHex(const std::string& str, size_t size, const std::string& prefix) {
|
||||
return true;
|
||||
} // isHex
|
||||
|
||||
int exifTime(const char* buf, struct tm* tm) {
|
||||
int exifTime(const char* buf, tm* tm) {
|
||||
int rc = 1;
|
||||
int year = 0, mon = 0, mday = 0, hour = 0, min = 0, sec = 0;
|
||||
if (std::sscanf(buf, "%4d:%2d:%2d %2d:%2d:%2d", &year, &mon, &mday, &hour, &min, &sec) == 6) {
|
||||
|
||||
@ -14,7 +14,7 @@ using namespace Exiv2;
|
||||
// More info about tm : http://www.cplusplus.com/reference/ctime/tm/
|
||||
|
||||
TEST(ExivTime, getsTimeFromValidString) {
|
||||
struct tm tmInstance;
|
||||
tm tmInstance;
|
||||
ASSERT_EQ(0, exifTime("2007:05:24 12:31:55", &tmInstance));
|
||||
ASSERT_EQ(107, tmInstance.tm_year); // Years since 1900
|
||||
ASSERT_EQ(4, tmInstance.tm_mon);
|
||||
@ -25,7 +25,7 @@ TEST(ExivTime, getsTimeFromValidString) {
|
||||
}
|
||||
|
||||
TEST(ExivTime, doesNotGetTimeWithBadFormedString) {
|
||||
struct tm tmInstance;
|
||||
tm tmInstance;
|
||||
ASSERT_EQ(1, exifTime("007:a5:24 aa:bb:cc", &tmInstance));
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user