diff --git a/app/actions.cpp b/app/actions.cpp index 53bdeb05..a53fd35e 100644 --- a/app/actions.cpp +++ b/app/actions.cpp @@ -932,7 +932,7 @@ namespace Action { const Params::PreviewNumbers& numbers = Params::instance().previewNumbers_; for (auto number : numbers) { - size_t num = static_cast(number); + auto num = static_cast(number); if (num == 0) { // Write all previews for (num = 0; num < pvList.size(); ++num) { diff --git a/app/exiv2.cpp b/app/exiv2.cpp index 1d5f9035..48d19687 100644 --- a/app/exiv2.cpp +++ b/app/exiv2.cpp @@ -150,7 +150,7 @@ int main(int argc, char* const argv[]) assert(task); // Process all files - int s = static_cast(params.files_.size()); + auto s = static_cast(params.files_.size()); if (params.action_ & Action::extract && params.target_ & Params::ctStdInOut && s > 1) { std::cerr << params.progname() << ": " << _("Only one file is allowed when extracting to stdout") << std::endl; rc = 1; @@ -949,7 +949,7 @@ static int readFileToBuf(FILE* f,Exiv2::DataBuf& buf) bool more {true}; while ( more ) { char buff[buff_size]; - int n = static_cast(fread(buff, 1, buff_size, f)); + auto n = static_cast(fread(buff, 1, buff_size, f)); more = n > 0 ; if ( more ) { bytes.resize(nBytes+n); @@ -1270,7 +1270,7 @@ namespace { } if (k > i) { bool ok = false; - int num = Exiv2::stringTo(os.str(), ok); + auto num = Exiv2::stringTo(os.str(), ok); if (ok && num >= 0) { previewNumbers.insert(num); } @@ -1282,7 +1282,7 @@ namespace { } if (!(k < optArg.size() && optArg[i] == ',')) break; } - int ret = static_cast(k - j); + auto ret = static_cast(k - j); if (ret == 0) { previewNumbers.insert(0); } diff --git a/samples/exiv2json.cpp b/samples/exiv2json.cpp index ba754c0c..47e24356 100644 --- a/samples/exiv2json.cpp +++ b/samples/exiv2json.cpp @@ -308,7 +308,7 @@ int main(int argc, char* const argv[]) if ( option == 'a' || option == 'i' ) { Exiv2::IptcData &iptcData = image->iptcData(); - for (Exiv2::IptcData::const_iterator i = iptcData.begin(); i != iptcData.end(); ++i) { + for (auto i = iptcData.begin(); i != iptcData.end(); ++i) { std::string name ; Jzon::Node& object = objectForKey(i->key(),root,name); push(object,name,i); diff --git a/samples/geotag.cpp b/samples/geotag.cpp index 544dad44..c94dbb32 100644 --- a/samples/geotag.cpp +++ b/samples/geotag.cpp @@ -247,13 +247,13 @@ std::string Position::toExifString(double d,bool bRational,bool bLat) const char* EW = d>=0.0?"E":"W"; const char* NSEW = bLat ? NS: EW; if ( d < 0 ) d = -d; - int deg = static_cast(d); + auto deg = static_cast(d); d -= deg; d *= 60; - int min = static_cast(d); + auto min = static_cast(d); d -= min; d *= 60; - int sec = static_cast(d); + auto sec = static_cast(d); char result[200]; if ( bRational ) snprintf(result,sizeof(result),"%d/1 %d/1 %d/1" ,deg,min,sec); diff --git a/samples/getopt-test.cpp b/samples/getopt-test.cpp index 48d5f6bb..690302a1 100644 --- a/samples/getopt-test.cpp +++ b/samples/getopt-test.cpp @@ -114,7 +114,7 @@ int main(int argc, char** const argv) do { n = ::getopt(argc,argv,::optstring); if ( n >= 0 ) { - char N = static_cast(n); + auto N = static_cast(n); std::cout << n << " = " << N; } else { std::cout << n ; @@ -132,7 +132,7 @@ int main(int argc, char** const argv) do { n = Util::getopt(argc,argv,::optstring); if ( n >= 0 ) { - char N = static_cast(n); + auto N = static_cast(n); std::cout << n << " = " << N; } else { std::cout << n ; diff --git a/samples/iotest.cpp b/samples/iotest.cpp index 56277355..7a7b8a5e 100644 --- a/samples/iotest.cpp +++ b/samples/iotest.cpp @@ -189,7 +189,7 @@ int WriteReadSeek(BasicIo &io) std::cerr << ": WRS size is not " << size1 << "\n"; return 2; } - long backup = static_cast(size1); + auto backup = static_cast(size1); io.seek(-backup, BasicIo::cur); int c = EOF; diff --git a/samples/mmap-test.cpp b/samples/mmap-test.cpp index e0ab5997..ae218431 100644 --- a/samples/mmap-test.cpp +++ b/samples/mmap-test.cpp @@ -47,7 +47,7 @@ try { } // Map it to memory const Exiv2::byte* pData = file.mmap(); - long size = static_cast(file.size()); + auto size = static_cast(file.size()); DataBuf buf(size); // Read from the memory mapped region buf.copyBytes(0, pData, buf.size()); diff --git a/src/basicio.cpp b/src/basicio.cpp index 7532af85..ee202a2b 100644 --- a/src/basicio.cpp +++ b/src/basicio.cpp @@ -1263,7 +1263,7 @@ namespace Exiv2 { } // submit to the remote machine. - long dataSize = static_cast(src.size() - left - right); + auto dataSize = static_cast(src.size() - left - right); if (dataSize > 0) { auto data = static_cast(std::malloc(dataSize)); src.seek(left, BasicIo::beg); diff --git a/src/bmffimage.cpp b/src/bmffimage.cpp index 2b87753a..61f92dda 100644 --- a/src/bmffimage.cpp +++ b/src/bmffimage.cpp @@ -217,7 +217,7 @@ namespace Exiv2 enforce(box_length >= hdrsize, Exiv2::kerCorruptedMetadata); enforce(box_length - hdrsize <= static_cast(pbox_end - restore), Exiv2::kerCorruptedMetadata); - const size_t buffer_size = static_cast(box_length - hdrsize); + const auto buffer_size = static_cast(box_length - hdrsize); if (skipBox(box_type)) { if (bTrace) { out << std::endl; @@ -637,7 +637,7 @@ namespace Exiv2 xmpID_ = unknownID_; long address = 0; - const long file_end = static_cast(io_->size()); + const auto file_end = static_cast(io_->size()); while (address < file_end) { io_->seek(address, BasicIo::beg); address = boxHandler(std::cout,kpsNone,file_end,0); @@ -671,7 +671,7 @@ namespace Exiv2 IoCloser closer(*io_); long address = 0; - const long file_end = static_cast(io_->size()); + const auto file_end = static_cast(io_->size()); while (address < file_end) { io_->seek(address, BasicIo::beg); address = boxHandler(out,option,file_end,depth); diff --git a/src/canonmn_int.cpp b/src/canonmn_int.cpp index ce7cf9fd..260dd688 100644 --- a/src/canonmn_int.cpp +++ b/src/canonmn_int.cpp @@ -2730,8 +2730,8 @@ namespace Exiv2::Internal { return os; } - int const exifFlMin = static_cast(static_cast(pos->value().toInt64(1)) / pos->value().toFloat(2)); - int const exifFlMax = static_cast(static_cast(pos->value().toInt64(0)) / pos->value().toFloat(2)); + auto const exifFlMin = static_cast(static_cast(pos->value().toInt64(1)) / pos->value().toFloat(2)); + auto const exifFlMax = static_cast(static_cast(pos->value().toInt64(0)) / pos->value().toFloat(2)); ExifKey aperKey("Exif.CanonCs.MaxAperture"); pos = metadata->findKey(aperKey); @@ -2894,7 +2894,7 @@ namespace Exiv2::Internal { // see also printSi0x0017 std::ostringstream oss; oss.copyfmt(os); - int res = static_cast(100.0 * (static_cast(value.toInt64()) / 32.0 + 5.0) + 0.5); + auto res = static_cast(100.0 * (static_cast(value.toInt64()) / 32.0 + 5.0) + 0.5); os << std::fixed << std::setprecision(2) << res / 100.0; os.copyfmt(oss); } @@ -3067,7 +3067,7 @@ namespace Exiv2::Internal { // remove fraction const auto remainder = val & 0x1f; val -= remainder; - float frac = static_cast(remainder); + auto frac = static_cast(remainder); // convert 1/3 (0x0c) and 2/3 (0x14) codes if (frac == 0x0c) { frac = 32.0F / 3; diff --git a/src/casiomn_int.cpp b/src/casiomn_int.cpp index bfbbc207..520bf6e1 100644 --- a/src/casiomn_int.cpp +++ b/src/casiomn_int.cpp @@ -527,7 +527,7 @@ namespace Exiv2::Internal { std::vector numbers; for(size_t i=0; i(value.toInt64(i)); + const auto l = static_cast(value.toInt64(i)); if(l!=0) { numbers.push_back(l); diff --git a/src/convert.cpp b/src/convert.cpp index ae8cb862..80d07bab 100644 --- a/src/convert.cpp +++ b/src/convert.cpp @@ -774,7 +774,7 @@ namespace Exiv2 { deg[i] = static_cast(z)/d; } double min = deg[0] * 60.0 + deg[1] + deg[2] / 60.0; - int ideg = static_cast(min / 60.0); + auto ideg = static_cast(min / 60.0); min -= ideg * 60; std::ostringstream oss; oss << ideg << "," diff --git a/src/crwimage_int.cpp b/src/crwimage_int.cpp index 3088e0c9..82e414c7 100644 --- a/src/crwimage_int.cpp +++ b/src/crwimage_int.cpp @@ -816,7 +816,7 @@ namespace Exiv2::Internal { const uint32_t component_size = ciffComponent.size(); enforce(component_size % 2 == 0, kerCorruptedMetadata); enforce(component_size/2 <= static_cast(std::numeric_limits::max()), kerCorruptedMetadata); - const uint16_t num_components = static_cast(component_size/2); + const auto num_components = static_cast(component_size / 2); uint16_t c = 1; while (c < num_components) { uint16_t n = 1; diff --git a/src/http.cpp b/src/http.cpp index 1fbcf8c0..9eecfcac 100644 --- a/src/http.cpp +++ b/src/http.cpp @@ -227,7 +227,7 @@ int Exiv2::http(Exiv2::Dictionary& request,Exiv2::Dictionary& response,std::stri //////////////////////////////////// // open the socket - int sockfd = static_cast(socket(AF_INET , SOCK_STREAM,IPPROTO_TCP)); + auto sockfd = static_cast(socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)); if (sockfd < 0) return error(errors, "unable to create socket\n", nullptr, nullptr, 0); diff --git a/src/image.cpp b/src/image.cpp index 470769d4..9197d9e6 100644 --- a/src/image.cpp +++ b/src/image.cpp @@ -386,7 +386,7 @@ namespace Exiv2 { // Overflow check enforce(allocate64 <= static_cast(std::numeric_limits::max()), kerCorruptedMetadata); enforce(allocate64 <= static_cast(std::numeric_limits::max()), kerCorruptedMetadata); - const long allocate = static_cast(allocate64); + const auto allocate = static_cast(allocate64); DataBuf buf(allocate); // allocate a buffer buf.copyBytes(0, dir.c_data(8), 4); // copy dir[8:11] into buffer (short strings) @@ -517,7 +517,7 @@ namespace Exiv2 { // read header (we already know for certain that we have a Tiff file) io.readOrThrow(dir.data(), 8, kerCorruptedMetadata); - char c = static_cast(dir.read_uint8(0)); + auto c = static_cast(dir.read_uint8(0)); bool bSwap = ( c == 'M' && isLittleEndianPlatform() ) || ( c == 'I' && isBigEndianPlatform() ) ; diff --git a/src/jpgimage.cpp b/src/jpgimage.cpp index 384a327e..8b08ce3b 100644 --- a/src/jpgimage.cpp +++ b/src/jpgimage.cpp @@ -398,8 +398,8 @@ namespace Exiv2 { foundIccData = true ; --search ; } - int chunk = static_cast(buf.read_uint8(2 + 12)); - int chunks = static_cast(buf.read_uint8(2 + 13)); + auto chunk = static_cast(buf.read_uint8(2 + 12)); + auto chunks = static_cast(buf.read_uint8(2 + 13)); // ICC1v43_2010-12.pdf header is 14 bytes // header = "ICC_PROFILE\0" (12 bytes) // chunk/chunks are a single byte @@ -1082,7 +1082,7 @@ namespace Exiv2 { if (chunkSize > maxChunkSize) { chunkSize = maxChunkSize; // Don't break at a valid IRB boundary - const long writtenSize = static_cast(chunkStart - newPsData.c_data()); + const auto writtenSize = static_cast(chunkStart - newPsData.c_data()); if (Photoshop::valid(newPsData.c_data(), writtenSize + chunkSize)) { // Since an IRB has minimum size 12, // (chunkSize - 8) can't be also a IRB boundary diff --git a/src/nikonmn_int.cpp b/src/nikonmn_int.cpp index 460f1b91..2efc1b06 100644 --- a/src/nikonmn_int.cpp +++ b/src/nikonmn_int.cpp @@ -2623,7 +2623,7 @@ fmountlens[] = { */ if (metadata == nullptr) { - const unsigned char vid = static_cast(value.toInt64(0)); + const auto vid = static_cast(value.toInt64(0)); /* the 'FMntLens' name is added to the anonymous struct for * fmountlens[] diff --git a/src/olympusmn_int.cpp b/src/olympusmn_int.cpp index decf3ea5..c04ffa04 100644 --- a/src/olympusmn_int.cpp +++ b/src/olympusmn_int.cpp @@ -1361,9 +1361,9 @@ namespace Exiv2::Internal { return os << value; } - byte v0 = static_cast(value.toInt64(0)); - byte v2 = static_cast(value.toInt64(2)); - byte v3 = static_cast(value.toInt64(3)); + auto v0 = static_cast(value.toInt64(0)); + auto v2 = static_cast(value.toInt64(2)); + auto v3 = static_cast(value.toInt64(3)); for (auto&& type : lensTypes) { if (type.val[0] == v0 && type.val[1] == v2 && type.val[2] == v3) { @@ -1407,8 +1407,8 @@ namespace Exiv2::Internal { return os << value; } - byte v0 = static_cast(value.toInt64(0)); - byte v2 = static_cast(value.toInt64(2)); + auto v0 = static_cast(value.toInt64(0)); + auto v2 = static_cast(value.toInt64(2)); for (auto&& model : extenderModels) { if (model.val[0] == v0 && model.val[1] == v2) { diff --git a/src/panasonicmn_int.cpp b/src/panasonicmn_int.cpp index 1bcbde5c..4d15ea14 100644 --- a/src/panasonicmn_int.cpp +++ b/src/panasonicmn_int.cpp @@ -672,14 +672,14 @@ namespace Exiv2::Internal { std::ostream& PanasonicMakerNote::printAccelerometer(std::ostream& os, const Value& value, const ExifData*) { // value is stored as unsigned int, but should be read as int16_t. - const int16_t i = static_cast(value.toInt64()); + const auto i = static_cast(value.toInt64()); return os << i; } // PanasonicMakerNote::printAccelerometer std::ostream& PanasonicMakerNote::printRollAngle(std::ostream& os, const Value& value, const ExifData*) { // value is stored as unsigned int, but should be read as int16_t. - const int16_t i = static_cast(value.toInt64()); + const auto i = static_cast(value.toInt64()); std::ostringstream oss; oss.copyfmt(os); os << std::fixed << std::setprecision(1) << i / 10.0; @@ -691,7 +691,7 @@ namespace Exiv2::Internal { std::ostream& PanasonicMakerNote::printPitchAngle(std::ostream& os, const Value& value, const ExifData*) { // value is stored as unsigned int, but should be read as int16_t. - const int16_t i = static_cast(value.toInt64()); + const auto i = static_cast(value.toInt64()); std::ostringstream oss; oss.copyfmt(os); os << std::fixed << std::setprecision(1) << -i / 10.0; diff --git a/src/pgfimage.cpp b/src/pgfimage.cpp index 1582830a..2114e8cc 100644 --- a/src/pgfimage.cpp +++ b/src/pgfimage.cpp @@ -181,7 +181,7 @@ namespace Exiv2 { img->setIptcData(iptcData_); img->setXmpData(xmpData_); img->writeMetadata(); - long imgSize = static_cast(img->io().size()); + auto imgSize = static_cast(img->io().size()); DataBuf imgBuf = img->io().read(imgSize); #ifdef EXIV2_DEBUG_MESSAGES @@ -257,7 +257,7 @@ namespace Exiv2 { if (bufRead != buffer.size()) throw Error(kerInputDataReadFailed); - int headerSize = static_cast(byteSwap_(buffer, 0, bSwap_)); + auto headerSize = static_cast(byteSwap_(buffer, 0, bSwap_)); if (headerSize <= 0 ) throw Error(kerNoImageInInputData); #ifdef EXIV2_DEBUG_MESSAGES diff --git a/src/pngchunk_int.cpp b/src/pngchunk_int.cpp index 8648cece..81cdfcae 100644 --- a/src/pngchunk_int.cpp +++ b/src/pngchunk_int.cpp @@ -158,7 +158,7 @@ namespace Exiv2::Internal { Exiv2::kerCorruptedMetadata); const byte* text = data.c_data(keysize + 3 + languageTextSize + 1 + translatedKeyTextSize + 1); - const long textsize = static_cast( + const auto textsize = static_cast( data.size() - (keysize + 3 + languageTextSize + 1 + translatedKeyTextSize + 1)); if (compressionFlag == 0x00) { diff --git a/src/pngimage.cpp b/src/pngimage.cpp index d4b85d53..74df305a 100644 --- a/src/pngimage.cpp +++ b/src/pngimage.cpp @@ -313,7 +313,7 @@ namespace Exiv2 { 1; // leading string length enforce(name_l < dataOffset, kerCorruptedMetadata); - uint32_t start = static_cast(name_l); + auto start = static_cast(name_l); bool bLF = false; // decode the chunk diff --git a/src/rafimage.cpp b/src/rafimage.cpp index 76aece5d..75e7920f 100644 --- a/src/rafimage.cpp +++ b/src/rafimage.cpp @@ -301,8 +301,8 @@ namespace Exiv2 { kerCorruptedMetadata); #endif - long jpg_img_off = static_cast(jpg_img_off_u32); - long jpg_img_len = static_cast(jpg_img_len_u32); + auto jpg_img_off = static_cast(jpg_img_off_u32); + auto jpg_img_len = static_cast(jpg_img_len_u32); enforce(jpg_img_len >= 12, kerCorruptedMetadata); diff --git a/src/tags_int.cpp b/src/tags_int.cpp index bc4cbe91..d1617b9a 100644 --- a/src/tags_int.cpp +++ b/src/tags_int.cpp @@ -2784,9 +2784,9 @@ namespace Exiv2::Internal { if (fraction != 0) p = 1; const double ss = std::fmod(t, 60); const double minutes = (t - ss)/60; - const int mm = static_cast(std::fmod(minutes, 60)); + const auto mm = static_cast(std::fmod(minutes, 60)); const double hours = (minutes - mm)/60; - const int hh = static_cast(std::fmod(hours, 24)); + const auto hh = static_cast(std::fmod(hours, 24)); os << std::setw(2) << std::setfill('0') << std::right << hh << ":" << std::setw(2) << std::setfill('0') << std::right << mm << ":" diff --git a/src/tiffcomposite_int.cpp b/src/tiffcomposite_int.cpp index 290b1060..d72dcba1 100644 --- a/src/tiffcomposite_int.cpp +++ b/src/tiffcomposite_int.cpp @@ -1077,7 +1077,7 @@ namespace Exiv2::Internal { } // Also add the size of data, but only if needed if (isRootDir) { - uint32_t sd = static_cast(component->sizeData()); + auto sd = static_cast(component->sizeData()); sd += sd & 1; // Align data to word boundary sizeData += sd; } @@ -1104,7 +1104,7 @@ namespace Exiv2::Internal { sv += sv & 1; // Align value to word boundary valueIdx += sv; } - uint32_t sd = static_cast(component->sizeData()); + auto sd = static_cast(component->sizeData()); sd += sd & 1; // Align data to word boundary dataIdx += sd; } @@ -1134,7 +1134,7 @@ namespace Exiv2::Internal { idx += sv; valueIdx += sv; } - uint32_t sd = static_cast(component->sizeData()); + auto sd = static_cast(component->sizeData()); sd += sd & 1; // Align data to word boundary dataIdx += sd; } @@ -1626,7 +1626,7 @@ namespace Exiv2::Internal { sv += sv & 1; // Align value to word boundary len += sv; } - uint32_t sd = static_cast(component->sizeData()); + auto sd = static_cast(component->sizeData()); sd += sd & 1; // Align data to word boundary len += sd; } diff --git a/src/tiffvisitor_int.cpp b/src/tiffvisitor_int.cpp index fd3f4323..f66bd4f0 100644 --- a/src/tiffvisitor_int.cpp +++ b/src/tiffvisitor_int.cpp @@ -1521,7 +1521,7 @@ namespace Exiv2::Internal { if (count > std::numeric_limits::max() / typeSize) { throw Error(kerArithmeticOverflow); } - uint32_t size = static_cast(typeSize * count); + auto size = static_cast(typeSize * count); uint32_t offset = getLong(p, byteOrder()); byte* pData = p; if ( size > 4 diff --git a/src/types.cpp b/src/types.cpp index a522dc54..8f6ba372 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -628,13 +628,13 @@ namespace Exiv2 { int64_t parseInt64(const std::string& s, bool& ok) { - int64_t ret = stringTo(s, ok); + auto ret = stringTo(s, ok); if (ok) return ret; auto f = stringTo(s, ok); if (ok) return static_cast(f); - Rational r = stringTo(s, ok); + auto r = stringTo(s, ok); if (ok) { if (r.second <= 0) { ok = false; @@ -664,7 +664,7 @@ namespace Exiv2 { auto ret = stringTo(s, ok); if (ok) return ret; - Rational r = stringTo(s, ok); + auto r = stringTo(s, ok); if (ok) { if (r.second == 0) { ok = false; @@ -683,10 +683,10 @@ namespace Exiv2 { Rational parseRational(const std::string& s, bool& ok) { - Rational ret = stringTo(s, ok); + auto ret = stringTo(s, ok); if (ok) return ret; - long l = stringTo(s, ok); + auto l = stringTo(s, ok); if (ok) return {l, 1}; @@ -714,7 +714,7 @@ namespace Exiv2 { } // Beware: primitive conversion algorithm int32_t den = 1000000; - const long d_as_long = static_cast(d); + const auto d_as_long = static_cast(d); if (Safe::abs(d_as_long) > 2147) { den = 10000; } diff --git a/src/value.cpp b/src/value.cpp index f28e21d3..6b8b20ee 100644 --- a/src/value.cpp +++ b/src/value.cpp @@ -1001,7 +1001,7 @@ namespace Exiv2 { tms.tm_mday = date_.day; tms.tm_mon = date_.month - 1; tms.tm_year = date_.year - 1900; - int64_t l = static_cast(std::mktime(&tms)); + auto l = static_cast(std::mktime(&tms)); ok_ = (l != -1); return l; } diff --git a/src/webpimage.cpp b/src/webpimage.cpp index 35c3c40e..c4302335 100644 --- a/src/webpimage.cpp +++ b/src/webpimage.cpp @@ -208,7 +208,7 @@ namespace Exiv2 { // Check that `size_u32` is safe to cast to `long`. enforce(size_u32 <= static_cast(std::numeric_limits::max()), Exiv2::kerCorruptedMetadata); - const long size = static_cast(size_u32); + const auto size = static_cast(size_u32); DataBuf payload(size); io_->readOrThrow(payload.data(), payload.size(), Exiv2::kerCorruptedMetadata); if ( payload.size() % 2 ) { @@ -346,7 +346,7 @@ namespace Exiv2 { // Check that `size_u32` is safe to cast to `long`. enforce(size_u32 <= static_cast(std::numeric_limits::max()), Exiv2::kerCorruptedMetadata); - const long size = static_cast(size_u32); + const auto size = static_cast(size_u32); DataBuf payload(size); io_->readOrThrow(payload.data(), size, Exiv2::kerCorruptedMetadata); @@ -572,7 +572,7 @@ namespace Exiv2 { // Check that `size_u32` is safe to cast to `long`. enforce(size_u32 <= static_cast(std::numeric_limits::max()), Exiv2::kerCorruptedMetadata); - const long size = static_cast(size_u32); + const auto size = static_cast(size_u32); // Check that `size` is within bounds. enforce(io_->tell() <= filesize, Exiv2::kerCorruptedMetadata);