From 743da1a5643a8d831b60911d9c9120417c1cb9ac Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Wed, 19 May 2021 14:48:26 -0700 Subject: [PATCH] clang-tidy: use C++ casting Found with google-readability-casting Signed-off-by: Rosen Penev --- samples/exiv2json.cpp | 26 +- samples/geotag.cpp | 32 +- samples/getopt-test.cpp | 24 +- samples/iotest.cpp | 14 +- samples/mmap-test.cpp | 2 +- samples/tiff-test.cpp | 2 +- src/actions.cpp | 22 +- src/basicio.cpp | 59 ++-- src/bmffimage.cpp | 38 +-- src/canonmn_int.cpp | 697 ++++++++++++++++++++-------------------- src/casiomn_int.cpp | 4 +- src/cr2image.cpp | 9 +- src/crwimage.cpp | 6 +- src/exif.cpp | 6 +- src/exiv2.cpp | 28 +- src/futils.cpp | 10 +- src/getopt.cpp | 4 +- src/http.cpp | 11 +- src/image.cpp | 23 +- src/image_int.cpp | 14 +- src/ini.cpp | 19 +- src/jp2image.cpp | 118 ++++--- src/jpgimage.cpp | 31 +- src/minoltamn_int.cpp | 2 +- src/nikonmn_int.cpp | 47 ++- src/olympusmn_int.cpp | 30 +- src/orfimage.cpp | 9 +- src/pentaxmn_int.cpp | 2 +- src/pgfimage.cpp | 8 +- src/pngchunk_int.cpp | 49 ++- src/pngimage.cpp | 57 ++-- src/preview.cpp | 13 +- src/rafimage.cpp | 51 ++- src/rw2image.cpp | 7 +- src/tags_int.cpp | 17 +- src/tiffimage.cpp | 9 +- src/tiffvisitor_int.cpp | 6 +- src/types.cpp | 113 ++++--- src/webpimage.cpp | 76 +++-- src/xmp.cpp | 2 +- src/xmpsidecar.cpp | 2 +- 41 files changed, 836 insertions(+), 863 deletions(-) diff --git a/samples/exiv2json.cpp b/samples/exiv2json.cpp index 4bf8584c..0039a56a 100644 --- a/samples/exiv2json.cpp +++ b/samples/exiv2json.cpp @@ -255,17 +255,17 @@ void fileSystemPush(const char* path,Jzon::Node& nfs) memset(&buf,0,sizeof(buf)); stat(path,&buf); - fs.Add("st_dev" ,(int) buf.st_dev ); /* ID of device containing file */ - fs.Add("st_ino" ,(int) buf.st_ino ); /* inode number */ - fs.Add("st_mode" ,(int) buf.st_mode ); /* protection */ - fs.Add("st_nlink" ,(int) buf.st_nlink ); /* number of hard links */ - fs.Add("st_uid" ,(int) buf.st_uid ); /* user ID of owner */ - fs.Add("st_gid" ,(int) buf.st_gid ); /* group ID of owner */ - fs.Add("st_rdev" ,(int) buf.st_rdev ); /* device ID (if special file) */ - fs.Add("st_size" ,(int) buf.st_size ); /* total size, in bytes */ - fs.Add("st_atime" ,(int) buf.st_atime ); /* time of last access */ - fs.Add("st_mtime" ,(int) buf.st_mtime ); /* time of last modification */ - fs.Add("st_ctime" ,(int) buf.st_ctime ); /* time of last status change */ + fs.Add("st_dev", static_cast(buf.st_dev)); /* ID of device containing file */ + fs.Add("st_ino", static_cast(buf.st_ino)); /* inode number */ + fs.Add("st_mode", static_cast(buf.st_mode)); /* protection */ + fs.Add("st_nlink", static_cast(buf.st_nlink)); /* number of hard links */ + fs.Add("st_uid", static_cast(buf.st_uid)); /* user ID of owner */ + fs.Add("st_gid", static_cast(buf.st_gid)); /* group ID of owner */ + fs.Add("st_rdev", static_cast(buf.st_rdev)); /* device ID (if special file) */ + fs.Add("st_size", static_cast(buf.st_size)); /* total size, in bytes */ + fs.Add("st_atime", static_cast(buf.st_atime)); /* time of last access */ + fs.Add("st_mtime", static_cast(buf.st_mtime)); /* time of last modification */ + fs.Add("st_ctime", static_cast(buf.st_ctime)); /* time of last status change */ #if defined(_MSC_VER) || defined(__MINGW__) size_t blksize = 1024; @@ -274,8 +274,8 @@ void fileSystemPush(const char* path,Jzon::Node& nfs) size_t blksize = buf.st_blksize; size_t blocks = buf.st_blocks ; #endif - fs.Add("st_blksize",(int) blksize ); /* blocksize for file system I/O */ - fs.Add("st_blocks" ,(int) blocks ); /* number of 512B blocks allocated */ + fs.Add("st_blksize", static_cast(blksize)); /* blocksize for file system I/O */ + fs.Add("st_blocks", static_cast(blocks)); /* number of 512B blocks allocated */ } int main(int argc, char* const argv[]) diff --git a/samples/geotag.cpp b/samples/geotag.cpp index a1fbce7c..c07dbda9 100644 --- a/samples/geotag.cpp +++ b/samples/geotag.cpp @@ -247,7 +247,7 @@ std::string Position::toExifString(double d) { char result[200]; d *= 100; - sprintf(result,"%d/100",abs((int)d)); + sprintf(result, "%d/100", abs(static_cast(d))); return std::string(result); } @@ -257,13 +257,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 = (int) d; - d -= deg; - d *= 60; - int min = (int) d ; - d -= min; - d *= 60; - int sec = (int)d; + int deg = static_cast(d); + d -= deg; + d *= 60; + int min = static_cast(d); + d -= min; + d *= 60; + int sec = static_cast(d); char result[200]; if ( bRational ) sprintf(result,"%d/1 %d/1 %d/1" ,deg,min,sec); @@ -326,7 +326,7 @@ public: // XML Parser Callbacks static void startElement(void* userData, const char* name, const char** atts ) { - auto me = (UserData*)userData; + auto me = static_cast(userData); //for ( int i = 0 ; i < me->indent ; i++ ) printf(" "); //printf("begin %s\n",name); me->bTime = strcmp(name,"time")==0; @@ -348,7 +348,7 @@ static void startElement(void* userData, const char* name, const char** atts ) static void endElement(void* userData, const char* name) { - auto me = (UserData*)userData; + auto me = static_cast(userData); me->indent-- ; if ( strcmp(name,"trkpt")==0 ) { @@ -370,7 +370,7 @@ static void endElement(void* userData, const char* name) void charHandler(void* userData,const char* s,int len) { - auto me = (UserData*)userData; + auto me = static_cast(userData); if ( me->nTrkpt == 1 ) { char buffer[100]; @@ -584,14 +584,14 @@ bool readXML(const char* path,Options& options) // swallow it if ( bResult ) { len = sip(f,buffer,sizeof buffer,len); - bResult = XML_Parse(parser, buffer,(int)len, len == 0 ) == XML_STATUS_OK; + bResult = XML_Parse(parser, buffer, static_cast(len), len == 0) == XML_STATUS_OK; } // drink the rest of the file while ( bResult && len != 0 ) { len = fread(buffer,1,sizeof(buffer)-100,f); len = sip(f,buffer,sizeof buffer,len); - bResult = XML_Parse(parser, buffer,(int)len, len == 0 ) == XML_STATUS_OK; + bResult = XML_Parse(parser, buffer, static_cast(len), len == 0) == XML_STATUS_OK; }; } @@ -861,10 +861,12 @@ int main(int argc,const char* argv[]) #endif char* path = realpath(arg,buffer); if ( t && path ) { - if ( options.verbose) printf("%s %ld %s",path,(long int)t,asctime(localtime(&t))); + if (options.verbose) + printf("%s %ld %s", path, static_cast(t), asctime(localtime(&t))); gFiles.push_back(path); } - if ( path && path != buffer ) ::free((void*) path); + if (path && path != buffer) + ::free(path); } if ( type == typeUnknown ) { fprintf(stderr,"error: illegal syntax %s\n",arg); diff --git a/samples/getopt-test.cpp b/samples/getopt-test.cpp index 1122cf92..83e4f441 100644 --- a/samples/getopt-test.cpp +++ b/samples/getopt-test.cpp @@ -114,12 +114,12 @@ int main(int argc, char** const argv) do { n = ::getopt(argc,argv,::optstring); if ( n >= 0 ) { - char N = (char) n; - std::cout << n << " = " << N ; - } else { - std::cout << n ; - } - std::cout << " optind = " << ::optind + char N = static_cast(n); + std::cout << n << " = " << N; + } else { + std::cout << n ; + } + std::cout << " optind = " << ::optind << " opterr = " << ::opterr << " optopt = " << ::optopt << " optarg = " << Safe(::optarg) @@ -132,12 +132,12 @@ int main(int argc, char** const argv) do { n = Util::getopt(argc,argv,::optstring); if ( n >= 0 ) { - char N = (char) n; - std::cout << n << " = " << N ; - } else { - std::cout << n ; - } - std::cout << " optind = " << Util::optind + char N = static_cast(n); + std::cout << n << " = " << N; + } else { + std::cout << n ; + } + std::cout << " optind = " << Util::optind << " opterr = " << Util::opterr << " optopt = " << Util::optopt << " optarg = " << Safe(Util::optarg) diff --git a/samples/iotest.cpp b/samples/iotest.cpp index bf50b3da..72b228b0 100644 --- a/samples/iotest.cpp +++ b/samples/iotest.cpp @@ -179,7 +179,7 @@ int WriteReadSeek(BasicIo &io) throw Error(Exiv2::kerDataSourceOpenFailed, io.path(), strError()); } IoCloser closer(io); - if ((size_t) io.write((byte*)tester1, (long)size1) != size1) { + if (static_cast(io.write(reinterpret_cast(tester1), static_cast(size1))) != size1) { std::cerr << ": WRS initial write failed\n"; return 2; } @@ -188,13 +188,13 @@ int WriteReadSeek(BasicIo &io) std::cerr << ": WRS size is not " << size1 << "\n"; return 2; } - long backup = (long)size1; + long backup = static_cast(size1); io.seek(-backup, BasicIo::cur); int c = EOF; std::memset(buf, -1, sizeof(buf)); for (int i = 0; (c=io.getb()) != EOF; ++i) { - buf[i] = (byte)c; + buf[i] = static_cast(c); } // Make sure we got the null back @@ -203,7 +203,7 @@ int WriteReadSeek(BasicIo &io) return 3; } - if (strcmp(tester1, (char*)buf) != 0 ) { + if (strcmp(tester1, reinterpret_cast(buf)) != 0) { std::cerr << ": WRS strings don't match 1\n"; return 4; } @@ -232,7 +232,7 @@ int WriteReadSeek(BasicIo &io) } io.seek(insert, BasicIo::beg); - if((size_t)io.write((byte*)tester2, (long)size2) != size2) { + if (static_cast(io.write(reinterpret_cast(tester2), static_cast(size2))) != size2) { std::cerr << ": WRS bad write 1\n"; return 9; } @@ -242,7 +242,7 @@ int WriteReadSeek(BasicIo &io) throw Error(Exiv2::kerDataSourceOpenFailed, io.path(), strError()); } std::memset(buf, -1, sizeof(buf)); - if ((size_t) io.read(buf, sizeof(buf)) != insert + size2) { + if (static_cast(io.read(buf, sizeof(buf))) != insert + size2) { std::cerr << ": WRS something went wrong\n"; return 10; } @@ -253,7 +253,7 @@ int WriteReadSeek(BasicIo &io) return 11; } - if (std::strcmp(expect, (char*)buf) != 0 ) { + if (std::strcmp(expect, reinterpret_cast(buf)) != 0) { std::cerr << ": WRS strings don't match 2\n"; return 12; } diff --git a/samples/mmap-test.cpp b/samples/mmap-test.cpp index c2966dbd..918e0cf6 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 = (long)file.size(); + long size = static_cast(file.size()); DataBuf buf(size); // Read from the memory mapped region memcpy(buf.pData_, pData, buf.size_); diff --git a/samples/tiff-test.cpp b/samples/tiff-test.cpp index 494e5186..8e27551f 100644 --- a/samples/tiff-test.cpp +++ b/samples/tiff-test.cpp @@ -84,7 +84,7 @@ void mini1(const char* path) enforce(wm == wmIntrusive, Exiv2::kerErrorMessage, "encode returned an unexpected value"); std::cout << "Test 3: Wrote non-empty Exif data without original binary data:\n"; exifData.clear(); - ByteOrder bo = ExifParser::decode(exifData, &blob[0], (uint32_t) blob.size()); + ByteOrder bo = ExifParser::decode(exifData, &blob[0], static_cast(blob.size())); enforce(bo == bigEndian, Exiv2::kerErrorMessage, "decode returned an unexpected value"); print(exifData); } diff --git a/src/actions.cpp b/src/actions.cpp index 832947aa..aa7b4fba 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -225,15 +225,15 @@ namespace Action { std::stringstream output(std::stringstream::out|std::stringstream::binary); result = printStructure(output, option, path); if ( result == 0 ) { - size_t size = (long) output.str().size(); - Exiv2::DataBuf iccProfile((long)size); - Exiv2::DataBuf ascii((long)(size * 3 + 1)); + size_t size = static_cast(output.str().size()); + Exiv2::DataBuf iccProfile(static_cast(size)); + Exiv2::DataBuf ascii(static_cast(size * 3 + 1)); ascii.pData_[size * 3] = 0; ::memcpy(iccProfile.pData_,output.str().c_str(),size); - if ( Exiv2::base64encode(iccProfile.pData_,size,(char*)ascii.pData_,size*3) ) { + if (Exiv2::base64encode(iccProfile.pData_, size, reinterpret_cast(ascii.pData_), size * 3)) { long chunk = 60 ; - std::string code = std::string("data:") + std::string((char*)ascii.pData_); - long length = (long) code.size() ; + std::string code = std::string("data:") + std::string(reinterpret_cast(ascii.pData_)); + long length = static_cast(code.size()); for ( long start = 0 ; start < length ; start += chunk ) { long count = (start+chunk) < length ? chunk : length - start ; std::cout << code.substr(start,count) << std::endl; @@ -1039,7 +1039,8 @@ namespace Action { } else { if ( bStdout ) { // -eC- - std::cout.write((const char*)image->iccProfile()->pData_,image->iccProfile()->size_); + std::cout.write(reinterpret_cast(image->iccProfile()->pData_), + image->iccProfile()->size_); } else { if (Params::instance().verbose_) { std::cout << _("Writing iccProfile: ") << target << std::endl; @@ -1172,7 +1173,7 @@ namespace Action { { std::string xmpPacket; for ( long i = 0 ; i < xmpBlob.size_ ; i++ ) { - xmpPacket += (char) xmpBlob.pData_[i]; + xmpPacket += static_cast(xmpBlob.pData_[i]); } Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open(path); assert(image.get() != 0); @@ -1784,7 +1785,7 @@ namespace { { int rc = 1; time_t t = mktime(tm); // interpret tm according to current timezone settings - if (t != (time_t)-1) { + if (t != static_cast(-1)) { rc = 0; actime_ = t; modtime_ = t; @@ -1827,7 +1828,8 @@ namespace { tm->tm_sec = tmp; // Conversions to set remaining fields of the tm structure - if (mktime(tm) == (time_t)-1) return 11; + if (mktime(tm) == static_cast(-1)) + return 11; return 0; } // str2Tm diff --git a/src/basicio.cpp b/src/basicio.cpp index 561101c3..44bbb696 100644 --- a/src/basicio.cpp +++ b/src/basicio.cpp @@ -574,7 +574,7 @@ namespace Exiv2 { { assert(p_->fp_ != 0); if (p_->switchMode(Impl::opWrite) != 0) return 0; - return (long)std::fwrite(data, 1, wcount, p_->fp_); + return static_cast(std::fwrite(data, 1, wcount, p_->fp_)); } long FileIo::write(BasicIo& src) @@ -589,7 +589,7 @@ namespace Exiv2 { long writeCount = 0; long writeTotal = 0; while ((readCount = src.read(buf, sizeof(buf)))) { - writeTotal += writeCount = (long)std::fwrite(buf, 1, readCount, p_->fp_); + writeTotal += writeCount = static_cast(std::fwrite(buf, 1, readCount, p_->fp_)); if (writeCount != readCount) { // try to reset back to where write stopped src.seek(writeCount-readCount, BasicIo::cur); @@ -986,7 +986,8 @@ namespace Exiv2 { DataBuf FileIo::read(long rcount) { assert(p_->fp_ != 0); - if ( (size_t) rcount > size() ) throw Error(kerInvalidMalloc); + if (static_cast(rcount) > size()) + throw Error(kerInvalidMalloc); DataBuf buf(rcount); long readCount = read(buf.pData_, buf.size_); buf.size_ = readCount; @@ -999,7 +1000,7 @@ namespace Exiv2 { if (p_->switchMode(Impl::opRead) != 0) { return 0; } - return (long)std::fread(buf, 1, rcount, p_->fp_); + return static_cast(std::fread(buf, 1, rcount, p_->fp_)); } int FileIo::getb() @@ -1098,7 +1099,7 @@ namespace Exiv2 { void populate (byte* source, size_t num) { size_ = num; - data_ = (byte*)std::malloc(size_); + data_ = static_cast(std::malloc(size_)); type_ = bMemory; std::memcpy(data_, source, size_); } @@ -1151,7 +1152,7 @@ namespace Exiv2 { if (!isMalloced_) { // Minimum size for 1st block long size = EXV_MAX(blockSize * (1 + need / blockSize), size_); - auto data = (byte*)std::malloc(size); + auto data = static_cast(std::malloc(size)); if ( data == NULL ) { throw Error(kerMallocFailed); } @@ -1169,7 +1170,7 @@ namespace Exiv2 { if ( blockSize > maxBlockSize ) blockSize = maxBlockSize ; // Allocate in blocks long want = blockSize * (1 + need / blockSize ); - data_ = (byte*)std::realloc(data_, want); + data_ = static_cast(std::realloc(data_, want)); if ( data_ == NULL ) { throw Error(kerMallocFailed); } @@ -1646,12 +1647,12 @@ namespace Exiv2 { if (blocksMap_[highBlock].isNone()) { std::string data; - getDataByRange( (long) lowBlock, (long) highBlock, data); + getDataByRange(static_cast(lowBlock), static_cast(highBlock), data); rcount = data.length(); if (rcount == 0) { throw Error(kerErrorMessage, "Data By Range is empty. Please check the permission."); } - auto source = (byte*)data.c_str(); + auto source = reinterpret_cast(const_cast(data.c_str())); size_t remain = rcount, totalRead = 0; size_t iBlock = (rcount == size_) ? 0 : lowBlock; @@ -1692,7 +1693,7 @@ namespace Exiv2 { size_t nBlocks = (p_->size_ + p_->blockSize_ - 1) / p_->blockSize_; p_->blocksMap_ = new BlockMap[nBlocks]; p_->isMalloced_ = true; - auto source = (byte*)data.c_str(); + auto source = reinterpret_cast(const_cast(data.c_str())); size_t remain = p_->size_, iBlock = 0, totalRead = 0; while (remain) { size_t allow = EXV_MIN(remain, p_->blockSize_); @@ -1704,7 +1705,7 @@ namespace Exiv2 { } else if (length == 0) { // file is empty throw Error(kerErrorMessage, "the file length is 0"); } else { - p_->size_ = (size_t) length; + p_->size_ = static_cast(length); size_t nBlocks = (p_->size_ + p_->blockSize_ - 1) / p_->blockSize_; p_->blocksMap_ = new BlockMap[nBlocks]; p_->isMalloced_ = true; @@ -1752,7 +1753,7 @@ namespace Exiv2 { size_t i = 0; size_t readCount = 0; size_t blockSize = 0; - auto buf = (byte*)std::malloc(p_->blockSize_); + auto buf = static_cast(std::malloc(p_->blockSize_)); size_t nBlocks = (p_->size_ + p_->blockSize_ - 1) / p_->blockSize_; // find $left @@ -1761,7 +1762,7 @@ namespace Exiv2 { while (blockIndex < nBlocks && !src.eof() && !findDiff) { blockSize = p_->blocksMap_[blockIndex].getSize(); bool isFakeData = p_->blocksMap_[blockIndex].isKnown(); // fake data - readCount = (size_t) src.read(buf, (long) blockSize); + readCount = static_cast(src.read(buf, static_cast(blockSize))); byte* blockData = p_->blocksMap_[blockIndex].getData(); for (i = 0; (i < readCount) && (i < blockSize) && !findDiff; i++) { if ((!isFakeData && buf[i] != blockData[i]) || (isFakeData && buf[i] != 0)) { @@ -1782,7 +1783,7 @@ namespace Exiv2 { findDiff = true; } else { bool isFakeData = p_->blocksMap_[blockIndex].isKnown(); // fake data - readCount = src.read(buf, (long) blockSize); + readCount = src.read(buf, static_cast(blockSize)); byte* blockData = p_->blocksMap_[blockIndex].getData(); for (i = 0; (i < readCount) && (i < blockSize) && !findDiff; i++) { if ((!isFakeData && buf[readCount - i - 1] != blockData[blockSize - i - 1]) || (isFakeData && buf[readCount - i - 1] != 0)) { @@ -1793,22 +1794,23 @@ namespace Exiv2 { } } blockIndex--; - blockSize = (long)p_->blocksMap_[blockIndex].getSize(); + blockSize = static_cast(p_->blocksMap_[blockIndex].getSize()); } // free buf if (buf) std::free(buf); // submit to the remote machine. - long dataSize = (long) (src.size() - left - right); + long dataSize = static_cast(src.size() - left - right); if (dataSize > 0) { - auto data = (byte*)std::malloc(dataSize); + auto data = static_cast(std::malloc(dataSize)); src.seek(left, BasicIo::beg); src.read(data, dataSize); - p_->writeRemote(data, (size_t)dataSize, (long)left, (long) (p_->size_ - right)); + p_->writeRemote(data, static_cast(dataSize), static_cast(left), + static_cast(p_->size_ - right)); if (data) std::free(data); } - return (long) src.size(); + return static_cast(src.size()); } int RemoteIo::putb(byte /*unused data*/) @@ -1836,7 +1838,7 @@ namespace Exiv2 { // connect to the remote machine & populate the blocks just in time. p_->populateBlocks(lowBlock, highBlock); - auto fakeData = (byte*)std::calloc(p_->blockSize_, sizeof(byte)); + auto fakeData = static_cast(std::calloc(p_->blockSize_, sizeof(byte))); if (!fakeData) { throw Error(kerErrorMessage, "Unable to allocate data"); } @@ -1856,16 +1858,16 @@ namespace Exiv2 { if (fakeData) std::free(fakeData); - p_->idx_ += (long) totalRead; - p_->eof_ = (p_->idx_ == (long) p_->size_); + p_->idx_ += static_cast(totalRead); + p_->eof_ = (p_->idx_ == static_cast(p_->size_)); - return (long) totalRead; + return static_cast(totalRead); } int RemoteIo::getb() { assert(p_->isMalloced_); - if (p_->idx_ == (long)p_->size_) { + if (p_->idx_ == static_cast(p_->size_)) { p_->eof_ = true; return EOF; } @@ -1919,8 +1921,9 @@ namespace Exiv2 { // #1198. Don't return 1 when asked to seek past EOF. Stay calm and set eof_ // if (newIdx < 0 || newIdx > (long) p_->size_) return 1; p_->idx_ = newIdx; - p_->eof_ = newIdx > (long) p_->size_; - if ( p_->idx_ > (long) p_->size_ ) p_->idx_= (long) p_->size_; + p_->eof_ = newIdx > static_cast(p_->size_); + if (p_->idx_ > static_cast(p_->size_)) + p_->idx_ = static_cast(p_->size_); return 0; } #endif @@ -1960,7 +1963,7 @@ namespace Exiv2 { size_t RemoteIo::size() const { - return (long) p_->size_; + return static_cast(p_->size_); } bool RemoteIo::isopen() const @@ -2291,7 +2294,7 @@ namespace Exiv2 { // get length double temp; curl_easy_getinfo(curl_, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &temp); // return -1 if unknown - return (long) temp; + return static_cast(temp); } void CurlIo::CurlImpl::getDataByRange(long lowBlock, long highBlock, std::string& response) diff --git a/src/bmffimage.cpp b/src/bmffimage.cpp index 804800eb..43ed484d 100644 --- a/src/bmffimage.cpp +++ b/src/bmffimage.cpp @@ -111,7 +111,7 @@ namespace Exiv2 std::string BmffImage::toAscii(long n) { - const auto p = (const char*)&n; + const auto p = reinterpret_cast(&n); std::string result; for (int i = 0; i < 4; i++) { char c = p[isBigEndianPlatform() ? i : (3 - i)]; @@ -189,8 +189,8 @@ namespace Exiv2 long BmffImage::boxHandler(std::ostream& out /* = std::cout*/ , Exiv2::PrintStructureOption option /* = kpsNone */,int depth /* =0 */) { - long result = (long)io_->size(); - long address = (long)io_->tell(); + long result = static_cast(io_->size()); + long address = io_->tell(); // never visit a box twice! if ( depth == 0 ) visits_.clear(); if (visits_.find(address) != visits_.end() || visits_.size() > visits_max_) { @@ -204,11 +204,11 @@ namespace Exiv2 #endif BmffBoxHeader box = {0, 0}; - if (io_->read((byte*)&box, sizeof(box)) != sizeof(box)) + if (io_->read(reinterpret_cast(&box), sizeof(box)) != sizeof(box)) return result; - box.length = getLong((byte*)&box.length, endian_); - box.type = getLong((byte*)&box.type, endian_); + box.length = getLong(reinterpret_cast(&box.length), endian_); + box.type = getLong(reinterpret_cast(&box.type), endian_); bool bLF = true; if ( bTrace ) { @@ -224,13 +224,13 @@ namespace Exiv2 // Check that `sz` is safe to cast to `long`. enforce(sz <= static_cast(std::numeric_limits::max()), Exiv2::kerCorruptedMetadata); - result = (long) sz; + result = static_cast(sz); // sanity check - if (result < 8 || result > (long)io_->size() - address) { - result = (long)io_->size(); + if (result < 8 || result > static_cast(io_->size()) - address) { + result = static_cast(io_->size()); box.length = result; } else { - box.length = (long) (io_->size() - address); + box.length = static_cast(io_->size() - address); } } @@ -248,7 +248,7 @@ namespace Exiv2 if (fullBox(box.type)) { enforce(data.size_ - skip >= 4, Exiv2::kerCorruptedMetadata); flags = getLong(data.pData_ + skip, endian_); // version/flags - version = (int8_t)flags >> 24; + version = static_cast(flags) >> 24; version &= 0x00ffffff; skip += 4; } @@ -288,7 +288,7 @@ namespace Exiv2 /* getShort(data.pData_+skip,endian_) ; */ skip += 2; // protection std::string id; // Check that the string has a '\0' terminator. - const char* str = (const char*)data.pData_ + skip; + const char* str = reinterpret_cast(data.pData_) + skip; const auto maxlen = static_cast(data.size_ - skip); enforce(strnlen(str, maxlen) < maxlen, Exiv2::kerCorruptedMetadata); std::string name(str); @@ -408,12 +408,14 @@ namespace Exiv2 // 12.1.5.2 case TAG_colr: { - if ( data.size_ >= (long) (skip+4+sizeof(box)) ) { // .____.HLino..__mntrR 2 0 0 0 0 12 72 76 105 110 111 2 16 ... + if (data.size_ >= + static_cast(skip + 4 + + sizeof(box))) { // .____.HLino..__mntrR 2 0 0 0 0 12 72 76 105 110 111 2 16 ... // https://www.ics.uci.edu/~dan/class/267/papers/jpeg2000.pdf uint8_t meth = data.pData_[skip+0]; uint8_t prec = data.pData_[skip+1]; uint8_t approx = data.pData_[skip+2]; - std::string colour_type = std::string((char*)data.pData_,4) ; + std::string colour_type = std::string(reinterpret_cast(data.pData_), 4); skip+=4; if ( colour_type == "rICC" || colour_type == "prof" ) { DataBuf profile(data.pData_+skip,data.size_-skip); @@ -527,7 +529,7 @@ namespace Exiv2 if ( io_->error() ) throw Error(kerFailedToReadImageData); try { - Exiv2::XmpParser::decode(xmpData(),std::string((char*)xmp.pData_)); + Exiv2::XmpParser::decode(xmpData(), std::string(reinterpret_cast(xmp.pData_))); } catch (...) { throw Error(kerFailedToReadImageData); } @@ -567,7 +569,7 @@ namespace Exiv2 exifID_ = unknownID_; long address = 0; - while (address < (long)io_->size()) { + while (address < static_cast(io_->size())) { io_->seek(address, BasicIo::beg); address = boxHandler(std::cout,kpsNone); } @@ -582,7 +584,7 @@ namespace Exiv2 default: break; // do nothing case kpsIccProfile : { - out.write((const char*)iccProfile_.pData_,iccProfile_.size_); + out.write(reinterpret_cast(iccProfile_.pData_), iccProfile_.size_); } break; #ifdef EXV_HAVE_XMP_TOOLKIT @@ -600,7 +602,7 @@ namespace Exiv2 IoCloser closer(*io_); long address = 0; - while (address < (long)io_->size()) { + while (address < static_cast(io_->size())) { io_->seek(address, BasicIo::beg); address = boxHandler(out,option,depth); } diff --git a/src/canonmn_int.cpp b/src/canonmn_int.cpp index fe2c4c05..62db09c2 100644 --- a/src/canonmn_int.cpp +++ b/src/canonmn_int.cpp @@ -73,360 +73,359 @@ namespace Exiv2 { //! ModelId, tag 0x0010 constexpr TagDetails canonModelId[] = { - { (long int)0x00000811, "EOS M6 Mark II"}, - { (long int)0x00000804, "Powershot G5 X Mark II"}, - { (long int)0x00000805, "PowerShot SX70 HS"}, - { (long int)0x00000808, "PowerShot G7 X Mark III"}, - { (long int)0x00000812, "EOS M200"}, - { (long int)0x1010000, "PowerShot A30" }, - { (long int)0x1040000, "PowerShot S300 / Digital IXUS 300 / IXY Digital 300" }, - { (long int)0x1060000, "PowerShot A20" }, - { (long int)0x1080000, "PowerShot A10" }, - { (long int)0x1090000, "PowerShot S110 / Digital IXUS v / IXY Digital 200" }, - { (long int)0x1100000, "PowerShot G2" }, - { (long int)0x1110000, "PowerShot S40" }, - { (long int)0x1120000, "PowerShot S30" }, - { (long int)0x1130000, "PowerShot A40" }, - { (long int)0x1140000, "EOS D30" }, - { (long int)0x1150000, "PowerShot A100" }, - { (long int)0x1160000, "PowerShot S200 / Digital IXUS v2 / IXY Digital 200a" }, - { (long int)0x1170000, "PowerShot A200" }, - { (long int)0x1180000, "PowerShot S330 / Digital IXUS 330 / IXY Digital 300a" }, - { (long int)0x1190000, "PowerShot G3" }, - { (long int)0x1210000, "PowerShot S45" }, - { (long int)0x1230000, "PowerShot SD100 / Digital IXUS II / IXY Digital 30" }, - { (long int)0x1240000, "PowerShot S230 / Digital IXUS v3 / IXY Digital 320" }, - { (long int)0x1250000, "PowerShot A70" }, - { (long int)0x1260000, "PowerShot A60" }, - { (long int)0x1270000, "PowerShot S400 / Digital IXUS 400 / IXY Digital 400" }, - { (long int)0x1290000, "PowerShot G5" }, - { (long int)0x1300000, "PowerShot A300" }, - { (long int)0x1310000, "PowerShot S50" }, - { (long int)0x1340000, "PowerShot A80" }, - { (long int)0x1350000, "PowerShot SD10 / Digital IXUS i / IXY Digital L" }, - { (long int)0x1360000, "PowerShot S1 IS" }, - { (long int)0x1370000, "PowerShot Pro1" }, - { (long int)0x1380000, "PowerShot S70" }, - { (long int)0x1390000, "PowerShot S60" }, - { (long int)0x1400000, "PowerShot G6" }, - { (long int)0x1410000, "PowerShot S500 / Digital IXUS 500 / IXY Digital 500" }, - { (long int)0x1420000, "PowerShot A75" }, - { (long int)0x1440000, "PowerShot SD110 / Digital IXUS IIs / IXY Digital 30a" }, - { (long int)0x1450000, "PowerShot A400" }, - { (long int)0x1470000, "PowerShot A310" }, - { (long int)0x1490000, "PowerShot A85" }, - { (long int)0x1520000, "PowerShot S410 / Digital IXUS 430 / IXY Digital 450" }, - { (long int)0x1530000, "PowerShot A95" }, - { (long int)0x1540000, "PowerShot SD300 / Digital IXUS 40 / IXY Digital 50" }, - { (long int)0x1550000, "PowerShot SD200 / Digital IXUS 30 / IXY Digital 40" }, - { (long int)0x1560000, "PowerShot A520" }, - { (long int)0x1570000, "PowerShot A510" }, - { (long int)0x1590000, "PowerShot SD20 / Digital IXUS i5 / IXY Digital L2" }, - { (long int)0x1640000, "PowerShot S2 IS" }, - { (long int)0x1650000, "PowerShot SD430 / Digital IXUS Wireless / IXY Digital Wireless" }, - { (long int)0x1660000, "PowerShot SD500 / Digital IXUS 700 / IXY Digital 600" }, - { (long int)0x1668000, "EOS D60" }, - { (long int)0x1700000, "PowerShot SD30 / Digital IXUS i Zoom / IXY Digital L3" }, - { (long int)0x1740000, "PowerShot A430" }, - { (long int)0x1750000, "PowerShot A410" }, - { (long int)0x1760000, "PowerShot S80" }, - { (long int)0x1780000, "PowerShot A620" }, - { (long int)0x1790000, "PowerShot A610" }, - { (long int)0x1800000, "PowerShot SD630 / Digital IXUS 65 / IXY Digital 80" }, - { (long int)0x1810000, "PowerShot SD450 / Digital IXUS 55 / IXY Digital 60" }, - { (long int)0x1820000, "PowerShot TX1" }, - { (long int)0x1870000, "PowerShot SD400 / Digital IXUS 50 / IXY Digital 55" }, - { (long int)0x1880000, "PowerShot A420" }, - { (long int)0x1890000, "PowerShot SD900 / Digital IXUS 900 Ti / IXY Digital 1000" }, - { (long int)0x1900000, "PowerShot SD550 / Digital IXUS 750 / IXY Digital 700" }, - { (long int)0x1920000, "PowerShot A700" }, - { (long int)0x1940000, "PowerShot SD700 IS / Digital IXUS 800 IS / IXY Digital 800 IS" }, - { (long int)0x1950000, "PowerShot S3 IS" }, - { (long int)0x1960000, "PowerShot A540" }, - { (long int)0x1970000, "PowerShot SD600 / Digital IXUS 60 / IXY Digital 70" }, - { (long int)0x1980000, "PowerShot G7" }, - { (long int)0x1990000, "PowerShot A530" }, - { (long int)0x2000000, "PowerShot SD800 IS / Digital IXUS 850 IS / IXY Digital 900 IS" }, - { (long int)0x2010000, "PowerShot SD40 / Digital IXUS i7 / IXY Digital L4" }, - { (long int)0x2020000, "PowerShot A710 IS" }, - { (long int)0x2030000, "PowerShot A640" }, - { (long int)0x2040000, "PowerShot A630" }, - { (long int)0x2090000, "PowerShot S5 IS" }, - { (long int)0x2100000, "PowerShot A460" }, - { (long int)0x2120000, "PowerShot SD850 IS / Digital IXUS 950 IS / IXY Digital 810 IS" }, - { (long int)0x2130000, "PowerShot A570 IS" }, - { (long int)0x2140000, "PowerShot A560" }, - { (long int)0x2150000, "PowerShot SD750 / Digital IXUS 75 / IXY Digital 90" }, - { (long int)0x2160000, "PowerShot SD1000 / Digital IXUS 70 / IXY Digital 10" }, - { (long int)0x2180000, "PowerShot A550" }, - { (long int)0x2190000, "PowerShot A450" }, - { (long int)0x2230000, "PowerShot G9" }, - { (long int)0x2240000, "PowerShot A650 IS" }, - { (long int)0x2260000, "PowerShot A720 IS" }, - { (long int)0x2290000, "PowerShot SX100 IS" }, - { (long int)0x2300000, "PowerShot SD950 IS / Digital IXUS 960 IS / IXY Digital 2000 IS" }, - { (long int)0x2310000, "PowerShot SD870 IS / Digital IXUS 860 IS / IXY Digital 910 IS" }, - { (long int)0x2320000, "PowerShot SD890 IS / Digital IXUS 970 IS / IXY Digital 820 IS" }, - { (long int)0x2360000, "PowerShot SD790 IS / Digital IXUS 90 IS / IXY Digital 95 IS" }, - { (long int)0x2370000, "PowerShot SD770 IS / Digital IXUS 85 IS / IXY Digital 25 IS" }, - { (long int)0x2380000, "PowerShot A590 IS" }, - { (long int)0x2390000, "PowerShot A580" }, - { (long int)0x2420000, "PowerShot A470" }, - { (long int)0x2430000, "PowerShot SD1100 IS / Digital IXUS 80 IS / IXY Digital 20 IS" }, - { (long int)0x2460000, "PowerShot SX1 IS" }, - { (long int)0x2470000, "PowerShot SX10 IS" }, - { (long int)0x2480000, "PowerShot A1000 IS" }, - { (long int)0x2490000, "PowerShot G10" }, - { (long int)0x2510000, "PowerShot A2000 IS" }, - { (long int)0x2520000, "PowerShot SX110 IS" }, - { (long int)0x2530000, "PowerShot SD990 IS / Digital IXUS 980 IS / IXY Digital 3000 IS" }, - { (long int)0x2540000, "PowerShot SD880 IS / Digital IXUS 870 IS / IXY Digital 920 IS" }, - { (long int)0x2550000, "PowerShot E1" }, - { (long int)0x2560000, "PowerShot D10" }, - { (long int)0x2570000, "PowerShot SD960 IS / Digital IXUS 110 IS / IXY Digital 510 IS" }, - { (long int)0x2580000, "PowerShot A2100 IS" }, - { (long int)0x2590000, "PowerShot A480" }, - { (long int)0x2600000, "PowerShot SX200 IS" }, - { (long int)0x2610000, "PowerShot SD970 IS / Digital IXUS 990 IS / IXY Digital 830 IS" }, - { (long int)0x2620000, "PowerShot SD780 IS / Digital IXUS 100 IS / IXY Digital 210 IS" }, - { (long int)0x2630000, "PowerShot A1100 IS" }, - { (long int)0x2640000, "PowerShot SD1200 IS / Digital IXUS 95 IS / IXY Digital 110 IS" }, - { (long int)0x2700000, "PowerShot G11" }, - { (long int)0x2710000, "PowerShot SX120 IS" }, - { (long int)0x2720000, "PowerShot S90" }, - { (long int)0x2750000, "PowerShot SX20 IS" }, - { (long int)0x2760000, "PowerShot SD980 IS / Digital IXUS 200 IS / IXY Digital 930 IS" }, - { (long int)0x2770000, "PowerShot SD940 IS / Digital IXUS 120 IS / IXY Digital 220 IS" }, - { (long int)0x2800000, "PowerShot A495" }, - { (long int)0x2810000, "PowerShot A490" }, - { (long int)0x2820000, "PowerShot A3100/A3150 IS" }, - { (long int)0x2830000, "PowerShot A3000 IS" }, - { (long int)0x2840000, "PowerShot SD1400 IS / IXUS 130 / IXY 400F" }, - { (long int)0x2850000, "PowerShot SD1300 IS / IXUS 105 / IXY 200F" }, - { (long int)0x2860000, "PowerShot SD3500 IS / IXUS 210 / IXY 10S" }, - { (long int)0x2870000, "PowerShot SX210 IS" }, - { (long int)0x2880000, "PowerShot SD4000 IS / IXUS 300 HS / IXY 30S" }, - { (long int)0x2890000, "PowerShot SD4500 IS / IXUS 1000 HS / IXY 50S" }, - { (long int)0x2920000, "PowerShot G12" }, - { (long int)0x2930000, "PowerShot SX30 IS" }, - { (long int)0x2940000, "PowerShot SX130 IS" }, - { (long int)0x2950000, "PowerShot S95" }, - { (long int)0x2980000, "PowerShot A3300 IS" }, - { (long int)0x2990000, "PowerShot A3200 IS" }, - { (long int)0x3000000, "PowerShot ELPH 500 HS / IXUS 310 HS / IXY 31S" }, - { (long int)0x3010000, "PowerShot Pro90 IS" }, - { (long int)0x3010001, "PowerShot A800" }, - { (long int)0x3020000, "PowerShot ELPH 100 HS / IXUS 115 HS / IXY 210F" }, - { (long int)0x3030000, "PowerShot SX230 HS" }, - { (long int)0x3040000, "PowerShot ELPH 300 HS / IXUS 220 HS / IXY 410F" }, - { (long int)0x3050000, "PowerShot A2200" }, - { (long int)0x3060000, "PowerShot A1200" }, - { (long int)0x3070000, "PowerShot SX220 HS" }, - { (long int)0x3080000, "PowerShot G1 X" }, - { (long int)0x3090000, "PowerShot SX150 IS" }, - { (long int)0x3100000, "PowerShot ELPH 510 HS / IXUS 1100 HS / IXY 51S" }, - { (long int)0x3110000, "PowerShot S100 (new)" }, - { (long int)0x3130000, "PowerShot SX40 HS" }, - { (long int)0x3120000, "PowerShot ELPH 310 HS / IXUS 230 HS / IXY 600F" }, - { (long int)0x3140000, "IXY 32S" }, - { (long int)0x3160000, "PowerShot A1300" }, - { (long int)0x3170000, "PowerShot A810" }, - { (long int)0x3180000, "PowerShot ELPH 320 HS / IXUS 240 HS / IXY 420F" }, - { (long int)0x3190000, "PowerShot ELPH 110 HS / IXUS 125 HS / IXY 220F" }, - { (long int)0x3200000, "PowerShot D20" }, - { (long int)0x3210000, "PowerShot A4000 IS" }, - { (long int)0x3220000, "PowerShot SX260 HS" }, - { (long int)0x3230000, "PowerShot SX240 HS" }, - { (long int)0x3240000, "PowerShot ELPH 530 HS / IXUS 510 HS / IXY 1" }, - { (long int)0x3250000, "PowerShot ELPH 520 HS / IXUS 500 HS / IXY 3" }, - { (long int)0x3260000, "PowerShot A3400 IS" }, - { (long int)0x3270000, "PowerShot A2400 IS" }, - { (long int)0x3280000, "PowerShot A2300" }, - { (long int)0x3320000, "PowerShot S100V" }, - { (long int)0x3330000, "PowerShot G15" }, - { (long int)0x3340000, "PowerShot SX50 HS" }, - { (long int)0x3350000, "PowerShot SX160 IS" }, - { (long int)0x3360000, "PowerShot S110 (new)" }, - { (long int)0x3370000, "PowerShot SX500 IS" }, - { (long int)0x3380000, "PowerShot N" }, - { (long int)0x3390000, "IXUS 245 HS / IXY 430F" }, - { (long int)0x3400000, "PowerShot SX280 HS" }, - { (long int)0x3410000, "PowerShot SX270 HS" }, - { (long int)0x3420000, "PowerShot A3500 IS" }, - { (long int)0x3430000, "PowerShot A2600" }, - { (long int)0x3440000, "PowerShot SX275 HS" }, - { (long int)0x3450000, "PowerShot A1400" }, - { (long int)0x3460000, "PowerShot ELPH 130 IS / IXUS 140 / IXY 110F" }, - { (long int)0x3470000, "PowerShot ELPH 115/120 IS / IXUS 132/135 / IXY 90F/100F" }, - { (long int)0x3490000, "PowerShot ELPH 330 HS / IXUS 255 HS / IXY 610F" }, - { (long int)0x3510000, "PowerShot A2500" }, - { (long int)0x3540000, "PowerShot G16" }, - { (long int)0x3550000, "PowerShot S120" }, - { (long int)0x3560000, "PowerShot SX170 IS" }, - { (long int)0x3580000, "PowerShot SX510 HS" }, - { (long int)0x3590000, "PowerShot S200 (new)" }, - { (long int)0x3600000, "IXY 620F" }, - { (long int)0x3610000, "PowerShot N100" }, - { (long int)0x3640000, "PowerShot G1 X Mark II" }, - { (long int)0x3650000, "PowerShot D30" }, - { (long int)0x3660000, "PowerShot SX700 HS" }, - { (long int)0x3670000, "PowerShot SX600 HS" }, - { (long int)0x3680000, "PowerShot ELPH 140 IS / IXUS 150 / IXY 130" }, - { (long int)0x3690000, "PowerShot ELPH 135 / IXUS 145 / IXY 120" }, - { (long int)0x3700000, "PowerShot ELPH 340 HS / IXUS 265 HS / IXY 630" }, - { (long int)0x3710000, "PowerShot ELPH 150 IS / IXUS 155 / IXY 140" }, - { (long int)0x3740000, "EOS M3" }, - { (long int)0x3750000, "PowerShot SX60 HS" }, - { (long int)0x3760000, "PowerShot SX520 HS" }, - { (long int)0x3770000, "PowerShot SX400 IS" }, - { (long int)0x3780000, "PowerShot G7 X" }, - { (long int)0x3790000, "PowerShot N2" }, - { (long int)0x3800000, "PowerShot SX530 HS" }, - { (long int)0x3820000, "PowerShot SX710 HS" }, - { (long int)0x3830000, "PowerShot SX610 HS" }, - { (long int)0x3840000, "EOS M10" }, - { (long int)0x3850000, "PowerShot G3 X" }, - { (long int)0x3860000, "PowerShot ELPH 165 HS / IXUS 165 / IXY 160" }, - { (long int)0x3870000, "PowerShot ELPH 160 / IXUS 160" }, - { (long int)0x3880000, "PowerShot ELPH 350 HS / IXUS 275 HS / IXY 640" }, - { (long int)0x3890000, "PowerShot ELPH 170 IS / IXUS 170" }, - { (long int)0x3910000, "PowerShot SX410 IS" }, - { (long int)0x3930000, "PowerShot G9 X" }, - { (long int)0x3940000, "EOS M5" }, - { (long int)0x3950000, "PowerShot G5 X" }, - { (long int)0x3970000, "PowerShot G7 X Mark II" }, - { (long int)0x3980000, "EOS M100" }, - { (long int)0x3990000, "PowerShot ELPH 360 HS / IXUS 285 HS / IXY 650" }, - { (long int)0x4010000, "PowerShot SX540 HS" }, - { (long int)0x4020000, "PowerShot SX420 IS" }, - { (long int)0x4030000, "PowerShot ELPH 190 IS / IXUS 180 / IXY 190" }, - { (long int)0x4040000, "PowerShot G1" }, - { (long int)0x4040001, "PowerShot ELPH 180 IS / IXUS 175 / IXY 180" }, - { (long int)0x4050000, "PowerShot SX720 HS" }, - { (long int)0x4060000, "PowerShot SX620 HS" }, - { (long int)0x4070000, "EOS M6" }, - { (long int)0x4100000, "PowerShot G9 X Mark II" }, - { (long int)0x412, "EOS M50 / Kiss M" }, - { (long int)0x4150000, "PowerShot ELPH 185 / IXUS 185 / IXY 200" }, - { (long int)0x4160000, "PowerShot SX430 IS" }, - { (long int)0x4170000, "PowerShot SX730 HS" }, - { (long int)0x4180000, "PowerShot G1 X Mark III" }, - { (long int)0x6040000, "PowerShot S100 / Digital IXUS / IXY Digital" }, - { (long int)0x801, "PowerShot SX740 HS" }, - { (long int)0x804, "PowerShot G5 X Mark II" }, - { (long int)0x805, "PowerShot SX70 HS" }, - { (long int)0x808, "PowerShot G7 X Mark III" }, - { (long int)0x811, "EOS M6 Mark II" }, - { (long int)0x812, "EOS M200" }, - { (long int)0x4007d673, "DC19/DC21/DC22" }, - { (long int)0x4007d674, "XH A1" }, - { (long int)0x4007d675, "HV10" }, - { (long int)0x4007d676, "MD130/MD140/MD150/MD160/ZR850" }, - { (long int)0x4007d777, "DC50" }, - { (long int)0x4007d778, "HV20" }, - { (long int)0x4007d779, "DC211" }, - { (long int)0x4007d77a, "HG10" }, - { (long int)0x4007d77b, "HR10" }, - { (long int)0x4007d77d, "MD255/ZR950" }, - { (long int)0x4007d81c, "HF11" }, - { (long int)0x4007d878, "HV30" }, - { (long int)0x4007d87c, "XH A1S" }, - { (long int)0x4007d87e, "DC301/DC310/DC311/DC320/DC330" }, - { (long int)0x4007d87f, "FS100" }, - { (long int)0x4007d880, "HF10" }, - { (long int)0x4007d882, "HG20/HG21" }, - { (long int)0x4007d925, "HF21" }, - { (long int)0x4007d926, "HF S11" }, - { (long int)0x4007d978, "HV40" }, - { (long int)0x4007d987, "DC410/DC411/DC420" }, - { (long int)0x4007d988, "FS19/FS20/FS21/FS22/FS200" }, - { (long int)0x4007d989, "HF20/HF200" }, - { (long int)0x4007d98a, "HF S10/S100" }, - { (long int)0x4007da8e, "HF R10/R16/R17/R18/R100/R106" }, - { (long int)0x4007da8f, "HF M30/M31/M36/M300/M306" }, - { (long int)0x4007da90, "HF S20/S21/S200" }, - { (long int)0x4007da92, "FS31/FS36/FS37/FS300/FS305/FS306/FS307" }, - { (long int)0x4007dca0, "EOS C300" }, - { (long int)0x4007dda9, "HF G25" }, - { (long int)0x4007dfb4, "XC10" }, - { (long int)0x4007e1c3, "EOS C200" }, - { (long int)0x80000001, "EOS-1D" }, - { (long int)0x80000167, "EOS-1DS" }, - { (long int)0x80000168, "EOS 10D" }, - { (long int)0x80000169, "EOS-1D Mark III" }, - { (long int)0x80000170, "EOS Digital Rebel / 300D / Kiss Digital" }, - { (long int)0x80000174, "EOS-1D Mark II" }, - { (long int)0x80000175, "EOS 20D" }, - { (long int)0x80000176, "EOS Digital Rebel XSi / 450D / Kiss X2" }, - { (long int)0x80000188, "EOS-1Ds Mark II" }, - { (long int)0x80000189, "EOS Digital Rebel XT / 350D / Kiss Digital N" }, - { (long int)0x80000190, "EOS 40D" }, - { (long int)0x80000213, "EOS 5D" }, - { (long int)0x80000215, "EOS-1Ds Mark III" }, - { (long int)0x80000218, "EOS 5D Mark II" }, - { (long int)0x80000219, "WFT-E1" }, - { (long int)0x80000232, "EOS-1D Mark II N" }, - { (long int)0x80000234, "EOS 30D" }, - { (long int)0x80000236, "EOS Digital Rebel XTi / 400D / Kiss Digital X" }, - { (long int)0x80000241, "WFT-E2" }, - { (long int)0x80000246, "WFT-E3" }, - { (long int)0x80000250, "EOS 7D" }, - { (long int)0x80000252, "EOS Rebel T1i / 500D / Kiss X3" }, - { (long int)0x80000254, "EOS Rebel XS / 1000D / Kiss F" }, - { (long int)0x80000261, "EOS 50D" }, - { (long int)0x80000269, "EOS-1D X" }, - { (long int)0x80000270, "EOS Rebel T2i / 550D / Kiss X4" }, - { (long int)0x80000271, "WFT-E4" }, - { (long int)0x80000273, "WFT-E5" }, - { (long int)0x80000281, "EOS-1D Mark IV" }, - { (long int)0x80000285, "EOS 5D Mark III" }, - { (long int)0x80000286, "EOS Rebel T3i / 600D / Kiss X5" }, - { (long int)0x80000287, "EOS 60D" }, - { (long int)0x80000288, "EOS Rebel T3 / 1100D / Kiss X50" }, - { (long int)0x80000289, "EOS 7D Mark II" }, - { (long int)0x80000297, "WFT-E2 II" }, - { (long int)0x80000298, "WFT-E4 II" }, - { (long int)0x80000301, "EOS Rebel T4i / 650D / Kiss X6i" }, - { (long int)0x80000302, "EOS 6D" }, - { (long int)0x80000324, "EOS-1D C" }, - { (long int)0x80000325, "EOS 70D" }, - { (long int)0x80000326, "EOS Rebel T5i / 700D / Kiss X7i" }, - { (long int)0x80000327, "EOS Rebel T5 / 1200D / Kiss X70 / Hi" }, - { (long int)0x80000328, "EOS-1D X MARK II" }, - { (long int)0x80000331, "EOS M" }, - { (long int)0x80000350, "EOS 80D" }, - { (long int)0x80000355, "EOS M2" }, - { (long int)0x80000346, "EOS Rebel SL1 / 100D / Kiss X7" }, - { (long int)0x80000347, "EOS Rebel T6s / 760D / 8000D" }, - { (long int)0x80000349, "EOS 5D Mark IV" }, - { (long int)0x80000382, "EOS 5DS" }, - { (long int)0x80000393, "EOS Rebel T6i / 750D / Kiss X8i" }, - { (long int)0x80000401, "EOS 5DS R" }, - { (long int)0x80000404, "EOS Rebel T6 / 1300D / Kiss X80" }, - { (long int)0x80000405, "EOS Rebel T7i / 800D / Kiss X9i" }, - { (long int)0x80000406, "EOS 6D Mark II" }, - { (long int)0x80000408, "EOS 77D / 9000D" }, - { (long int)0x80000417, "EOS Rebel SL2 / 200D / Kiss X9" }, - { (long int)0x80000421, "EOS R5" }, - { (long int)0x80000422, "EOS Rebel T100 / 4000D / 3000D" }, - { (long int)0x80000424, "EOS R" }, - { (long int)0x80000428, "EOS-1D X Mark III" }, - { (long int)0x80000432, "EOS Rebel T7 / 2000D / 1500D / Kiss X90" }, - { (long int)0x80000433, "EOS RP" }, - { (long int)0x80000435, "EOS 850D / T8i / Kiss X10i" }, - { (long int)0x80000436, "EOS SL3 / 250D / Kiss X10" }, - { (long int)0x80000437, "EOS 90D" }, - { (long int)0x80000453, "EOS R6" }, + { static_cast(0x00000811), "EOS M6 Mark II"}, + { static_cast(0x00000804), "Powershot G5 X Mark II"}, + { static_cast(0x00000805), "PowerShot SX70 HS"}, + { static_cast(0x00000808), "PowerShot G7 X Mark III"}, + { static_cast(0x00000812), "EOS M200"}, + { static_cast(0x1010000), "PowerShot A30" }, + { static_cast(0x1040000), "PowerShot S300 / Digital IXUS 300 / IXY Digital 300" }, + { static_cast(0x1060000), "PowerShot A20" }, + { static_cast(0x1080000), "PowerShot A10" }, + { static_cast(0x1090000), "PowerShot S110 / Digital IXUS v / IXY Digital 200" }, + { static_cast(0x1100000), "PowerShot G2" }, + { static_cast(0x1110000), "PowerShot S40" }, + { static_cast(0x1120000), "PowerShot S30" }, + { static_cast(0x1130000), "PowerShot A40" }, + { static_cast(0x1140000), "EOS D30" }, + { static_cast(0x1150000), "PowerShot A100" }, + { static_cast(0x1160000), "PowerShot S200 / Digital IXUS v2 / IXY Digital 200a" }, + { static_cast(0x1170000), "PowerShot A200" }, + { static_cast(0x1180000), "PowerShot S330 / Digital IXUS 330 / IXY Digital 300a" }, + { static_cast(0x1190000), "PowerShot G3" }, + { static_cast(0x1210000), "PowerShot S45" }, + { static_cast(0x1230000), "PowerShot SD100 / Digital IXUS II / IXY Digital 30" }, + { static_cast(0x1240000), "PowerShot S230 / Digital IXUS v3 / IXY Digital 320" }, + { static_cast(0x1250000), "PowerShot A70" }, + { static_cast(0x1260000), "PowerShot A60" }, + { static_cast(0x1270000), "PowerShot S400 / Digital IXUS 400 / IXY Digital 400" }, + { static_cast(0x1290000), "PowerShot G5" }, + { static_cast(0x1300000), "PowerShot A300" }, + { static_cast(0x1310000), "PowerShot S50" }, + { static_cast(0x1340000), "PowerShot A80" }, + { static_cast(0x1350000), "PowerShot SD10 / Digital IXUS i / IXY Digital L" }, + { static_cast(0x1360000), "PowerShot S1 IS" }, + { static_cast(0x1370000), "PowerShot Pro1" }, + { static_cast(0x1380000), "PowerShot S70" }, + { static_cast(0x1390000), "PowerShot S60" }, + { static_cast(0x1400000), "PowerShot G6" }, + { static_cast(0x1410000), "PowerShot S500 / Digital IXUS 500 / IXY Digital 500" }, + { static_cast(0x1420000), "PowerShot A75" }, + { static_cast(0x1440000), "PowerShot SD110 / Digital IXUS IIs / IXY Digital 30a" }, + { static_cast(0x1450000), "PowerShot A400" }, + { static_cast(0x1470000), "PowerShot A310" }, + { static_cast(0x1490000), "PowerShot A85" }, + { static_cast(0x1520000), "PowerShot S410 / Digital IXUS 430 / IXY Digital 450" }, + { static_cast(0x1530000), "PowerShot A95" }, + { static_cast(0x1540000), "PowerShot SD300 / Digital IXUS 40 / IXY Digital 50" }, + { static_cast(0x1550000), "PowerShot SD200 / Digital IXUS 30 / IXY Digital 40" }, + { static_cast(0x1560000), "PowerShot A520" }, + { static_cast(0x1570000), "PowerShot A510" }, + { static_cast(0x1590000), "PowerShot SD20 / Digital IXUS i5 / IXY Digital L2" }, + { static_cast(0x1640000), "PowerShot S2 IS" }, + { static_cast(0x1650000), "PowerShot SD430 / Digital IXUS Wireless / IXY Digital Wireless" }, + { static_cast(0x1660000), "PowerShot SD500 / Digital IXUS 700 / IXY Digital 600" }, + { static_cast(0x1668000), "EOS D60" }, + { static_cast(0x1700000), "PowerShot SD30 / Digital IXUS i Zoom / IXY Digital L3" }, + { static_cast(0x1740000), "PowerShot A430" }, + { static_cast(0x1750000), "PowerShot A410" }, + { static_cast(0x1760000), "PowerShot S80" }, + { static_cast(0x1780000), "PowerShot A620" }, + { static_cast(0x1790000), "PowerShot A610" }, + { static_cast(0x1800000), "PowerShot SD630 / Digital IXUS 65 / IXY Digital 80" }, + { static_cast(0x1810000), "PowerShot SD450 / Digital IXUS 55 / IXY Digital 60" }, + { static_cast(0x1820000), "PowerShot TX1" }, + { static_cast(0x1870000), "PowerShot SD400 / Digital IXUS 50 / IXY Digital 55" }, + { static_cast(0x1880000), "PowerShot A420" }, + { static_cast(0x1890000), "PowerShot SD900 / Digital IXUS 900 Ti / IXY Digital 1000" }, + { static_cast(0x1900000), "PowerShot SD550 / Digital IXUS 750 / IXY Digital 700" }, + { static_cast(0x1920000), "PowerShot A700" }, + { static_cast(0x1940000), "PowerShot SD700 IS / Digital IXUS 800 IS / IXY Digital 800 IS" }, + { static_cast(0x1950000), "PowerShot S3 IS" }, + { static_cast(0x1960000), "PowerShot A540" }, + { static_cast(0x1970000), "PowerShot SD600 / Digital IXUS 60 / IXY Digital 70" }, + { static_cast(0x1980000), "PowerShot G7" }, + { static_cast(0x1990000), "PowerShot A530" }, + { static_cast(0x2000000), "PowerShot SD800 IS / Digital IXUS 850 IS / IXY Digital 900 IS" }, + { static_cast(0x2010000), "PowerShot SD40 / Digital IXUS i7 / IXY Digital L4" }, + { static_cast(0x2020000), "PowerShot A710 IS" }, + { static_cast(0x2030000), "PowerShot A640" }, + { static_cast(0x2040000), "PowerShot A630" }, + { static_cast(0x2090000), "PowerShot S5 IS" }, + { static_cast(0x2100000), "PowerShot A460" }, + { static_cast(0x2120000), "PowerShot SD850 IS / Digital IXUS 950 IS / IXY Digital 810 IS" }, + { static_cast(0x2130000), "PowerShot A570 IS" }, + { static_cast(0x2140000), "PowerShot A560" }, + { static_cast(0x2150000), "PowerShot SD750 / Digital IXUS 75 / IXY Digital 90" }, + { static_cast(0x2160000), "PowerShot SD1000 / Digital IXUS 70 / IXY Digital 10" }, + { static_cast(0x2180000), "PowerShot A550" }, + { static_cast(0x2190000), "PowerShot A450" }, + { static_cast(0x2230000), "PowerShot G9" }, + { static_cast(0x2240000), "PowerShot A650 IS" }, + { static_cast(0x2260000), "PowerShot A720 IS" }, + { static_cast(0x2290000), "PowerShot SX100 IS" }, + { static_cast(0x2300000), "PowerShot SD950 IS / Digital IXUS 960 IS / IXY Digital 2000 IS" }, + { static_cast(0x2310000), "PowerShot SD870 IS / Digital IXUS 860 IS / IXY Digital 910 IS" }, + { static_cast(0x2320000), "PowerShot SD890 IS / Digital IXUS 970 IS / IXY Digital 820 IS" }, + { static_cast(0x2360000), "PowerShot SD790 IS / Digital IXUS 90 IS / IXY Digital 95 IS" }, + { static_cast(0x2370000), "PowerShot SD770 IS / Digital IXUS 85 IS / IXY Digital 25 IS" }, + { static_cast(0x2380000), "PowerShot A590 IS" }, + { static_cast(0x2390000), "PowerShot A580" }, + { static_cast(0x2420000), "PowerShot A470" }, + { static_cast(0x2430000), "PowerShot SD1100 IS / Digital IXUS 80 IS / IXY Digital 20 IS" }, + { static_cast(0x2460000), "PowerShot SX1 IS" }, + { static_cast(0x2470000), "PowerShot SX10 IS" }, + { static_cast(0x2480000), "PowerShot A1000 IS" }, + { static_cast(0x2490000), "PowerShot G10" }, + { static_cast(0x2510000), "PowerShot A2000 IS" }, + { static_cast(0x2520000), "PowerShot SX110 IS" }, + { static_cast(0x2530000), "PowerShot SD990 IS / Digital IXUS 980 IS / IXY Digital 3000 IS" }, + { static_cast(0x2540000), "PowerShot SD880 IS / Digital IXUS 870 IS / IXY Digital 920 IS" }, + { static_cast(0x2550000), "PowerShot E1" }, + { static_cast(0x2560000), "PowerShot D10" }, + { static_cast(0x2570000), "PowerShot SD960 IS / Digital IXUS 110 IS / IXY Digital 510 IS" }, + { static_cast(0x2580000), "PowerShot A2100 IS" }, + { static_cast(0x2590000), "PowerShot A480" }, + { static_cast(0x2600000), "PowerShot SX200 IS" }, + { static_cast(0x2610000), "PowerShot SD970 IS / Digital IXUS 990 IS / IXY Digital 830 IS" }, + { static_cast(0x2620000), "PowerShot SD780 IS / Digital IXUS 100 IS / IXY Digital 210 IS" }, + { static_cast(0x2630000), "PowerShot A1100 IS" }, + { static_cast(0x2640000), "PowerShot SD1200 IS / Digital IXUS 95 IS / IXY Digital 110 IS" }, + { static_cast(0x2700000), "PowerShot G11" }, + { static_cast(0x2710000), "PowerShot SX120 IS" }, + { static_cast(0x2720000), "PowerShot S90" }, + { static_cast(0x2750000), "PowerShot SX20 IS" }, + { static_cast(0x2760000), "PowerShot SD980 IS / Digital IXUS 200 IS / IXY Digital 930 IS" }, + { static_cast(0x2770000), "PowerShot SD940 IS / Digital IXUS 120 IS / IXY Digital 220 IS" }, + { static_cast(0x2800000), "PowerShot A495" }, + { static_cast(0x2810000), "PowerShot A490" }, + { static_cast(0x2820000), "PowerShot A3100/A3150 IS" }, + { static_cast(0x2830000), "PowerShot A3000 IS" }, + { static_cast(0x2840000), "PowerShot SD1400 IS / IXUS 130 / IXY 400F" }, + { static_cast(0x2850000), "PowerShot SD1300 IS / IXUS 105 / IXY 200F" }, + { static_cast(0x2860000), "PowerShot SD3500 IS / IXUS 210 / IXY 10S" }, + { static_cast(0x2870000), "PowerShot SX210 IS" }, + { static_cast(0x2880000), "PowerShot SD4000 IS / IXUS 300 HS / IXY 30S" }, + { static_cast(0x2890000), "PowerShot SD4500 IS / IXUS 1000 HS / IXY 50S" }, + { static_cast(0x2920000), "PowerShot G12" }, + { static_cast(0x2930000), "PowerShot SX30 IS" }, + { static_cast(0x2940000), "PowerShot SX130 IS" }, + { static_cast(0x2950000), "PowerShot S95" }, + { static_cast(0x2980000), "PowerShot A3300 IS" }, + { static_cast(0x2990000), "PowerShot A3200 IS" }, + { static_cast(0x3000000), "PowerShot ELPH 500 HS / IXUS 310 HS / IXY 31S" }, + { static_cast(0x3010000), "PowerShot Pro90 IS" }, + { static_cast(0x3010001), "PowerShot A800" }, + { static_cast(0x3020000), "PowerShot ELPH 100 HS / IXUS 115 HS / IXY 210F" }, + { static_cast(0x3030000), "PowerShot SX230 HS" }, + { static_cast(0x3040000), "PowerShot ELPH 300 HS / IXUS 220 HS / IXY 410F" }, + { static_cast(0x3050000), "PowerShot A2200" }, + { static_cast(0x3060000), "PowerShot A1200" }, + { static_cast(0x3070000), "PowerShot SX220 HS" }, + { static_cast(0x3080000), "PowerShot G1 X" }, + { static_cast(0x3090000), "PowerShot SX150 IS" }, + { static_cast(0x3100000), "PowerShot ELPH 510 HS / IXUS 1100 HS / IXY 51S" }, + { static_cast(0x3110000), "PowerShot S100 (new)" }, + { static_cast(0x3130000), "PowerShot SX40 HS" }, + { static_cast(0x3120000), "PowerShot ELPH 310 HS / IXUS 230 HS / IXY 600F" }, + { static_cast(0x3140000), "IXY 32S" }, + { static_cast(0x3160000), "PowerShot A1300" }, + { static_cast(0x3170000), "PowerShot A810" }, + { static_cast(0x3180000), "PowerShot ELPH 320 HS / IXUS 240 HS / IXY 420F" }, + { static_cast(0x3190000), "PowerShot ELPH 110 HS / IXUS 125 HS / IXY 220F" }, + { static_cast(0x3200000), "PowerShot D20" }, + { static_cast(0x3210000), "PowerShot A4000 IS" }, + { static_cast(0x3220000), "PowerShot SX260 HS" }, + { static_cast(0x3230000), "PowerShot SX240 HS" }, + { static_cast(0x3240000), "PowerShot ELPH 530 HS / IXUS 510 HS / IXY 1" }, + { static_cast(0x3250000), "PowerShot ELPH 520 HS / IXUS 500 HS / IXY 3" }, + { static_cast(0x3260000), "PowerShot A3400 IS" }, + { static_cast(0x3270000), "PowerShot A2400 IS" }, + { static_cast(0x3280000), "PowerShot A2300" }, + { static_cast(0x3320000), "PowerShot S100V" }, + { static_cast(0x3330000), "PowerShot G15" }, + { static_cast(0x3340000), "PowerShot SX50 HS" }, + { static_cast(0x3350000), "PowerShot SX160 IS" }, + { static_cast(0x3360000), "PowerShot S110 (new)" }, + { static_cast(0x3370000), "PowerShot SX500 IS" }, + { static_cast(0x3380000), "PowerShot N" }, + { static_cast(0x3390000), "IXUS 245 HS / IXY 430F" }, + { static_cast(0x3400000), "PowerShot SX280 HS" }, + { static_cast(0x3410000), "PowerShot SX270 HS" }, + { static_cast(0x3420000), "PowerShot A3500 IS" }, + { static_cast(0x3430000), "PowerShot A2600" }, + { static_cast(0x3440000), "PowerShot SX275 HS" }, + { static_cast(0x3450000), "PowerShot A1400" }, + { static_cast(0x3460000), "PowerShot ELPH 130 IS / IXUS 140 / IXY 110F" }, + { static_cast(0x3470000), "PowerShot ELPH 115/120 IS / IXUS 132/135 / IXY 90F/100F" }, + { static_cast(0x3490000), "PowerShot ELPH 330 HS / IXUS 255 HS / IXY 610F" }, + { static_cast(0x3510000), "PowerShot A2500" }, + { static_cast(0x3540000), "PowerShot G16" }, + { static_cast(0x3550000), "PowerShot S120" }, + { static_cast(0x3560000), "PowerShot SX170 IS" }, + { static_cast(0x3580000), "PowerShot SX510 HS" }, + { static_cast(0x3590000), "PowerShot S200 (new)" }, + { static_cast(0x3600000), "IXY 620F" }, + { static_cast(0x3610000), "PowerShot N100" }, + { static_cast(0x3640000), "PowerShot G1 X Mark II" }, + { static_cast(0x3650000), "PowerShot D30" }, + { static_cast(0x3660000), "PowerShot SX700 HS" }, + { static_cast(0x3670000), "PowerShot SX600 HS" }, + { static_cast(0x3680000), "PowerShot ELPH 140 IS / IXUS 150 / IXY 130" }, + { static_cast(0x3690000), "PowerShot ELPH 135 / IXUS 145 / IXY 120" }, + { static_cast(0x3700000), "PowerShot ELPH 340 HS / IXUS 265 HS / IXY 630" }, + { static_cast(0x3710000), "PowerShot ELPH 150 IS / IXUS 155 / IXY 140" }, + { static_cast(0x3740000), "EOS M3" }, + { static_cast(0x3750000), "PowerShot SX60 HS" }, + { static_cast(0x3760000), "PowerShot SX520 HS" }, + { static_cast(0x3770000), "PowerShot SX400 IS" }, + { static_cast(0x3780000), "PowerShot G7 X" }, + { static_cast(0x3790000), "PowerShot N2" }, + { static_cast(0x3800000), "PowerShot SX530 HS" }, + { static_cast(0x3820000), "PowerShot SX710 HS" }, + { static_cast(0x3830000), "PowerShot SX610 HS" }, + { static_cast(0x3840000), "EOS M10" }, + { static_cast(0x3850000), "PowerShot G3 X" }, + { static_cast(0x3860000), "PowerShot ELPH 165 HS / IXUS 165 / IXY 160" }, + { static_cast(0x3870000), "PowerShot ELPH 160 / IXUS 160" }, + { static_cast(0x3880000), "PowerShot ELPH 350 HS / IXUS 275 HS / IXY 640" }, + { static_cast(0x3890000), "PowerShot ELPH 170 IS / IXUS 170" }, + { static_cast(0x3910000), "PowerShot SX410 IS" }, + { static_cast(0x3930000), "PowerShot G9 X" }, + { static_cast(0x3940000), "EOS M5" }, + { static_cast(0x3950000), "PowerShot G5 X" }, + { static_cast(0x3970000), "PowerShot G7 X Mark II" }, + { static_cast(0x3980000), "EOS M100" }, + { static_cast(0x3990000), "PowerShot ELPH 360 HS / IXUS 285 HS / IXY 650" }, + { static_cast(0x4010000), "PowerShot SX540 HS" }, + { static_cast(0x4020000), "PowerShot SX420 IS" }, + { static_cast(0x4030000), "PowerShot ELPH 190 IS / IXUS 180 / IXY 190" }, + { static_cast(0x4040000), "PowerShot G1" }, + { static_cast(0x4040001), "PowerShot ELPH 180 IS / IXUS 175 / IXY 180" }, + { static_cast(0x4050000), "PowerShot SX720 HS" }, + { static_cast(0x4060000), "PowerShot SX620 HS" }, + { static_cast(0x4070000), "EOS M6" }, + { static_cast(0x4100000), "PowerShot G9 X Mark II" }, + { static_cast(0x412), "EOS M50 / Kiss M" }, + { static_cast(0x4150000), "PowerShot ELPH 185 / IXUS 185 / IXY 200" }, + { static_cast(0x4160000), "PowerShot SX430 IS" }, + { static_cast(0x4170000), "PowerShot SX730 HS" }, + { static_cast(0x4180000), "PowerShot G1 X Mark III" }, + { static_cast(0x6040000), "PowerShot S100 / Digital IXUS / IXY Digital" }, + { static_cast(0x801), "PowerShot SX740 HS" }, + { static_cast(0x804), "PowerShot G5 X Mark II" }, + { static_cast(0x805), "PowerShot SX70 HS" }, + { static_cast(0x808), "PowerShot G7 X Mark III" }, + { static_cast(0x811), "EOS M6 Mark II" }, + { static_cast(0x812), "EOS M200" }, + { static_cast(0x4007d673), "DC19/DC21/DC22" }, + { static_cast(0x4007d674), "XH A1" }, + { static_cast(0x4007d675), "HV10" }, + { static_cast(0x4007d676), "MD130/MD140/MD150/MD160/ZR850" }, + { static_cast(0x4007d777), "DC50" }, + { static_cast(0x4007d778), "HV20" }, + { static_cast(0x4007d779), "DC211" }, + { static_cast(0x4007d77a), "HG10" }, + { static_cast(0x4007d77b), "HR10" }, + { static_cast(0x4007d77d), "MD255/ZR950" }, + { static_cast(0x4007d81c), "HF11" }, + { static_cast(0x4007d878), "HV30" }, + { static_cast(0x4007d87c), "XH A1S" }, + { static_cast(0x4007d87e), "DC301/DC310/DC311/DC320/DC330" }, + { static_cast(0x4007d87f), "FS100" }, + { static_cast(0x4007d880), "HF10" }, + { static_cast(0x4007d882), "HG20/HG21" }, + { static_cast(0x4007d925), "HF21" }, + { static_cast(0x4007d926), "HF S11" }, + { static_cast(0x4007d978), "HV40" }, + { static_cast(0x4007d987), "DC410/DC411/DC420" }, + { static_cast(0x4007d988), "FS19/FS20/FS21/FS22/FS200" }, + { static_cast(0x4007d989), "HF20/HF200" }, + { static_cast(0x4007d98a), "HF S10/S100" }, + { static_cast(0x4007da8e), "HF R10/R16/R17/R18/R100/R106" }, + { static_cast(0x4007da8f), "HF M30/M31/M36/M300/M306" }, + { static_cast(0x4007da90), "HF S20/S21/S200" }, + { static_cast(0x4007da92), "FS31/FS36/FS37/FS300/FS305/FS306/FS307" }, + { static_cast(0x4007dca0), "EOS C300" }, + { static_cast(0x4007dda9), "HF G25" }, + { static_cast(0x4007dfb4), "XC10" }, + { static_cast(0x4007e1c3), "EOS C200" }, + { static_cast(0x80000001), "EOS-1D" }, + { static_cast(0x80000167), "EOS-1DS" }, + { static_cast(0x80000168), "EOS 10D" }, + { static_cast(0x80000169), "EOS-1D Mark III" }, + { static_cast(0x80000170), "EOS Digital Rebel / 300D / Kiss Digital" }, + { static_cast(0x80000174), "EOS-1D Mark II" }, + { static_cast(0x80000175), "EOS 20D" }, + { static_cast(0x80000176), "EOS Digital Rebel XSi / 450D / Kiss X2" }, + { static_cast(0x80000188), "EOS-1Ds Mark II" }, + { static_cast(0x80000189), "EOS Digital Rebel XT / 350D / Kiss Digital N" }, + { static_cast(0x80000190), "EOS 40D" }, + { static_cast(0x80000213), "EOS 5D" }, + { static_cast(0x80000215), "EOS-1Ds Mark III" }, + { static_cast(0x80000218), "EOS 5D Mark II" }, + { static_cast(0x80000219), "WFT-E1" }, + { static_cast(0x80000232), "EOS-1D Mark II N" }, + { static_cast(0x80000234), "EOS 30D" }, + { static_cast(0x80000236), "EOS Digital Rebel XTi / 400D / Kiss Digital X" }, + { static_cast(0x80000241), "WFT-E2" }, + { static_cast(0x80000246), "WFT-E3" }, + { static_cast(0x80000250), "EOS 7D" }, + { static_cast(0x80000252), "EOS Rebel T1i / 500D / Kiss X3" }, + { static_cast(0x80000254), "EOS Rebel XS / 1000D / Kiss F" }, + { static_cast(0x80000261), "EOS 50D" }, + { static_cast(0x80000269), "EOS-1D X" }, + { static_cast(0x80000270), "EOS Rebel T2i / 550D / Kiss X4" }, + { static_cast(0x80000271), "WFT-E4" }, + { static_cast(0x80000273), "WFT-E5" }, + { static_cast(0x80000281), "EOS-1D Mark IV" }, + { static_cast(0x80000285), "EOS 5D Mark III" }, + { static_cast(0x80000286), "EOS Rebel T3i / 600D / Kiss X5" }, + { static_cast(0x80000287), "EOS 60D" }, + { static_cast(0x80000288), "EOS Rebel T3 / 1100D / Kiss X50" }, + { static_cast(0x80000289), "EOS 7D Mark II" }, + { static_cast(0x80000297), "WFT-E2 II" }, + { static_cast(0x80000298), "WFT-E4 II" }, + { static_cast(0x80000301), "EOS Rebel T4i / 650D / Kiss X6i" }, + { static_cast(0x80000302), "EOS 6D" }, + { static_cast(0x80000324), "EOS-1D C" }, + { static_cast(0x80000325), "EOS 70D" }, + { static_cast(0x80000326), "EOS Rebel T5i / 700D / Kiss X7i" }, + { static_cast(0x80000327), "EOS Rebel T5 / 1200D / Kiss X70 / Hi" }, + { static_cast(0x80000328), "EOS-1D X MARK II" }, + { static_cast(0x80000331), "EOS M" }, + { static_cast(0x80000350), "EOS 80D" }, + { static_cast(0x80000355), "EOS M2" }, + { static_cast(0x80000346), "EOS Rebel SL1 / 100D / Kiss X7" }, + { static_cast(0x80000347), "EOS Rebel T6s / 760D / 8000D" }, + { static_cast(0x80000349), "EOS 5D Mark IV" }, + { static_cast(0x80000382), "EOS 5DS" }, + { static_cast(0x80000393), "EOS Rebel T6i / 750D / Kiss X8i" }, + { static_cast(0x80000401), "EOS 5DS R" }, + { static_cast(0x80000404), "EOS Rebel T6 / 1300D / Kiss X80" }, + { static_cast(0x80000405), "EOS Rebel T7i / 800D / Kiss X9i" }, + { static_cast(0x80000406), "EOS 6D Mark II" }, + { static_cast(0x80000408), "EOS 77D / 9000D" }, + { static_cast(0x80000417), "EOS Rebel SL2 / 200D / Kiss X9" }, + { static_cast(0x80000421), "EOS R5" }, + { static_cast(0x80000422), "EOS Rebel T100 / 4000D / 3000D" }, + { static_cast(0x80000424), "EOS R" }, + { static_cast(0x80000428), "EOS-1D X Mark III" }, + { static_cast(0x80000432), "EOS Rebel T7 / 2000D / 1500D / Kiss X90" }, + { static_cast(0x80000433), "EOS RP" }, + { static_cast(0x80000435), "EOS 850D / T8i / Kiss X10i" }, + { static_cast(0x80000436), "EOS SL3 / 250D / Kiss X10" }, + { static_cast(0x80000437), "EOS 90D" }, + { static_cast(0x80000453), "EOS R6" }, //{ (long int)tbd, "EOS Ra" }, //{ (long int)tbd, "EOS M50 Mark II" }, - { (long int)0x80000520, "EOS D2000C" }, - { (long int)0x80000560, "EOS D6000C" } - }; + {static_cast(0x80000520), "EOS D2000C"}, + {static_cast(0x80000560), "EOS D6000C"}}; //! SerialNumberFormat, tag 0x0015 constexpr TagDetails canonSerialNumberFormat[] = { - { (long int)0x90000000, N_("Format 1") }, - { (long int)0xa0000000, N_("Format 2") }, + { static_cast(0x90000000), N_("Format 1") }, + { static_cast(0xa0000000), N_("Format 2") }, }; //! SuperMacro, tag 0x001a diff --git a/src/casiomn_int.cpp b/src/casiomn_int.cpp index ed81d2a7..51f9e446 100644 --- a/src/casiomn_int.cpp +++ b/src/casiomn_int.cpp @@ -230,7 +230,7 @@ namespace Exiv2 { long l=value.toLong(i); if(l!=0) { - numbers.push_back((char)l); + numbers.push_back(static_cast(l)); }; }; if(numbers.size()>=10) @@ -549,7 +549,7 @@ namespace Exiv2 { long l=value.toLong(i); if(l!=0) { - numbers.push_back((char)l); + numbers.push_back(static_cast(l)); }; }; if(numbers.size()>=10) diff --git a/src/cr2image.cpp b/src/cr2image.cpp index c36c440e..2d22b17e 100644 --- a/src/cr2image.cpp +++ b/src/cr2image.cpp @@ -102,11 +102,8 @@ namespace Exiv2 { throw Error(kerNotAnImage, "CR2"); } clearMetadata(); - ByteOrder bo = Cr2Parser::decode(exifData_, - iptcData_, - xmpData_, - io_->mmap(), - (uint32_t) io_->size()); + ByteOrder bo = + Cr2Parser::decode(exifData_, iptcData_, xmpData_, io_->mmap(), static_cast(io_->size())); setByteOrder(bo); } // Cr2Image::readMetadata @@ -123,7 +120,7 @@ namespace Exiv2 { // Ensure that this is the correct image type if (isCr2Type(*io_, false)) { pData = io_->mmap(true); - size = (long) io_->size(); + size = static_cast(io_->size()); Cr2Header cr2Header; if (0 == cr2Header.read(pData, 16)) { bo = cr2Header.byteOrder(); diff --git a/src/crwimage.cpp b/src/crwimage.cpp index 2458cd5e..f2a3fbef 100644 --- a/src/crwimage.cpp +++ b/src/crwimage.cpp @@ -101,10 +101,10 @@ namespace Exiv2 { throw Error(kerNotACrwImage); } clearMetadata(); - DataBuf file( (long) io().size()); + DataBuf file(static_cast(io().size())); io_->read(file.pData_,file.size_); - CrwParser::decode(this, io_->mmap(), (uint32_t) io_->size()); + CrwParser::decode(this, io_->mmap(), static_cast(io_->size())); } // CrwImage::readMetadata @@ -120,7 +120,7 @@ namespace Exiv2 { // Ensure that this is the correct image type if (isCrwType(*io_, false)) { // Read the image into a memory buffer - buf.alloc((long) io_->size()); + buf.alloc(static_cast(io_->size())); io_->read(buf.pData_, buf.size_); if (io_->error() || io_->eof()) { buf.reset(); diff --git a/src/exif.cpp b/src/exif.cpp index 9e12eac4..25fbb6a9 100644 --- a/src/exif.cpp +++ b/src/exif.cpp @@ -736,7 +736,7 @@ namespace Exiv2 { header.get(), 0); if (mio1.size() <= 65527) { - append(blob, mio1.mmap(), (uint32_t) mio1.size()); + append(blob, mio1.mmap(), static_cast(mio1.size())); return wm; } @@ -838,7 +838,7 @@ namespace Exiv2 { TiffMapping::findEncoder, header.get(), 0); - append(blob, mio2.mmap(), (uint32_t) mio2.size()); + append(blob, mio2.mmap(), static_cast(mio2.size())); #ifdef EXIV2_DEBUG_MESSAGES if (wm == wmIntrusive) { std::cerr << "SIZE OF EXIF DATA IS " << std::dec << mio2.size() << " BYTES\n"; @@ -915,7 +915,7 @@ namespace { Exiv2::IptcData emptyIptc; Exiv2::XmpData emptyXmp; Exiv2::TiffParser::encode(io, 0, 0, Exiv2::littleEndian, thumb, emptyIptc, emptyXmp); - return io.read((long) io.size()); + return io.read(static_cast(io.size())); } const char* JpegThumbnail::mimeType() const diff --git a/src/exiv2.cpp b/src/exiv2.cpp index 1cd1501c..c3750238 100644 --- a/src/exiv2.cpp +++ b/src/exiv2.cpp @@ -524,9 +524,8 @@ int Params::evalRename(int opt, const std::string& optArg) } break; default: - std::cerr << progname() - << ": " << _("Option") << " -" << (char)opt - << " " << _("is not compatible with a previous option\n"); + std::cerr << progname() << ": " << _("Option") << " -" << static_cast(opt) << " " + << _("is not compatible with a previous option\n"); rc = 1; break; } @@ -843,8 +842,7 @@ int Params::evalModify(int opt, const std::string& optArg) if (opt == 'M') cmdLines_.push_back(optArg); // parse the commands later break; default: - std::cerr << progname() << ": " - << _("Option") << " -" << (char)opt << " " + std::cerr << progname() << ": " << _("Option") << " -" << static_cast(opt) << " " << _("is not compatible with a previous option\n"); rc = 1; break; @@ -958,15 +956,15 @@ int Params::nonoption(const std::string& argv) static int readFileToBuf(FILE* f,Exiv2::DataBuf& buf) { const int buff_size = 4*1028; - auto bytes = (Exiv2::byte*)::malloc(buff_size); + auto bytes = static_cast(::malloc(buff_size)); int nBytes = 0 ; bool more = bytes != NULL; while ( more ) { char buff[buff_size]; - int n = (int) fread(buff,1,buff_size,f); + int n = static_cast(fread(buff, 1, buff_size, f)); more = n > 0 ; if ( more ) { - bytes = (Exiv2::byte*) realloc(bytes,nBytes+n); + bytes = static_cast(realloc(bytes, nBytes + n)); memcpy(bytes+nBytes,buff,n); nBytes += n ; } @@ -974,7 +972,7 @@ static int readFileToBuf(FILE* f,Exiv2::DataBuf& buf) if ( nBytes ) { buf.alloc(nBytes); - memcpy(buf.pData_,(const void*)bytes,nBytes); + memcpy(buf.pData_, bytes, nBytes); } if ( bytes != NULL ) ::free(bytes) ; return nBytes; @@ -1154,7 +1152,8 @@ int Params::getopt(int argc, char* const Argv[]) cleanup: // cleanup the argument vector - for ( int i = 0 ; i < argc ; i++ ) ::free((void*)argv[i]); + for (int i = 0; i < argc; i++) + ::free(argv[i]); delete [] argv; return rc; @@ -1255,7 +1254,8 @@ namespace { case 'p': { if (strcmp(action.c_str(), "extract") == 0) { - i += (size_t)parsePreviewNumbers(Params::instance().previewNumbers_, optArg, (int)i + 1); + i += static_cast( + parsePreviewNumbers(Params::instance().previewNumbers_, optArg, static_cast(i) + 1)); target |= Params::ctPreview; break; } @@ -1307,7 +1307,7 @@ namespace { } std::cout << std::endl; #endif - return (int) (k - j); + return static_cast(k - j); } // parsePreviewNumbers bool parseCmdFiles(ModifyCmds& modifyCmds, @@ -1572,8 +1572,8 @@ namespace { } std::string ucs2toUtf8; - ucs2toUtf8.push_back((char) ((acc & 0xff00) >> 8)); - ucs2toUtf8.push_back((char) (acc & 0x00ff)); + ucs2toUtf8.push_back(static_cast((acc & 0xff00) >> 8)); + ucs2toUtf8.push_back(static_cast(acc & 0x00ff)); if (Exiv2::convertStringCharset (ucs2toUtf8, "UCS-2BE", "UTF-8")) { result.append (ucs2toUtf8); diff --git a/src/futils.cpp b/src/futils.cpp index 5c97751c..c81db519 100644 --- a/src/futils.cpp +++ b/src/futils.cpp @@ -150,13 +150,13 @@ namespace Exiv2 { '4', '5', '6', '7', '8', '9', '+', '/'}; int base64encode(const void* data_buf, size_t dataLength, char* result, size_t resultSize) { - auto encoding_table = (char*)base64_encode; + auto encoding_table = base64_encode; size_t mod_table[] = {0, 2, 1}; size_t output_length = 4 * ((dataLength + 2) / 3); int rc = result && data_buf && output_length < resultSize ? 1 : 0; if ( rc ) { - const auto data = (const unsigned char*)data_buf; + const auto data = static_cast(data_buf); for (size_t i = 0, j = 0 ; i < dataLength;) { uint32_t octet_a = i < dataLength ? data[i++] : 0 ; @@ -183,13 +183,13 @@ namespace Exiv2 { size_t input_length = in ? ::strlen(in) : 0; if (!in || input_length % 4 != 0) return result; - auto encoding_table = (unsigned char*)base64_encode; + auto encoding_table = reinterpret_cast(base64_encode); unsigned char decoding_table[256]; for (unsigned char i = 0; i < 64; i++) decoding_table[encoding_table[i]] = i; size_t output_length = input_length / 4 * 3; - const auto buff = (const unsigned char*)in; + const auto buff = reinterpret_cast(in); if (buff[input_length - 1] == '=') (output_length)--; if (buff[input_length - 2] == '=') (output_length)--; @@ -212,7 +212,7 @@ namespace Exiv2 { if (j < output_length) out[j++] = (triple >> 0 * 8) & 0xFF; } out[output_length]=0; - result = (long) output_length; + result = static_cast(output_length); } return result; diff --git a/src/getopt.cpp b/src/getopt.cpp index c5d1b045..46861be1 100644 --- a/src/getopt.cpp +++ b/src/getopt.cpp @@ -82,13 +82,13 @@ namespace Util { } if (opt[1] == ':') { if (arg[optpos + 1]) { - optarg = (char *)arg + optpos + 1; + optarg = const_cast(arg) + optpos + 1; optind++; optpos = 1; return optopt; } if (argv[optind + 1]) { - optarg = (char *)argv[optind + 1]; + optarg = argv[optind + 1]; optind += 2; optpos = 1; return optopt; diff --git a/src/http.cpp b/src/http.cpp index 1d6e6813..0a2ba21b 100644 --- a/src/http.cpp +++ b/src/http.cpp @@ -258,7 +258,7 @@ int Exiv2::http(Exiv2::Dictionary& request,Exiv2::Dictionary& response,std::stri // fill in the address struct sockaddr_in serv_addr ; int serv_len = sizeof(serv_addr); - memset((char *)&serv_addr,0,serv_len); + memset(reinterpret_cast(&serv_addr), 0, serv_len); serv_addr.sin_addr.s_addr = inet_addr(servername_p); serv_addr.sin_family = AF_INET ; @@ -266,8 +266,7 @@ int Exiv2::http(Exiv2::Dictionary& request,Exiv2::Dictionary& response,std::stri // convert unknown servername into IP address // http://publib.boulder.ibm.com/infocenter/iseries/v5r3/index.jsp?topic=/rzab6/rzab6uafinet.htm - if (serv_addr.sin_addr.s_addr == (unsigned long)INADDR_NONE) - { + if (serv_addr.sin_addr.s_addr == static_cast(INADDR_NONE)) { struct hostent* host = gethostbyname(servername_p); if (!host) return error(errors, "no such host", servername_p); @@ -278,7 +277,7 @@ int Exiv2::http(Exiv2::Dictionary& request,Exiv2::Dictionary& response,std::stri //////////////////////////////////// // and connect - server = connect(sockfd, (const struct sockaddr *) &serv_addr, serv_len) ; + server = connect(sockfd, reinterpret_cast(&serv_addr), serv_len); if ( server == SOCKET_ERROR && WSAGetLastError() != WSAEWOULDBLOCK ) return error(errors, "error - unable to connect to server = %s port = %s wsa_error = %d", servername_p, port_p, WSAGetLastError()); @@ -311,7 +310,7 @@ int Exiv2::http(Exiv2::Dictionary& request,Exiv2::Dictionary& response,std::stri //////////////////////////////////// // read and process the response int err ; - n=forgive(recv(sockfd,buffer,(int)buff_l,0),err) ; + n = forgive(recv(sockfd, buffer, static_cast(buff_l), 0), err); while ( n >= 0 && OK(status) ) { if ( n ) { end += n ; @@ -378,7 +377,7 @@ int Exiv2::http(Exiv2::Dictionary& request,Exiv2::Dictionary& response,std::stri flushBuffer(buffer,body,end,file); } } - n=forgive(recv(sockfd,buffer+end,(int)(buff_l-end),0),err) ; + n = forgive(recv(sockfd, buffer + end, static_cast(buff_l - end), 0), err); if ( !n ) { Sleep(snooze) ; sleep_ -= snooze ; diff --git a/src/image.cpp b/src/image.cpp index 14304141..077f5161 100644 --- a/src/image.cpp +++ b/src/image.cpp @@ -258,7 +258,7 @@ namespace Exiv2 { uint16_t Image::byteSwap2(const DataBuf& buf,size_t offset,bool bSwap) { uint16_t v; - auto p = (char*)&v; + auto p = reinterpret_cast(&v); p[0] = buf.pData_[offset]; p[1] = buf.pData_[offset+1]; return Image::byteSwap(v,bSwap); @@ -267,7 +267,7 @@ namespace Exiv2 { uint32_t Image::byteSwap4(const DataBuf& buf,size_t offset,bool bSwap) { uint32_t v; - auto p = (char*)&v; + auto p = reinterpret_cast(&v); p[0] = buf.pData_[offset]; p[1] = buf.pData_[offset+1]; p[2] = buf.pData_[offset+2]; @@ -390,11 +390,11 @@ namespace Exiv2 { // if ( offset > io.size() ) offset = 0; // Denial of service? // #55 and #56 memory allocation crash test/data/POC8 - long long allocate = (long long) size*count + pad+20; - if ( allocate > (long long) io.size() ) { + long long allocate = static_cast(size) * count + pad + 20; + if (allocate > static_cast(io.size())) { throw Error(kerInvalidMalloc); } - DataBuf buf((long)allocate); // allocate a buffer + DataBuf buf(static_cast(allocate)); // allocate a buffer std::memset(buf.pData_, 0, buf.size_); std::memcpy(buf.pData_,dir.pData_+8,4); // copy dir[8:11] into buffer (short strings) const bool bOffsetIsPointer = count*size > 4; @@ -467,7 +467,7 @@ namespace Exiv2 { uint32_t jump= 10 ; byte bytes[20] ; - const auto chars = (const char*)&bytes[0]; + const auto chars = reinterpret_cast(&bytes[0]); io.seek(offset,BasicIo::beg); // position io.read(bytes,jump ) ; // read bytes[jump]=0 ; @@ -490,10 +490,10 @@ namespace Exiv2 { if ( isPrintXMP(tag,option) ) { buf.pData_[count]=0; - out << (char*) buf.pData_; + out << reinterpret_cast(buf.pData_); } if ( isPrintICC(tag,option) ) { - out.write((const char*)buf.pData_,count); + out.write(reinterpret_cast(buf.pData_), count); } } if ( start ) { @@ -518,12 +518,12 @@ namespace Exiv2 { // read header (we already know for certain that we have a Tiff file) io.read(dir.pData_, 8); - char c = (char) dir.pData_[0] ; + char c = static_cast(dir.pData_[0]); bool bSwap = ( c == 'M' && isLittleEndianPlatform() ) || ( c == 'I' && isBigEndianPlatform() ) ; uint32_t start = byteSwap4(dir,4,bSwap); - printIFDStructure(io,out,option,start+(uint32_t)offset,bSwap,c,depth); + printIFDStructure(io, out, option, start + static_cast(offset), bSwap, c, depth); } } @@ -652,7 +652,8 @@ namespace Exiv2 { void Image::setIccProfile(Exiv2::DataBuf& iccProfile,bool bTestValid) { if ( bTestValid ) { - if ( iccProfile.pData_ && ( iccProfile.size_ < (long) sizeof(long)) ) throw Error(kerInvalidIccProfile); + if (iccProfile.pData_ && (iccProfile.size_ < static_cast(sizeof(long)))) + throw Error(kerInvalidIccProfile); long size = iccProfile.pData_ ? getULong(iccProfile.pData_, bigEndian): -1; if ( size!= iccProfile.size_ ) throw Error(kerInvalidIccProfile); } diff --git a/src/image_int.cpp b/src/image_int.cpp index 428d53bc..8db6de19 100644 --- a/src/image_int.cpp +++ b/src/image_int.cpp @@ -61,22 +61,22 @@ namespace Exiv2 { std::stringstream hexOutput; - auto tl = (unsigned long)((size / 16) * 16); - auto tl_offset = (unsigned long)(size - tl); + auto tl = size_t(size / 16) * 16; + auto tl_offset = size_t(size) - tl; - for (unsigned long loop = 0; loop < (unsigned long)size; loop++) { + for (size_t loop = 0; loop < size; loop++) { if (data[loop] < 16) { hexOutput << "0"; } - hexOutput << std::hex << (int)data[loop]; + hexOutput << std::hex << static_cast(data[loop]); if ((loop % 8) == 7) { hexOutput << " "; } if ((loop % 16) == 15 || loop == (tl + tl_offset - 1)) { int max = 15; if (loop >= tl) { - max = tl_offset - 1; - for (int offset = 0; offset < (int)(16 - tl_offset); offset++) { + max = int(tl_offset) - 1; + for (int offset = 0; offset < int(16 - tl_offset); offset++) { if ((offset % 8) == 7) { hexOutput << " "; } @@ -92,7 +92,7 @@ namespace Exiv2 if (data[loop - offset] >= 0x20 && data[loop - offset] <= 0x7E) { c = data[loop - offset]; } - hexOutput << (char)c; + hexOutput << static_cast(c); } hexOutput << std::endl; } diff --git a/src/ini.cpp b/src/ini.cpp index b36693e5..f0e729e4 100755 --- a/src/ini.cpp +++ b/src/ini.cpp @@ -63,7 +63,7 @@ https://github.com/benhoyt/inih static char* rstrip(char* s) { char* p = s + strlen(s); - while (p > s && isspace((unsigned char)(*--p))) + while (p > s && isspace(static_cast(*--p))) *p = '\0'; return s; } @@ -71,9 +71,9 @@ static char* rstrip(char* s) /* Return pointer to first non-whitespace char in given string. */ static char* lskip(const char* s) { - while (*s && isspace((unsigned char)(*s))) + while (*s && isspace(static_cast(*s))) s++; - return (char*)s; + return const_cast(s); } /* Return pointer to first char (of chars) or inline comment in given string, @@ -85,7 +85,7 @@ static char* find_chars_or_comment(const char* s, const char* chars) int was_space = 0; while (*s && (!chars || !strchr(chars, *s)) && !(was_space && strchr(INI_INLINE_COMMENT_PREFIXES, *s))) { - was_space = isspace((unsigned char)(*s)); + was_space = isspace(static_cast(*s)); s++; } #else @@ -93,7 +93,7 @@ static char* find_chars_or_comment(const char* s, const char* chars) s++; } #endif - return (char*)s; + return const_cast(s); } /* Version of strncpy that ensures dest (size bytes) is null-terminated. */ @@ -137,9 +137,8 @@ int Exiv2::ini_parse_stream(ini_reader reader, void* stream, ini_handler handler start = line; #if INI_ALLOW_BOM - if (lineno == 1 && (unsigned char)start[0] == 0xEF && - (unsigned char)start[1] == 0xBB && - (unsigned char)start[2] == 0xBF) { + if (lineno == 1 && static_cast(start[0]) == 0xEF && + static_cast(start[1]) == 0xBB && static_cast(start[2]) == 0xBF) { start += 3; } #endif @@ -211,7 +210,7 @@ int Exiv2::ini_parse_stream(ini_reader reader, void* stream, ini_handler handler /* See documentation in header file. */ int Exiv2::ini_parse_file(FILE* file, ini_handler handler, void* user) { - return Exiv2::ini_parse_stream((ini_reader)fgets, file, handler, user); + return Exiv2::ini_parse_stream(reinterpret_cast(fgets), file, handler, user); } /* See documentation in header file. */ @@ -285,7 +284,7 @@ string INIReader::MakeKey(const string& section, const string& name) int INIReader::ValueHandler(void* user, const char* section, const char* name, const char* value) { - auto reader = (INIReader*)user; + auto reader = static_cast(user); string key = MakeKey(section, name); if (!reader->_values[key].empty()) reader->_values[key] += "\n"; diff --git a/src/jp2image.cpp b/src/jp2image.cpp index 93a25a99..d880297a 100644 --- a/src/jp2image.cpp +++ b/src/jp2image.cpp @@ -185,7 +185,7 @@ namespace Exiv2 static std::string toAscii(long n) { - const auto p = (const char*)&n; + const auto p = reinterpret_cast(&n); std::string result; bool bBigEndian = isBigEndian(); for ( int i = 0 ; i < 4 ; i++) { @@ -229,12 +229,11 @@ static void boxes_check(size_t b,size_t m) size_t boxes = 0 ; size_t boxem = 1000 ; // boxes max - while (io_->read((byte*)&box, sizeof(box)) == sizeof(box)) - { + while (io_->read(reinterpret_cast(&box), sizeof(box)) == sizeof(box)) { boxes_check(boxes++,boxem ); position = io_->tell(); - box.length = getLong((byte*)&box.length, bigEndian); - box.type = getLong((byte*)&box.type, bigEndian); + box.length = getLong(reinterpret_cast(&box.length), bigEndian); + box.type = getLong(reinterpret_cast(&box.type), bigEndian); #ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::Jp2Image::readMetadata: " << "Position: " << position @@ -259,11 +258,11 @@ static void boxes_check(size_t b,size_t m) #endif long restore = io_->tell(); - while (io_->read((byte*)&subBox, sizeof(subBox)) == sizeof(subBox) && subBox.length ) - { + while (io_->read(reinterpret_cast(&subBox), sizeof(subBox)) == sizeof(subBox) && + subBox.length) { boxes_check(boxes++, boxem) ; - subBox.length = getLong((byte*)&subBox.length, bigEndian); - subBox.type = getLong((byte*)&subBox.type, bigEndian); + subBox.length = getLong(reinterpret_cast(&subBox.length), bigEndian); + subBox.type = getLong(reinterpret_cast(&subBox.type), bigEndian); if (subBox.length > io_->size() ) { throw Error(kerCorruptedMetadata); } @@ -308,14 +307,15 @@ static void boxes_check(size_t b,size_t m) if( subBox.type == kJp2BoxTypeImageHeader) { - io_->read((byte*)&ihdr, sizeof(ihdr)); + io_->read(reinterpret_cast(&ihdr), sizeof(ihdr)); #ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::Jp2Image::readMetadata: Ihdr data found" << std::endl; #endif - ihdr.imageHeight = getLong((byte*)&ihdr.imageHeight, bigEndian); - ihdr.imageWidth = getLong((byte*)&ihdr.imageWidth, bigEndian); - ihdr.componentCount = getShort((byte*)&ihdr.componentCount, bigEndian); - ihdr.compressionTypeProfile = getShort((byte*)&ihdr.compressionTypeProfile, bigEndian); + ihdr.imageHeight = getLong(reinterpret_cast(&ihdr.imageHeight), bigEndian); + ihdr.imageWidth = getLong(reinterpret_cast(&ihdr.imageWidth), bigEndian); + ihdr.componentCount = getShort(reinterpret_cast(&ihdr.componentCount), bigEndian); + ihdr.compressionTypeProfile = + getShort(reinterpret_cast(&ihdr.compressionTypeProfile), bigEndian); pixelWidth_ = ihdr.imageWidth; pixelHeight_ = ihdr.imageHeight; @@ -336,8 +336,7 @@ static void boxes_check(size_t b,size_t m) std::cout << "Exiv2::Jp2Image::readMetadata: UUID box found" << std::endl; #endif - if (io_->read((byte*)&uuid, sizeof(uuid)) == sizeof(uuid)) - { + if (io_->read(reinterpret_cast(&uuid), sizeof(uuid)) == sizeof(uuid)) { DataBuf rawData; long bufRead; bool bIsExif = memcmp(uuid.uuid, kJp2UuidExif, sizeof(uuid))==0; @@ -363,8 +362,8 @@ static void boxes_check(size_t b,size_t m) // #1242 Forgive having Exif\0\0 in rawData.pData_ const byte exifHeader[] = { 0x45, 0x78, 0x69, 0x66, 0x00, 0x00 }; - for (long i=0 ; pos < 0 && i < rawData.size_-(long)sizeof(exifHeader) ; i++) - { + for (long i = 0; pos < 0 && i < rawData.size_ - static_cast(sizeof(exifHeader)); + i++) { if (memcmp(exifHeader, &rawData.pData_[i], sizeof(exifHeader)) == 0) { pos = i+sizeof(exifHeader); @@ -422,21 +421,22 @@ static void boxes_check(size_t b,size_t m) #ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::Jp2Image::readMetadata: Xmp data found" << std::endl; #endif - rawData.alloc(box.length - (uint32_t)(sizeof(box) + sizeof(uuid))); - bufRead = io_->read(rawData.pData_, rawData.size_); - if (io_->error()) throw Error(kerFailedToReadImageData); - if (bufRead != rawData.size_) throw Error(kerInputDataReadFailed); - xmpPacket_.assign(reinterpret_cast(rawData.pData_), rawData.size_); + rawData.alloc(box.length - static_cast(sizeof(box) + sizeof(uuid))); + bufRead = io_->read(rawData.pData_, rawData.size_); + if (io_->error()) + throw Error(kerFailedToReadImageData); + if (bufRead != rawData.size_) + throw Error(kerInputDataReadFailed); + xmpPacket_.assign(reinterpret_cast(rawData.pData_), rawData.size_); - std::string::size_type idx = xmpPacket_.find_first_of('<'); - if (idx != std::string::npos && idx > 0) - { + std::string::size_type idx = xmpPacket_.find_first_of('<'); + if (idx != std::string::npos && idx > 0) { #ifndef SUPPRESS_WARNINGS EXV_WARNING << "Removing " << static_cast(idx) << " characters from the beginning of the XMP packet" << std::endl; #endif xmpPacket_ = xmpPacket_.substr(idx); - } + } if (!xmpPacket_.empty() && XmpParser::decode(xmpData_, xmpPacket_)) { #ifndef SUPPRESS_WARNINGS @@ -492,16 +492,16 @@ static void boxes_check(size_t b,size_t m) Jp2UuidBox uuid = {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}}; bool bLF = false; - while (box.length && box.type != kJp2BoxTypeClose && io_->read((byte*)&box, sizeof(box)) == sizeof(box)) - { + while (box.length && box.type != kJp2BoxTypeClose && + io_->read(reinterpret_cast(&box), sizeof(box)) == sizeof(box)) { position = io_->tell(); - box.length = getLong((byte*)&box.length, bigEndian); - box.type = getLong((byte*)&box.type, bigEndian); + box.length = getLong(reinterpret_cast(&box.length), bigEndian); + box.type = getLong(reinterpret_cast(&box.type), bigEndian); enforce(box.length <= io_->size()-io_->tell() , Exiv2::kerCorruptedMetadata); if (bPrint) { out << Internal::stringFormat("%8ld | %8ld | ", position - sizeof(box), - (size_t)box.length) + static_cast(box.length)) << toAscii(box.type) << " | "; bLF = true; if (box.type == kJp2BoxTypeClose) @@ -514,12 +514,12 @@ static void boxes_check(size_t b,size_t m) case kJp2BoxTypeJp2Header: { lf(out, bLF); - while (io_->read((byte*)&subBox, sizeof(subBox)) == sizeof(subBox) && - io_->tell() < position + (long)box.length) // don't read beyond the box! + while (io_->read(reinterpret_cast(&subBox), sizeof(subBox)) == sizeof(subBox) && + io_->tell() < position + static_cast(box.length)) // don't read beyond the box! { int address = io_->tell() - sizeof(subBox); - subBox.length = getLong((byte*)&subBox.length, bigEndian); - subBox.type = getLong((byte*)&subBox.type, bigEndian); + subBox.length = getLong(reinterpret_cast(&subBox.length), bigEndian); + subBox.type = getLong(reinterpret_cast(&subBox.type), bigEndian); if (subBox.length < sizeof(box) || subBox.length > io_->size() - io_->tell()) { throw Error(kerCorruptedMetadata); @@ -528,8 +528,8 @@ static void boxes_check(size_t b,size_t m) DataBuf data(subBox.length - sizeof(box)); io_->read(data.pData_, data.size_); if (bPrint) { - out << Internal::stringFormat("%8ld | %8ld | sub:", (size_t)address, - (size_t)subBox.length) + out << Internal::stringFormat("%8ld | %8ld | sub:", static_cast(address), + static_cast(subBox.length)) << toAscii(subBox.type) << " | " << Internal::binaryToString(makeSlice(data, 0, std::min(30L, data.size_))); bLF = true; @@ -540,14 +540,14 @@ static void boxes_check(size_t b,size_t m) if (bPrint) { out << " | pad:"; for (int i = 0; i < 3; i++) - out << " " << (int)data.pData_[i]; + out << " " << static_cast(data.pData_[i]); } long iccLength = getULong(data.pData_ + pad, bigEndian); if (bPrint) { out << " | iccLength:" << iccLength; } if (bICC) { - out.write((const char*)data.pData_ + pad, iccLength); + out.write(reinterpret_cast(data.pData_) + pad, iccLength); } } lf(out, bLF); @@ -555,7 +555,7 @@ static void boxes_check(size_t b,size_t m) } break; case kJp2BoxTypeUuid: { - if (io_->read((byte*)&uuid, sizeof(uuid)) == sizeof(uuid)) { + if (io_->read(reinterpret_cast(&uuid), sizeof(uuid)) == sizeof(uuid)) { bool bIsExif = memcmp(uuid.uuid, kJp2UuidExif, sizeof(uuid)) == 0; bool bIsIPTC = memcmp(uuid.uuid, kJp2UuidIptc, sizeof(uuid)) == 0; bool bIsXMP = memcmp(uuid.uuid, kJp2UuidXmp, sizeof(uuid)) == 0; @@ -601,7 +601,7 @@ static void boxes_check(size_t b,size_t m) } if (bIsXMP && bXMP) { - out.write((const char*)rawData.pData_, rawData.size_); + out.write(reinterpret_cast(rawData.pData_), rawData.size_); } } } break; @@ -648,24 +648,24 @@ static void boxes_check(size_t b,size_t m) long outlen = sizeof(Jp2BoxHeader) ; // now many bytes have we written to output? long inlen = sizeof(Jp2BoxHeader) ; // how many bytes have we read from boxBuf? enforce(sizeof(Jp2BoxHeader) <= static_cast(output.size_), Exiv2::kerCorruptedMetadata); - auto pBox = (Jp2BoxHeader*)boxBuf.pData_; - uint32_t length = getLong((byte*)&pBox->length, bigEndian); + auto pBox = reinterpret_cast(boxBuf.pData_); + uint32_t length = getLong(reinterpret_cast(&pBox->length), bigEndian); enforce(length <= static_cast(output.size_), Exiv2::kerCorruptedMetadata); uint32_t count = sizeof (Jp2BoxHeader); - auto p = (char*)boxBuf.pData_; + auto p = reinterpret_cast(boxBuf.pData_); bool bWroteColor = false ; while ( count < length || !bWroteColor ) { enforce(sizeof(Jp2BoxHeader) <= length - count, Exiv2::kerCorruptedMetadata); - auto pSubBox = (Jp2BoxHeader*)(p + count); + auto pSubBox = reinterpret_cast(p + count); // copy data. pointer could be into a memory mapped file which we will decode! Jp2BoxHeader subBox ; memcpy(&subBox,pSubBox,sizeof(subBox)); Jp2BoxHeader newBox = subBox; if ( count < length ) { - subBox.length = getLong((byte*)&subBox.length, bigEndian); - subBox.type = getLong((byte*)&subBox.type , bigEndian); + subBox.length = getLong(reinterpret_cast(&subBox.length), bigEndian); + subBox.type = getLong(reinterpret_cast(&subBox.type), bigEndian); #ifdef EXIV2_DEBUG_MESSAGES std::cout << "Jp2Image::encodeJp2Header subbox: "<< toAscii(subBox.type) << " length = " << subBox.length << std::endl; #endif @@ -687,8 +687,8 @@ static void boxes_check(size_t b,size_t m) uint32_t psize = 15; newlen = sizeof(newBox) + psize ; enforce(newlen <= static_cast(output.size_ - outlen), Exiv2::kerCorruptedMetadata); - ul2Data((byte*)&newBox.length,psize ,bigEndian); - ul2Data((byte*)&newBox.type ,newBox.type,bigEndian); + ul2Data(reinterpret_cast(&newBox.length), psize, bigEndian); + ul2Data(reinterpret_cast(&newBox.type), newBox.type, bigEndian); ::memcpy(output.pData_+outlen ,&newBox ,sizeof(newBox)); ::memcpy(output.pData_+outlen+sizeof(newBox) ,pad ,psize ); } else { @@ -696,8 +696,8 @@ static void boxes_check(size_t b,size_t m) uint32_t psize = 3; newlen = sizeof(newBox) + psize + iccProfile_.size_; enforce(newlen <= static_cast(output.size_ - outlen), Exiv2::kerCorruptedMetadata); - ul2Data((byte*)&newBox.length,newlen,bigEndian); - ul2Data((byte*)&newBox.type,newBox.type,bigEndian); + ul2Data(reinterpret_cast(&newBox.length), newlen, bigEndian); + ul2Data(reinterpret_cast(&newBox.type), newBox.type, bigEndian); ::memcpy(output.pData_+outlen ,&newBox ,sizeof(newBox) ); ::memcpy(output.pData_+outlen+sizeof(newBox) , pad ,psize ); ::memcpy(output.pData_+outlen+sizeof(newBox)+psize,iccProfile_.pData_,iccProfile_.size_); @@ -714,9 +714,9 @@ static void boxes_check(size_t b,size_t m) // allocate the correct number of bytes, copy the data and update the box header outBuf.alloc(outlen); ::memcpy(outBuf.pData_,output.pData_,outlen); - pBox = (Jp2BoxHeader*) outBuf.pData_; - ul2Data((byte*)&pBox->type,kJp2BoxTypeJp2Header,bigEndian); - ul2Data((byte*)&pBox->length,outlen,bigEndian); + pBox = reinterpret_cast(outBuf.pData_); + ul2Data(reinterpret_cast(&pBox->type), kJp2BoxTypeJp2Header, bigEndian); + ul2Data(reinterpret_cast(&pBox->length), outlen, bigEndian); } // Jp2Image::encodeJp2Header #ifdef __clang__ @@ -752,8 +752,7 @@ static void boxes_check(size_t b,size_t m) // FIXME: Andreas, why the loop do not stop when EOF is taken from _io. The loop go out by an exception // generated by a zero size data read. - while(io_->tell() < (long) io_->size()) - { + while (io_->tell() < static_cast(io_->size())) { #ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::Jp2Image::doWriteMetadata: Position: " << io_->tell() << " / " << io_->size() << std::endl; #endif @@ -781,7 +780,7 @@ static void boxes_check(size_t b,size_t m) std::cout << "Exiv2::Jp2Image::doWriteMetadata: Null Box size has been found. " "This is the last box of file." << std::endl; #endif - box.length = (uint32_t) (io_->size() - io_->tell() + 8); + box.length = static_cast(io_->size() - io_->tell() + 8); } if (box.length < 8) { @@ -805,8 +804,7 @@ static void boxes_check(size_t b,size_t m) throw Error(kerFailedToReadImageData); } - if (bufRead != (long)(box.length - 8)) - { + if (bufRead != static_cast(box.length - 8)) { #ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::Jp2Image::doWriteMetadata: Cannot read source file data" << std::endl; #endif diff --git a/src/jpgimage.cpp b/src/jpgimage.cpp index 35e3b406..51361df7 100644 --- a/src/jpgimage.cpp +++ b/src/jpgimage.cpp @@ -433,7 +433,7 @@ namespace Exiv2 { // Append to psBlob append(psBlob, psData.pData_, psData.size_); // Check whether psBlob is complete - if (!psBlob.empty() && Photoshop::valid(&psBlob[0], (long)psBlob.size())) { + if (!psBlob.empty() && Photoshop::valid(&psBlob[0], static_cast(psBlob.size()))) { --search; foundCompletePsData = true; } @@ -468,8 +468,8 @@ namespace Exiv2 { foundIccData = true ; --search ; } - int chunk = (int) buf.pData_[2+12]; - int chunks = (int) buf.pData_[2+13]; + int chunk = static_cast(buf.pData_[2 + 12]); + int chunks = static_cast(buf.pData_[2 + 13]); // ICC1v43_2010-12.pdf header is 14 bytes // header = "ICC_PROFILE\0" (12 bytes) // chunk/chunks are a single byte @@ -756,14 +756,14 @@ namespace Exiv2 { io_->seek(-bufRead, BasicIo::cur); io_->read(exif, size); uint32_t start = signature == "Exif" ? 8 : 6; - uint32_t max = (uint32_t)size - 1; + uint32_t max = static_cast(size) - 1; // is this an fff block? if (bFlir) { start = 0; bFlir = false; while (start < max) { - if (std::strcmp((const char*)(exif + start), "FFF") == 0) { + if (std::strcmp(reinterpret_cast(exif + start), "FFF") == 0) { bFlir = true; break; } @@ -844,7 +844,7 @@ namespace Exiv2 { std::cout << ' '; } #endif - auto count = (uint32_t)iptcDataSegs.size(); + auto count = static_cast(iptcDataSegs.size()); // figure out which blocks to copy auto pos = new uint64_t[count + 2]; @@ -876,7 +876,7 @@ namespace Exiv2 { uint64_t start = pos[2 * i] + 2; // step JPG 2 byte marker if (start == 2) start = 0; // read the file 2 byte SOI - long length = (long)(pos[2 * i + 1] - start); + long length = static_cast(pos[2 * i + 1] - start); if (length) { #ifdef EXIV2_DEBUG_MESSAGES std::cout << start << ":" << length << std::endl; @@ -1012,7 +1012,7 @@ namespace Exiv2 { // Append to psBlob append(psBlob, psData.pData_, psData.size_); // Check whether psBlob is complete - if (!psBlob.empty() && Photoshop::valid(&psBlob[0], (long)psBlob.size())) { + if (!psBlob.empty() && Photoshop::valid(&psBlob[0], static_cast(psBlob.size()))) { foundCompletePsData = true; } } else if (marker == com_ && skipCom == -1) { @@ -1047,7 +1047,7 @@ namespace Exiv2 { if (!foundCompletePsData && !psBlob.empty()) throw Error(kerNoImageInInputData); - search += (int)skipApp13Ps3.size() + (int)skipApp2Icc.size(); + search += static_cast(skipApp13Ps3.size()) + static_cast(skipApp2Icc.size()); if (comPos == 0) { if (marker == eoi_) @@ -1160,7 +1160,7 @@ namespace Exiv2 { tmpBuf[1] = app2_; int chunk_size = 256 * 256 - 40; // leave bytes for marker, header and padding - int sizeProfile = (int)iccProfile_.size_; + int sizeProfile = static_cast(iccProfile_.size_); int chunks = 1 + (sizeProfile - 1) / chunk_size; if (iccProfile_.size_ > 256 * chunk_size) throw Error(kerTooLargeJpegSegment, "IccProfile"); @@ -1180,8 +1180,8 @@ namespace Exiv2 { char pad[2]; pad[0] = chunk + 1; pad[1] = chunks; - outIo.write((const byte*)iccId_, 12); - outIo.write((const byte*)pad, 2); + outIo.write(reinterpret_cast(iccId_), 12); + outIo.write(reinterpret_cast(pad), 2); if (outIo.write(iccProfile_.pData_ + (chunk * chunk_size), bytes) != bytes) throw Error(kerImageWriteFailed); if (outIo.error()) @@ -1193,8 +1193,8 @@ namespace Exiv2 { if (foundCompletePsData || iptcData_.count() > 0) { // Set the new IPTC IRB, keeps existing IRBs but removes the // IPTC block if there is no new IPTC data to write - DataBuf newPsData = - Photoshop::setIptcIrb(!psBlob.empty() ? &psBlob[0] : 0, (long)psBlob.size(), iptcData_); + DataBuf newPsData = Photoshop::setIptcIrb(!psBlob.empty() ? &psBlob[0] : 0, + static_cast(psBlob.size()), iptcData_); const long maxChunkSize = 0xffff - 16; const byte* chunkStart = newPsData.pData_; const byte* chunkEnd = chunkStart + newPsData.size_; @@ -1246,7 +1246,8 @@ namespace Exiv2 { if (outIo.write(tmpBuf, 4) != 4) throw Error(kerImageWriteFailed); - if (outIo.write((byte*)comment_.data(), (long)comment_.length()) != (long)comment_.length()) + if (outIo.write(reinterpret_cast(const_cast(comment_.data())), + static_cast(comment_.length())) != static_cast(comment_.length())) throw Error(kerImageWriteFailed); if (outIo.putb(0) == EOF) throw Error(kerImageWriteFailed); diff --git a/src/minoltamn_int.cpp b/src/minoltamn_int.cpp index 96ebd0bc..ced6e845 100644 --- a/src/minoltamn_int.cpp +++ b/src/minoltamn_int.cpp @@ -1977,7 +1977,7 @@ namespace Exiv2 { { long result = -1; if ( metadata->findKey(ExifKey(key)) != metadata->end() ) { - result = (long) metadata->findKey(ExifKey(key))->toFloat(which); + result = static_cast(metadata->findKey(ExifKey(key))->toFloat(which)); } return result; } diff --git a/src/nikonmn_int.cpp b/src/nikonmn_int.cpp index 8c9eeefc..8588960a 100644 --- a/src/nikonmn_int.cpp +++ b/src/nikonmn_int.cpp @@ -300,7 +300,8 @@ namespace Exiv2 { if ( value.count() >= 9 ) { ByteOrder bo = getKeyString("Exif.MakerNote.ByteOrder",exifData) == "MM" ? bigEndian : littleEndian; byte p[4]; - for ( int n = 0 ; n < 4 ; n++ ) p[n] = (byte)value.toLong(6+n); + for (int n = 0; n < 4; n++) + p[n] = static_cast(value.toLong(6 + n)); os << getLong(p, bo); } @@ -331,9 +332,7 @@ namespace Exiv2 { else if (distance.second != 0) { std::ostringstream oss; oss.copyfmt(os); - os << std::fixed << std::setprecision(2) - << (float)distance.first / distance.second - << " m"; + os << std::fixed << std::setprecision(2) << static_cast(distance.first) / distance.second << " m"; os.copyfmt(oss); } else { @@ -355,9 +354,7 @@ namespace Exiv2 { else if (zoom.second != 0) { std::ostringstream oss; oss.copyfmt(os); - os << std::fixed << std::setprecision(1) - << (float)zoom.first / zoom.second - << "x"; + os << std::fixed << std::setprecision(1) << static_cast(zoom.first) / zoom.second << "x"; os.copyfmt(oss); } else { @@ -542,9 +539,7 @@ namespace Exiv2 { else if (zoom.second != 0) { std::ostringstream oss; oss.copyfmt(os); - os << std::fixed << std::setprecision(1) - << (float)zoom.first / zoom.second - << "x"; + os << std::fixed << std::setprecision(1) << static_cast(zoom.first) / zoom.second << "x"; os.copyfmt(oss); } else { @@ -1613,9 +1608,7 @@ namespace Exiv2 { else if (distance.second != 0) { std::ostringstream oss; oss.copyfmt(os); - os << std::fixed << std::setprecision(2) - << (float)distance.first / distance.second - << " m"; + os << std::fixed << std::setprecision(2) << static_cast(distance.first) / distance.second << " m"; os.copyfmt(oss); } else { @@ -1637,9 +1630,7 @@ namespace Exiv2 { else if (zoom.second != 0) { std::ostringstream oss; oss.copyfmt(os); - os << std::fixed << std::setprecision(1) - << (float)zoom.first / zoom.second - << "x"; + os << std::fixed << std::setprecision(1) << static_cast(zoom.first) / zoom.second << "x"; os.copyfmt(oss); } else { @@ -2599,16 +2590,16 @@ fmountlens[] = { */ if (metadata == 0) { - const unsigned char vid = (unsigned)value.toLong(0); + const unsigned char vid = static_cast(value.toLong(0)); - /* the 'FMntLens' name is added to the annonymous struct for - * fmountlens[] - * - * remember to name the struct when importing/updating the lens info - * from: - * - * www.rottmerhusen.com/objektives/lensid/files/c-header/fmountlens4.h - */ + /* the 'FMntLens' name is added to the annonymous struct for + * fmountlens[] + * + * remember to name the struct when importing/updating the lens info + * from: + * + * www.rottmerhusen.com/objektives/lensid/files/c-header/fmountlens4.h + */ const struct FMntLens* pf = fmountlens; while (pf->lid && pf->lensname) { if (pf->lid == vid) { @@ -2658,7 +2649,7 @@ fmountlens[] = { const std::string undefined("undefined") ; const std::string section ("nikon"); std::ostringstream lensIDStream; - lensIDStream << (int) raw[7]; + lensIDStream << static_cast(raw[7]); if ( Internal::readExiv2Config(section,lensIDStream.str(),undefined) != undefined ) { return os << Internal::readExiv2Config(section,lensIDStream.str(),undefined); } @@ -2838,8 +2829,8 @@ fmountlens[] = { std::ostringstream oss; oss.copyfmt(os); char sign = value.toLong() < 0 ? '-' : '+'; - long h = long(std::abs((int)(value.toFloat() / 60.0F))) % 24; - long min = long(std::abs( (int) (value.toFloat()-h*60) ))%60; + long h = long(std::abs(static_cast(value.toFloat() / 60.0F))) % 24; + long min = long(std::abs(static_cast(value.toFloat() - h * 60))) % 60; os << std::fixed << "UTC " << sign << std::setw(2) << std::setfill('0') << h << ":" << std::setw(2) << std::setfill('0') << min; os.copyfmt(oss); diff --git a/src/olympusmn_int.cpp b/src/olympusmn_int.cpp index 62f8a595..834d19b9 100644 --- a/src/olympusmn_int.cpp +++ b/src/olympusmn_int.cpp @@ -1199,7 +1199,7 @@ namespace Exiv2 { return os << value; } if (value.count() == 1) { - auto l0 = (short)value.toLong(0); + auto l0 = static_cast(value.toLong(0)); if (l0 == 1) { os << _("Auto"); } @@ -1208,8 +1208,8 @@ namespace Exiv2 { } } else if (value.count() == 2) { - auto l0 = (short)value.toLong(0); - auto l1 = (short)value.toLong(1); + auto l0 = static_cast(value.toLong(0)); + auto l1 = static_cast(value.toLong(1)); if (l0 == 1) { switch (l1) { case 0: os << _("Auto"); break; @@ -1379,9 +1379,9 @@ namespace Exiv2 { return os << value; } - byte v0 = (byte)value.toLong(0); - byte v2 = (byte)value.toLong(2); - byte v3 = (byte)value.toLong(3); + byte v0 = static_cast(value.toLong(0)); + byte v2 = static_cast(value.toLong(2)); + byte v3 = static_cast(value.toLong(3)); for (auto&& type : lensTypes) { if (type.val[0] == v0 && type.val[1] == v2 && type.val[2] == v3) { @@ -1400,7 +1400,7 @@ namespace Exiv2 { char ch; int size = value.size(); - for (int i = 0; i < size && ((ch = (char)value.toLong(i)) != '\0'); i++) { + for (int i = 0; i < size && ((ch = static_cast(value.toLong(i))) != '\0'); i++) { os << ch; } return os; @@ -1425,8 +1425,8 @@ namespace Exiv2 { return os << value; } - byte v0 = (byte)value.toLong(0); - byte v2 = (byte)value.toLong(2); + byte v0 = static_cast(value.toLong(0)); + byte v2 = static_cast(value.toLong(2)); for (auto&& model : extenderModels) { if (model.val[0] == v0 && model.val[1] == v2) { @@ -1466,13 +1466,13 @@ namespace Exiv2 { if (value.count() < 1 || value.typeId() != unsignedShort) { return os << "(" << value << ")"; } - auto v = (uint16_t)value.toLong(0); + auto v = static_cast(value.toLong(0)); // If value 2 is present, it is used instead of value 1. if (value.count() > 1) { std::string p; // Used to enable ',' separation - v = (uint16_t)value.toLong(1); + v = static_cast(value.toLong(1)); for (auto&& mode : focusModes1) { if ((v &mode.val) != 0) { if (!p.empty()) { @@ -1546,8 +1546,8 @@ namespace Exiv2 { return os << value; } - auto v0 = (uint16_t)value.toLong(0); - auto v1 = (uint16_t)value.toLong(1); + auto v0 = static_cast(value.toLong(0)); + auto v1 = static_cast(value.toLong(1)); for (auto&& filter : artFilters) { if (filter.val[0] == v0 && filter.val[1] == v1) { @@ -1591,7 +1591,7 @@ namespace Exiv2 { std::ostringstream oss; oss.copyfmt(os); os << std::fixed << std::setprecision(2); - os << (float)distance.first/1000 << " m"; + os << static_cast(distance.first) / 1000 << " m"; os.copyfmt(oss); } os.flags(f); @@ -1659,7 +1659,7 @@ value, const ExifData* metadata) } } - auto v = (uint16_t)value.toLong(0); + auto v = static_cast(value.toLong(0)); if (!E3_E30model) { for (auto&& point : afPoints) { diff --git a/src/orfimage.cpp b/src/orfimage.cpp index 77aae0a0..550f72c8 100644 --- a/src/orfimage.cpp +++ b/src/orfimage.cpp @@ -108,11 +108,8 @@ namespace Exiv2 { throw Error(kerNotAnImage, "ORF"); } clearMetadata(); - ByteOrder bo = OrfParser::decode(exifData_, - iptcData_, - xmpData_, - io_->mmap(), - (uint32_t) io_->size()); + ByteOrder bo = + OrfParser::decode(exifData_, iptcData_, xmpData_, io_->mmap(), static_cast(io_->size())); setByteOrder(bo); } // OrfImage::readMetadata @@ -129,7 +126,7 @@ namespace Exiv2 { // Ensure that this is the correct image type if (isOrfType(*io_, false)) { pData = io_->mmap(true); - size = (long) io_->size(); + size = static_cast(io_->size()); OrfHeader orfHeader; if (0 == orfHeader.read(pData, 8)) { bo = orfHeader.byteOrder(); diff --git a/src/pentaxmn_int.cpp b/src/pentaxmn_int.cpp index e1e2ffd5..059ad1ae 100644 --- a/src/pentaxmn_int.cpp +++ b/src/pentaxmn_int.cpp @@ -1206,7 +1206,7 @@ namespace Exiv2 { { long result = -1; if ( metadata->findKey(ExifKey(key)) != metadata->end() ) { - result = (long) metadata->findKey(ExifKey(key))->toFloat(0); + result = static_cast(metadata->findKey(ExifKey(key))->toFloat(0)); } return result; } diff --git a/src/pgfimage.cpp b/src/pgfimage.cpp index c853d596..b65a1990 100644 --- a/src/pgfimage.cpp +++ b/src/pgfimage.cpp @@ -67,11 +67,11 @@ namespace Exiv2 { static uint32_t byteSwap_(Exiv2::DataBuf& buf,size_t offset,bool bSwap) { uint32_t v; - auto p = (char*)&v; + auto p = reinterpret_cast(&v); int i; for ( i = 0 ; i < 4 ; i++ ) p[i] = buf.pData_[offset+i]; uint32_t result = byteSwap_(v,bSwap); - p = (char*) &result; + p = reinterpret_cast(&result); for ( i = 0 ; i < 4 ; i++ ) buf.pData_[offset+i] = p[i]; return result; } @@ -198,7 +198,7 @@ namespace Exiv2 { img->setIptcData(iptcData_); img->setXmpData(xmpData_); img->writeMetadata(); - long imgSize = (long) img->io().size(); + long imgSize = static_cast(img->io().size()); DataBuf imgBuf = img->io().read(imgSize); #ifdef EXIV2_DEBUG_MESSAGES @@ -270,7 +270,7 @@ namespace Exiv2 { if (iIo.error()) throw Error(kerFailedToReadImageData); if (bufRead != buffer.size_) throw Error(kerInputDataReadFailed); - int headerSize = (int) byteSwap_(buffer,0,bSwap_); + int 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 42e61ba0..a02e27f2 100644 --- a/src/pngchunk_int.cpp +++ b/src/pngchunk_int.cpp @@ -68,8 +68,8 @@ namespace Exiv2 { // Extract image width and height from IHDR chunk. - *outWidth = getLong((const byte*)data.pData_, bigEndian); - *outHeight = getLong((const byte*)data.pData_ + 4, bigEndian); + *outWidth = getLong(data.pData_, bigEndian); + *outHeight = getLong(data.pData_ + 4, bigEndian); } // PngChunk::decodeIHDRChunk @@ -82,7 +82,7 @@ namespace Exiv2 { #ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::PngChunk::decodeTXTChunk: TXT chunk data: " - << std::string((const char*)arr.pData_, arr.size_) << std::endl; + << std::string(reinterpret_cast(arr.pData_), arr.size_) << std::endl; #endif parseChunkContent(pImage, key.pData_, key.size_, arr); @@ -95,7 +95,7 @@ namespace Exiv2 { #ifdef EXIV2_DEBUG_MESSAGES std::cout << "Exiv2::PngChunk::decodeTXTChunk: TXT chunk key: " - << std::string((const char*)key.pData_, key.size_) << std::endl; + << std::string(reinterpret_cast(key.pData_), key.size_) << std::endl; #endif return parseTXTChunk(data, key.size_, type); @@ -182,17 +182,17 @@ namespace Exiv2 { // language description string after the compression technique spec const size_t languageTextMaxSize = data.size_ - keysize - 3; - std::string languageText = - string_from_unterminated((const char*)(data.pData_ + Safe::add(keysize, 3)), languageTextMaxSize); + std::string languageText = string_from_unterminated( + reinterpret_cast(data.pData_ + Safe::add(keysize, 3)), languageTextMaxSize); const size_t languageTextSize = languageText.size(); enforce(static_cast(data.size_) >= Safe::add(static_cast(Safe::add(keysize, 4)), languageTextSize), Exiv2::kerCorruptedMetadata); // translated keyword string after the language description - std::string translatedKeyText = - string_from_unterminated((const char*)(data.pData_ + keysize + 3 + languageTextSize + 1), - data.size_ - (keysize + 3 + languageTextSize + 1)); + std::string translatedKeyText = string_from_unterminated( + reinterpret_cast(data.pData_ + keysize + 3 + languageTextSize + 1), + data.size_ - (keysize + 3 + languageTextSize + 1)); const auto translatedKeyTextSize = static_cast(translatedKeyText.size()); if ((compressionFlag == 0x00) || (compressionFlag == 0x01 && compressionMethod == 0x00)) { @@ -259,8 +259,7 @@ namespace Exiv2 { const byte exifHeader[] = { 0x45, 0x78, 0x69, 0x66, 0x00, 0x00 }; long pos = -1; - for (long i=0 ; i < length-(long)sizeof(exifHeader) ; i++) - { + for (long i = 0; i < length - static_cast(sizeof(exifHeader)); i++) { if (memcmp(exifHeader, &exifData.pData_[i], sizeof(exifHeader)) == 0) { pos = i; @@ -491,9 +490,8 @@ namespace Exiv2 { DataBuf arr; do { arr.alloc(compressedLen); - zlibResult = compress2(arr.pData_, &compressedLen, - (const Bytef*)text.data(), static_cast(text.size()), - Z_BEST_COMPRESSION); + zlibResult = compress2(arr.pData_, &compressedLen, reinterpret_cast(text.data()), + static_cast(text.size()), Z_BEST_COMPRESSION); switch (zlibResult) { case Z_OK: @@ -515,7 +513,7 @@ namespace Exiv2 { } } while (zlibResult == Z_BUF_ERROR); - return std::string((const char*)arr.pData_, arr.size_); + return std::string(reinterpret_cast(arr.pData_), arr.size_); } // PngChunk::zlibCompress @@ -550,11 +548,12 @@ namespace Exiv2 { // Calculate CRC on chunk type and chunk data std::string crcData = chunkType + chunkData; uLong tmp = crc32(0L, Z_NULL, 0); - tmp = crc32(tmp, (const Bytef*)crcData.data(), static_cast(crcData.size())); + tmp = crc32(tmp, reinterpret_cast(crcData.data()), static_cast(crcData.size())); byte crc[4]; ul2Data(crc, tmp, bigEndian); // Assemble the chunk - return std::string((const char*)length, 4) + chunkType + chunkData + std::string((const char*)crc, 4); + return std::string(reinterpret_cast(length), 4) + chunkType + chunkData + + std::string(reinterpret_cast(crc), 4); } // PngChunk::makeAsciiTxtChunk @@ -587,11 +586,12 @@ namespace Exiv2 { std::string chunkType = "iTXt"; std::string crcData = chunkType + chunkData; uLong tmp = crc32(0L, Z_NULL, 0); - tmp = crc32(tmp, (const Bytef*)crcData.data(), static_cast(crcData.size())); + tmp = crc32(tmp, reinterpret_cast(crcData.data()), static_cast(crcData.size())); byte crc[4]; ul2Data(crc, tmp, bigEndian); // Assemble the chunk - return std::string((const char*)length, 4) + chunkType + chunkData + std::string((const char*)crc, 4); + return std::string(reinterpret_cast(length), 4) + chunkType + chunkData + + std::string(reinterpret_cast(crc), 4); } // PngChunk::makeUtf8TxtChunk @@ -614,8 +614,8 @@ namespace Exiv2 { return info; } - const char *sp = (char*) text.pData_+1; // current byte (space pointer) - const char *eot = (char*) text.pData_+text.size_; // end of text + const char* sp = reinterpret_cast(text.pData_) + 1; // current byte (space pointer) + const char* eot = reinterpret_cast(text.pData_) + text.size_; // end of text if (sp >= eot) { return DataBuf(); @@ -690,8 +690,7 @@ namespace Exiv2 { unsigned char *dp = info.pData_; // decode pointer unsigned int nibbles = length * 2; - for (long i = 0; i < (long) nibbles; i++) - { + for (long i = 0; i < static_cast(nibbles); i++) { enforce(sp < eot, Exiv2::kerCorruptedMetadata); while (*sp < '0' || (*sp > '9' && *sp < 'a') || *sp > 'f') { @@ -708,9 +707,9 @@ namespace Exiv2 { } if (i%2 == 0) - *dp = (unsigned char) (16*unhex[(int) *sp++]); + *dp = static_cast(16 * unhex[static_cast(*sp++)]); else - (*dp++) += unhex[(int) *sp++]; + (*dp++) += unhex[static_cast(*sp++)]; } return info; diff --git a/src/pngimage.cpp b/src/pngimage.cpp index a89fdd74..0cf1983b 100644 --- a/src/pngimage.cpp +++ b/src/pngimage.cpp @@ -105,7 +105,7 @@ namespace Exiv2 { result.alloc(uncompressedLen); zlibResult = uncompress(result.pData_,&uncompressedLen,bytes,length); // if result buffer is large than necessary, redo to fit perfectly. - if (zlibResult == Z_OK && (long) uncompressedLen < result.size_ ) { + if (zlibResult == Z_OK && static_cast(uncompressedLen) < result.size_) { result.free(); result.alloc(uncompressedLen); @@ -237,7 +237,7 @@ namespace Exiv2 { out << " address | chunk | length | data | checksum" << std::endl; } - const long imgSize = (long) io_->size(); + const long imgSize = static_cast(io_->size()); DataBuf cheaderBuf(8); while( !io_->eof() && ::strcmp(chType,"IEND") ) { @@ -288,11 +288,11 @@ namespace Exiv2 { enforce(bufRead == 4, kerFailedToReadImageData); io_->seek(restore, BasicIo::beg) ;// restore file pointer - out << Internal::stringFormat("%8d | %-5s |%8d | " - ,(uint32_t)address, chType,dataOffset) + out << Internal::stringFormat("%8d | %-5s |%8d | ", static_cast(address), chType, + dataOffset) << dataString - << Internal::stringFormat(" | 0x%02x%02x%02x%02x" - ,checksum[0],checksum[1],checksum[2],checksum[3]) + << Internal::stringFormat(" | 0x%02x%02x%02x%02x", checksum[0], checksum[1], checksum[2], + checksum[3]) << std::endl; } @@ -320,7 +320,8 @@ namespace Exiv2 { bufRead = io_->read(data,dataOffset); enforce(bufRead == static_cast(dataOffset), kerFailedToReadImageData); io_->seek(restore, BasicIo::beg); - uint32_t name_l = (uint32_t) std::strlen((const char*)data)+1; // leading string length + uint32_t name_l = static_cast(std::strlen(reinterpret_cast(data))) + + 1; // leading string length enforce(name_l <= dataOffset, kerCorruptedMetadata); uint32_t start = name_l; @@ -369,19 +370,19 @@ namespace Exiv2 { DataBuf s(dataBuf.size_+1); // allocate buffer with an extra byte memcpy(s.pData_,dataBuf.pData_,dataBuf.size_);// copy in the dataBuf s.pData_[dataBuf.size_] = 0 ; // nul terminate it - const auto str = (const char*)s.pData_; // give it name - out << Internal::indent(depth) << (const char*) buff.pData_ << ": " << str ; + const auto str = reinterpret_cast(s.pData_); // give it name + out << Internal::indent(depth) << reinterpret_cast(buff.pData_) << ": " << str; bLF=true; } if ( bICC || bComm ) { - out.write((const char*) dataBuf.pData_,dataBuf.size_); + out.write(reinterpret_cast(dataBuf.pData_), dataBuf.size_); bLF = bComm ; } if ( bDesc && iTXt ) { DataBuf decoded = PngChunk::decodeTXTChunk(buff,PngChunk::iTXt_Chunk ); - out.write((const char*)decoded.pData_,decoded.size_); + out.write(reinterpret_cast(decoded.pData_), decoded.size_); bLF = true; } if ( eXIf && option == kpsRecursive ) { @@ -429,7 +430,7 @@ namespace Exiv2 { } clearMetadata(); - const long imgSize = (long) io_->size(); + const long imgSize = static_cast(io_->size()); DataBuf cheaderBuf(8); // Chunk header: 4 bytes (data size) + 4 bytes (chunk type). while(!io_->eof()) @@ -572,7 +573,8 @@ namespace Exiv2 { memcpy(chunkBuf.pData_, cheaderBuf.pData_, 8); // Copy header. bufRead = io_->read(chunkBuf.pData_ + 8, dataOffset + 4); // Extract chunk data + CRC if (io_->error()) throw Error(kerFailedToReadImageData); - if (bufRead != (long)(dataOffset + 4)) throw Error(kerInputDataReadFailed); + if (bufRead != static_cast(dataOffset + 4)) + throw Error(kerInputDataReadFailed); char szChunk[5]; memcpy(szChunk,cheaderBuf.pData_ + 4,4); @@ -602,8 +604,8 @@ namespace Exiv2 { { // Update Comment data to a new PNG chunk std::string chunk = PngChunk::makeMetadataChunk(comment_, mdComment); - if (outIo.write((const byte*)chunk.data(), static_cast(chunk.size())) != (long)chunk.size()) - { + if (outIo.write(reinterpret_cast(chunk.data()), static_cast(chunk.size())) != + static_cast(chunk.size())) { throw Error(kerImageWriteFailed); } } @@ -615,11 +617,11 @@ namespace Exiv2 { ExifParser::encode(blob, littleEndian, exifData_); if (!blob.empty()) { static const char exifHeader[] = { 0x45, 0x78, 0x69, 0x66, 0x00, 0x00 }; - std::string rawExif = std::string(exifHeader, 6) - + std::string((const char*)&blob[0], blob.size()); + std::string rawExif = std::string(exifHeader, 6) + + std::string(reinterpret_cast(&blob[0]), blob.size()); std::string chunk = PngChunk::makeMetadataChunk(rawExif, mdExif); - if (outIo.write((const byte*)chunk.data(), static_cast(chunk.size())) != (long)chunk.size()) - { + if (outIo.write(reinterpret_cast(chunk.data()), static_cast(chunk.size())) != + static_cast(chunk.size())) { throw Error(kerImageWriteFailed); } } @@ -631,10 +633,10 @@ namespace Exiv2 { DataBuf newPsData = Photoshop::setIptcIrb(0, 0, iptcData_); if (newPsData.size_ > 0) { - std::string rawIptc((const char*)newPsData.pData_, newPsData.size_); + std::string rawIptc(reinterpret_cast(newPsData.pData_), newPsData.size_); std::string chunk = PngChunk::makeMetadataChunk(rawIptc, mdIptc); - if (outIo.write((const byte*)chunk.data(), static_cast(chunk.size())) != (long)chunk.size()) - { + if (outIo.write(reinterpret_cast(chunk.data()), static_cast(chunk.size())) != + static_cast(chunk.size())) { throw Error(kerImageWriteFailed); } } @@ -643,8 +645,8 @@ namespace Exiv2 { if ( iccProfileDefined() ) { DataBuf compressed; if ( zlibToCompressed(iccProfile_.pData_,iccProfile_.size_,compressed) ) { - const auto nullComp = (const byte*)"\0\0"; - const auto type = (const byte*)"iCCP"; + const auto nullComp = reinterpret_cast("\0\0"); + const auto type = reinterpret_cast("iCCP"); const auto nameLength = static_cast(profileName_.size()); const uint32_t chunkLength = nameLength + 2 + compressed.size_ ; byte length[4]; @@ -653,9 +655,9 @@ namespace Exiv2 { // calculate CRC uLong tmp = crc32(0L, Z_NULL, 0); tmp = crc32(tmp, type, 4); - tmp = crc32(tmp, (const Bytef*)profileName_.data(), nameLength); + tmp = crc32(tmp, reinterpret_cast(profileName_.data()), nameLength); tmp = crc32(tmp, nullComp, 2); - tmp = crc32(tmp, (const Bytef*)compressed.pData_,compressed.size_); + tmp = crc32(tmp, compressed.pData_, compressed.size_); byte crc[4]; ul2Data(crc, tmp, bigEndian); @@ -685,7 +687,8 @@ namespace Exiv2 { if (!xmpPacket_.empty()) { // Update XMP data to a new PNG chunk std::string chunk = PngChunk::makeMetadataChunk(xmpPacket_, mdXmp); - if (outIo.write((const byte*)chunk.data(), static_cast(chunk.size())) != (long)chunk.size()) { + if (outIo.write(reinterpret_cast(chunk.data()), static_cast(chunk.size())) != + static_cast(chunk.size())) { throw Error(kerImageWriteFailed); } } diff --git a/src/preview.cpp b/src/preview.cpp index be8a7d16..8aebd25c 100644 --- a/src/preview.cpp +++ b/src/preview.cpp @@ -408,7 +408,7 @@ namespace { PreviewId Loader::getNumLoaders() { - return (PreviewId)EXV_COUNTOF(loaderList_); + return static_cast EXV_COUNTOF(loaderList_); } LoaderNative::LoaderNative(PreviewId id, const Image &image, int parIdx) @@ -465,7 +465,7 @@ namespace { } IoCloser closer(io); const byte* data = io.mmap(); - if ((long)io.size() < nativePreview_.position_ + static_cast(nativePreview_.size_)) { + if (static_cast(io.size()) < nativePreview_.position_ + static_cast(nativePreview_.size_)) { #ifndef SUPPRESS_WARNINGS EXV_WARNING << "Invalid native preview position or size.\n"; #endif @@ -827,7 +827,7 @@ namespace { IptcData emptyIptc; XmpData emptyXmp; TiffParser::encode(mio, 0, 0, Exiv2::littleEndian, preview, emptyIptc, emptyXmp); - return DataBuf(mio.mmap(), (long) mio.size()); + return DataBuf(mio.mmap(), static_cast(mio.size())); } LoaderXmpJpeg::LoaderXmpJpeg(PreviewId id, const Image &image, int parIdx) @@ -932,12 +932,13 @@ namespace { std::array decodeBase64Table; decodeBase64Table.fill(invalid); for (unsigned long i = 0; i < 64; i++) - decodeBase64Table[(unsigned char)encodeBase64Table[i]] = i; + decodeBase64Table[static_cast(encodeBase64Table[i])] = i; // calculate dest size unsigned long validSrcSize = 0; for (unsigned long srcPos = 0; srcPos < srcSize; srcPos++) { - if (decodeBase64Table[(unsigned char)src[srcPos]] != invalid) validSrcSize++; + if (decodeBase64Table[static_cast(src[srcPos])] != invalid) + validSrcSize++; } if (validSrcSize > ULONG_MAX / 3) return DataBuf(); // avoid integer overflow const unsigned long destSize = (validSrcSize * 3) / 4; @@ -950,7 +951,7 @@ namespace { for (unsigned long srcPos = 0, destPos = 0; destPos < destSize;) { unsigned long buffer = 0; for (int bufferPos = 3; bufferPos >= 0 && srcPos < srcSize; srcPos++) { - unsigned long srcValue = decodeBase64Table[(unsigned char)src[srcPos]]; + unsigned long srcValue = decodeBase64Table[static_cast(src[srcPos])]; if (srcValue == invalid) continue; buffer |= srcValue << (bufferPos * 6); bufferPos--; diff --git a/src/rafimage.cpp b/src/rafimage.cpp index 9b03c291..f4b6840c 100644 --- a/src/rafimage.cpp +++ b/src/rafimage.cpp @@ -118,11 +118,8 @@ namespace Exiv2 { io_->read(magicdata, 16); magicdata[16] = 0; { - out << Internal::indent(depth) - << Internal::stringFormat(format,address, 16, 0) - << " magic : " - << (char*) magicdata - << std::endl; + out << Internal::indent(depth) << Internal::stringFormat(format, address, 16, 0) + << " magic : " << reinterpret_cast(magicdata) << std::endl; } address = io_->tell(); @@ -130,11 +127,8 @@ namespace Exiv2 { io_->read(data1, 4); data1[4] = 0; { - out << Internal::indent(depth) - << Internal::stringFormat(format,address, 4, 16) - << " data1 : " - << std::string((char*)&data1) - << std::endl; + out << Internal::indent(depth) << Internal::stringFormat(format, address, 4, 16) + << " data1 : " << std::string(reinterpret_cast(&data1)) << std::endl; } address = io_->tell(); @@ -142,11 +136,8 @@ namespace Exiv2 { io_->read(data2, 8); data2[8] = 0; { - out << Internal::indent(depth) - << Internal::stringFormat(format,address, 8, 20) - << " data2 : " - << std::string((char*)&data2) - << std::endl; + out << Internal::indent(depth) << Internal::stringFormat(format, address, 8, 20) + << " data2 : " << std::string(reinterpret_cast(&data2)) << std::endl; } address = io_->tell(); @@ -154,11 +145,8 @@ namespace Exiv2 { io_->read(camdata, 32); camdata[32] = 0; { - out << Internal::indent(depth) - << Internal::stringFormat(format,address, 32, 28) - << " camera : " - << std::string((char*)&camdata) - << std::endl; + out << Internal::indent(depth) << Internal::stringFormat(format, address, 32, 28) + << " camera : " << std::string(reinterpret_cast(&camdata)) << std::endl; } address = io_->tell(); @@ -166,11 +154,8 @@ namespace Exiv2 { io_->read(dir_version, 4); dir_version[4] = 0; { - out << Internal::indent(depth) - << Internal::stringFormat(format,address, 4, 60) - << " version : " - << std::string((char*)&dir_version) - << std::endl; + out << Internal::indent(depth) << Internal::stringFormat(format, address, 4, 60) + << " version : " << std::string(reinterpret_cast(&dir_version)) << std::endl; } address = io_->tell(); @@ -192,8 +177,8 @@ namespace Exiv2 { address2 = io_->tell(); io_->read(jpg_img_length, 4); - long jpg_img_off = Exiv2::getULong((const byte *) jpg_img_offset, bigEndian); - long jpg_img_len = Exiv2::getULong((const byte *) jpg_img_length, bigEndian); + long jpg_img_off = Exiv2::getULong(jpg_img_offset, bigEndian); + long jpg_img_len = Exiv2::getULong(jpg_img_length, bigEndian); std::stringstream j_off; std::stringstream j_len; j_off << jpg_img_off; @@ -217,8 +202,8 @@ namespace Exiv2 { byte cfa_header_length [4]; address2 = io_->tell(); io_->read(cfa_header_length, 4); - long cfa_hdr_off = Exiv2::getULong((const byte *) cfa_header_offset, bigEndian); - long cfa_hdr_len = Exiv2::getULong((const byte *) cfa_header_length, bigEndian); + long cfa_hdr_off = Exiv2::getULong(cfa_header_offset, bigEndian); + long cfa_hdr_len = Exiv2::getULong(cfa_header_length, bigEndian); std::stringstream ch_off; std::stringstream ch_len; ch_off << cfa_hdr_off; @@ -242,8 +227,8 @@ namespace Exiv2 { byte cfa_length [4]; address2 = io_->tell(); io_->read(cfa_length, 4); - long cfa_off = Exiv2::getULong((const byte *) cfa_offset, bigEndian); - long cfa_len = Exiv2::getULong((const byte *) cfa_length, bigEndian); + long cfa_off = Exiv2::getULong(cfa_offset, bigEndian); + long cfa_len = Exiv2::getULong(cfa_length, bigEndian); std::stringstream c_off; std::stringstream c_len; c_off << cfa_off; @@ -317,8 +302,8 @@ namespace Exiv2 { if (io_->read(jpg_img_offset, 4) != 4) throw Error(kerFailedToReadImageData); byte jpg_img_length [4]; if (io_->read(jpg_img_length, 4) != 4) throw Error(kerFailedToReadImageData); - uint32_t jpg_img_off_u32 = Exiv2::getULong((const byte *) jpg_img_offset, bigEndian); - uint32_t jpg_img_len_u32 = Exiv2::getULong((const byte *) jpg_img_length, bigEndian); + uint32_t jpg_img_off_u32 = Exiv2::getULong(jpg_img_offset, bigEndian); + uint32_t jpg_img_len_u32 = Exiv2::getULong(jpg_img_length, bigEndian); enforce(Safe::add(jpg_img_off_u32, jpg_img_len_u32) <= io_->size(), kerCorruptedMetadata); diff --git a/src/rw2image.cpp b/src/rw2image.cpp index d74d3356..9afd6cbd 100644 --- a/src/rw2image.cpp +++ b/src/rw2image.cpp @@ -119,11 +119,8 @@ namespace Exiv2 { throw Error(kerNotAnImage, "RW2"); } clearMetadata(); - ByteOrder bo = Rw2Parser::decode(exifData_, - iptcData_, - xmpData_, - io_->mmap(), - (uint32_t) io_->size()); + ByteOrder bo = + Rw2Parser::decode(exifData_, iptcData_, xmpData_, io_->mmap(), static_cast(io_->size())); setByteOrder(bo); // A lot more metadata is hidden in the embedded preview image diff --git a/src/tags_int.cpp b/src/tags_int.cpp index f72e68dd..5d0fa44c 100644 --- a/src/tags_int.cpp +++ b/src/tags_int.cpp @@ -2643,7 +2643,7 @@ namespace Exiv2 { return os << "(" << value << ")"; } } - const float ss = (float)sec.first / sec.second; + const float ss = static_cast(sec.first) / sec.second; os << dd << " deg "; os << mm << "' "; std::ostringstream oss; @@ -2676,7 +2676,7 @@ namespace Exiv2 { } } - std::string str((const char*)buf.pData_, buf.size_); + std::string str(reinterpret_cast(buf.pData_), buf.size_); cnv = convertStringCharset(str, "UCS-2LE", "UTF-8"); if (cnv) os << str; } @@ -2934,7 +2934,7 @@ namespace Exiv2 { { Rational bias = value.toRational(); - if (bias.first == 0 || bias.first == (int32_t)0x80000000 ) { + if (bias.first == 0 || bias.first == static_cast(0x80000000)) { os << "0 EV"; } else if (bias.second <= 0) { os << "(" << bias.first << "/" << bias.second << ")"; @@ -2964,9 +2964,7 @@ namespace Exiv2 { else if (distance.second != 0) { std::ostringstream oss; oss.copyfmt(os); - os << std::fixed << std::setprecision(2) - << (float)distance.first / distance.second - << " m"; + os << std::fixed << std::setprecision(2) << static_cast(distance.first) / distance.second << " m"; os.copyfmt(oss); } else { @@ -3006,9 +3004,7 @@ namespace Exiv2 { if (length.second != 0) { std::ostringstream oss; oss.copyfmt(os); - os << std::fixed << std::setprecision(1) - << (float)length.first / length.second - << " mm"; + os << std::fixed << std::setprecision(1) << static_cast(length.first) / length.second << " mm"; os.copyfmt(oss); } else { @@ -3112,8 +3108,7 @@ namespace Exiv2 { else { std::ostringstream oss; oss.copyfmt(os); - os << std::fixed << std::setprecision(1) - << (float)zoom.first / zoom.second; + os << std::fixed << std::setprecision(1) << static_cast(zoom.first) / zoom.second; os.copyfmt(oss); } os.flags(f); diff --git a/src/tiffimage.cpp b/src/tiffimage.cpp index 58922289..e227b96f 100644 --- a/src/tiffimage.cpp +++ b/src/tiffimage.cpp @@ -181,11 +181,8 @@ namespace Exiv2 { } clearMetadata(); - ByteOrder bo = TiffParser::decode(exifData_, - iptcData_, - xmpData_, - io_->mmap(), - (uint32_t) io_->size()); + ByteOrder bo = + TiffParser::decode(exifData_, iptcData_, xmpData_, io_->mmap(), static_cast(io_->size())); setByteOrder(bo); // read profile from the metadata @@ -215,7 +212,7 @@ namespace Exiv2 { // Ensure that this is the correct image type if (isTiffType(*io_, false)) { pData = io_->mmap(true); - size = (long) io_->size(); + size = static_cast(io_->size()); TiffHeader tiffHeader; if (0 == tiffHeader.read(pData, 8)) { bo = tiffHeader.byteOrder(); diff --git a/src/tiffvisitor_int.cpp b/src/tiffvisitor_int.cpp index 267d37a4..b5107270 100644 --- a/src/tiffvisitor_int.cpp +++ b/src/tiffvisitor_int.cpp @@ -457,8 +457,8 @@ namespace Exiv2 { std::vector ints; std::vector uint; for (int i = 0; i < object->pValue()->count(); i++) { - ints.push_back((int16_t) object->pValue()->toLong(i)); - uint.push_back((uint16_t) object->pValue()->toLong(i)); + ints.push_back(static_cast(object->pValue()->toLong(i))); + uint.push_back(static_cast(object->pValue()->toLong(i))); } // Check this is AFInfo2 (ints[0] = bytes in object) if ( ints[0] != object->pValue()->count()*2 ) return ; @@ -1597,7 +1597,7 @@ namespace Exiv2 { // #1143 Write a "hollow" buffer for the preview image // Sadly: we don't know the exact location of the image in the source (it's near offset) // And neither TiffReader nor TiffEntryBase have access to the BasicIo object being processed - auto buffer = (byte*)::malloc(isize); + auto buffer = static_cast(::malloc(isize)); ::memset(buffer,0,isize); v->read(buffer,isize, byteOrder()); ::free(buffer); diff --git a/src/types.cpp b/src/types.cpp index addf8274..6e5e34d0 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -277,22 +277,23 @@ namespace Exiv2 { uint32_t getULong(const byte* buf, ByteOrder byteOrder) { if (byteOrder == littleEndian) { - return (byte)buf[3] << 24 | (byte)buf[2] << 16 - | (byte)buf[1] << 8 | (byte)buf[0]; + return buf[3] << 24 | buf[2] << 16 | buf[1] << 8 | buf[0]; } - return (byte)buf[0] << 24 | (byte)buf[1] << 16 | (byte)buf[2] << 8 | (byte)buf[3]; + return buf[0] << 24 | buf[1] << 16 | buf[2] << 8 | buf[3]; } uint64_t getULongLong(const byte* buf, ByteOrder byteOrder) { if (byteOrder == littleEndian) { - return (uint64_t)buf[7] << 56 | (uint64_t)buf[6] << 48 - | (uint64_t)buf[5] << 40 | (uint64_t)buf[4] << 32 - | (uint64_t)buf[3] << 24 | (uint64_t)buf[2] << 16 - | (uint64_t)buf[1] << 8 | (uint64_t)buf[0]; + return static_cast(buf[7]) << 56 | static_cast(buf[6]) << 48 | + static_cast(buf[5]) << 40 | static_cast(buf[4]) << 32 | + static_cast(buf[3]) << 24 | static_cast(buf[2]) << 16 | + static_cast(buf[1]) << 8 | static_cast(buf[0]); } - return (uint64_t)buf[0] << 56 | (uint64_t)buf[1] << 48 | (uint64_t)buf[2] << 40 | (uint64_t)buf[3] << 32 | - (uint64_t)buf[4] << 24 | (uint64_t)buf[5] << 16 | (uint64_t)buf[6] << 8 | (uint64_t)buf[7]; + return static_cast(buf[0]) << 56 | static_cast(buf[1]) << 48 | + static_cast(buf[2]) << 40 | static_cast(buf[3]) << 32 | + static_cast(buf[4]) << 24 | static_cast(buf[5]) << 16 | + static_cast(buf[6]) << 8 | static_cast(buf[7]); } URational getURational(const byte* buf, ByteOrder byteOrder) @@ -305,18 +306,17 @@ namespace Exiv2 { int16_t getShort(const byte* buf, ByteOrder byteOrder) { if (byteOrder == littleEndian) { - return (byte)buf[1] << 8 | (byte)buf[0]; + return buf[1] << 8 | buf[0]; } - return (byte)buf[0] << 8 | (byte)buf[1]; + return buf[0] << 8 | buf[1]; } int32_t getLong(const byte* buf, ByteOrder byteOrder) { if (byteOrder == littleEndian) { - return (byte)buf[3] << 24 | (byte)buf[2] << 16 - | (byte)buf[1] << 8 | (byte)buf[0]; + return buf[3] << 24 | buf[2] << 16 | buf[1] << 8 | buf[0]; } - return (byte)buf[0] << 24 | (byte)buf[1] << 16 | (byte)buf[2] << 8 | (byte)buf[3]; + return buf[0] << 24 | buf[1] << 16 | buf[2] << 8 | buf[3]; } Rational getRational(const byte* buf, ByteOrder byteOrder) @@ -377,12 +377,12 @@ namespace Exiv2 { long us2Data(byte* buf, uint16_t s, ByteOrder byteOrder) { if (byteOrder == littleEndian) { - buf[0] = (byte) (s & 0x00ff); - buf[1] = (byte)((s & 0xff00) >> 8); + buf[0] = static_cast(s & 0x00ff); + buf[1] = static_cast((s & 0xff00) >> 8); } else { - buf[0] = (byte)((s & 0xff00) >> 8); - buf[1] = (byte) (s & 0x00ff); + buf[0] = static_cast((s & 0xff00) >> 8); + buf[1] = static_cast(s & 0x00ff); } return 2; } @@ -390,16 +390,16 @@ namespace Exiv2 { long ul2Data(byte* buf, uint32_t l, ByteOrder byteOrder) { if (byteOrder == littleEndian) { - buf[0] = (byte) (l & 0x000000ff); - buf[1] = (byte)((l & 0x0000ff00) >> 8); - buf[2] = (byte)((l & 0x00ff0000) >> 16); - buf[3] = (byte)((l & 0xff000000) >> 24); + buf[0] = static_cast(l & 0x000000ff); + buf[1] = static_cast((l & 0x0000ff00) >> 8); + buf[2] = static_cast((l & 0x00ff0000) >> 16); + buf[3] = static_cast((l & 0xff000000) >> 24); } else { - buf[0] = (byte)((l & 0xff000000) >> 24); - buf[1] = (byte)((l & 0x00ff0000) >> 16); - buf[2] = (byte)((l & 0x0000ff00) >> 8); - buf[3] = (byte) (l & 0x000000ff); + buf[0] = static_cast((l & 0xff000000) >> 24); + buf[1] = static_cast((l & 0x00ff0000) >> 16); + buf[2] = static_cast((l & 0x0000ff00) >> 8); + buf[3] = static_cast(l & 0x000000ff); } return 4; } @@ -414,12 +414,12 @@ namespace Exiv2 { long s2Data(byte* buf, int16_t s, ByteOrder byteOrder) { if (byteOrder == littleEndian) { - buf[0] = (byte)(s & 0x00ff); - buf[1] = (byte)((s & 0xff00) >> 8); + buf[0] = static_cast(s & 0x00ff); + buf[1] = static_cast((s & 0xff00) >> 8); } else { - buf[0] = (byte)((s & 0xff00) >> 8); - buf[1] = (byte)(s & 0x00ff); + buf[0] = static_cast((s & 0xff00) >> 8); + buf[1] = static_cast(s & 0x00ff); } return 2; } @@ -427,16 +427,16 @@ namespace Exiv2 { long l2Data(byte* buf, int32_t l, ByteOrder byteOrder) { if (byteOrder == littleEndian) { - buf[0] = (byte)(l & 0x000000ff); - buf[1] = (byte)((l & 0x0000ff00) >> 8); - buf[2] = (byte)((l & 0x00ff0000) >> 16); - buf[3] = (byte)((l & 0xff000000) >> 24); + buf[0] = static_cast(l & 0x000000ff); + buf[1] = static_cast((l & 0x0000ff00) >> 8); + buf[2] = static_cast((l & 0x00ff0000) >> 16); + buf[3] = static_cast((l & 0xff000000) >> 24); } else { - buf[0] = (byte)((l & 0xff000000) >> 24); - buf[1] = (byte)((l & 0x00ff0000) >> 16); - buf[2] = (byte)((l & 0x0000ff00) >> 8); - buf[3] = (byte)(l & 0x000000ff); + buf[0] = static_cast((l & 0xff000000) >> 24); + buf[1] = static_cast((l & 0x00ff0000) >> 16); + buf[2] = static_cast((l & 0x0000ff00) >> 8); + buf[3] = static_cast(l & 0x000000ff); } return 4; } @@ -475,24 +475,24 @@ namespace Exiv2 { u.d_ = d; uint64_t m = 0xff; if (byteOrder == littleEndian) { - buf[0] = (byte)(u.ull_ & m); - buf[1] = (byte)((u.ull_ & (m << 8)) >> 8); - buf[2] = (byte)((u.ull_ & (m << 16)) >> 16); - buf[3] = (byte)((u.ull_ & (m << 24)) >> 24); - buf[4] = (byte)((u.ull_ & (m << 32)) >> 32); - buf[5] = (byte)((u.ull_ & (m << 40)) >> 40); - buf[6] = (byte)((u.ull_ & (m << 48)) >> 48); - buf[7] = (byte)((u.ull_ & (m << 56)) >> 56); + buf[0] = static_cast(u.ull_ & m); + buf[1] = static_cast((u.ull_ & (m << 8)) >> 8); + buf[2] = static_cast((u.ull_ & (m << 16)) >> 16); + buf[3] = static_cast((u.ull_ & (m << 24)) >> 24); + buf[4] = static_cast((u.ull_ & (m << 32)) >> 32); + buf[5] = static_cast((u.ull_ & (m << 40)) >> 40); + buf[6] = static_cast((u.ull_ & (m << 48)) >> 48); + buf[7] = static_cast((u.ull_ & (m << 56)) >> 56); } else { - buf[0] = (byte)((u.ull_ & (m << 56)) >> 56); - buf[1] = (byte)((u.ull_ & (m << 48)) >> 48); - buf[2] = (byte)((u.ull_ & (m << 40)) >> 40); - buf[3] = (byte)((u.ull_ & (m << 32)) >> 32); - buf[4] = (byte)((u.ull_ & (m << 24)) >> 24); - buf[5] = (byte)((u.ull_ & (m << 16)) >> 16); - buf[6] = (byte)((u.ull_ & (m << 8)) >> 8); - buf[7] = (byte)(u.ull_ & m); + buf[0] = static_cast((u.ull_ & (m << 56)) >> 56); + buf[1] = static_cast((u.ull_ & (m << 48)) >> 48); + buf[2] = static_cast((u.ull_ & (m << 40)) >> 40); + buf[3] = static_cast((u.ull_ & (m << 32)) >> 32); + buf[4] = static_cast((u.ull_ & (m << 24)) >> 24); + buf[5] = static_cast((u.ull_ & (m << 16)) >> 16); + buf[6] = static_cast((u.ull_ & (m << 8)) >> 8); + buf[7] = static_cast(u.ull_ & m); } return 8; } @@ -511,9 +511,8 @@ namespace Exiv2 { std::ostringstream ss; do { byte c = buf[i]; - os << std::setw(2) << std::setfill('0') << std::right - << std::hex << (int)c << " "; - ss << ((int)c >= 31 && (int)c < 127 ? char(buf[i]) : '.'); + os << std::setw(2) << std::setfill('0') << std::right << std::hex << static_cast(c) << " "; + ss << (static_cast(c) >= 31 && static_cast(c) < 127 ? char(buf[i]) : '.'); } while (++i < len && i%16 != 0); std::string::size_type width = 9 + ((i-1)%16 + 1) * 3; os << (width > pos ? "" : align.substr(width)) << ss.str() << "\n"; diff --git a/src/webpimage.cpp b/src/webpimage.cpp index 0fadc1e2..300edd5f 100644 --- a/src/webpimage.cpp +++ b/src/webpimage.cpp @@ -184,7 +184,7 @@ namespace Exiv2 { /* Verify for a VP8X Chunk First before writing in case we have any exif or xmp data, also check for any chunks with alpha frame/layer set */ - while ( !io_->eof() && (uint64_t) io_->tell() < filesize) { + while (!io_->eof() && static_cast(io_->tell()) < filesize) { readOrThrow(*io_, chunkId.pData_, WEBP_TAG_SIZE, Exiv2::kerCorruptedMetadata); readOrThrow(*io_, size_buff, WEBP_TAG_SIZE, Exiv2::kerCorruptedMetadata); const uint32_t size_u32 = Exiv2::getULong(size_buff, littleEndian); @@ -321,7 +321,7 @@ namespace Exiv2 { } io_->seek(12, BasicIo::beg); - while ( !io_->eof() && (uint64_t) io_->tell() < filesize) { + while (!io_->eof() && static_cast(io_->tell()) < filesize) { readOrThrow(*io_, chunkId.pData_, 4, Exiv2::kerCorruptedMetadata); readOrThrow(*io_, size_buff, 4, Exiv2::kerCorruptedMetadata); @@ -367,8 +367,10 @@ namespace Exiv2 { } if (has_icc) { - if (outIo.write((const byte*)WEBP_CHUNK_HEADER_ICCP, WEBP_TAG_SIZE) != WEBP_TAG_SIZE) throw Error(kerImageWriteFailed); - ul2Data(data, (uint32_t) iccProfile_.size_, littleEndian); + if (outIo.write(reinterpret_cast(WEBP_CHUNK_HEADER_ICCP), WEBP_TAG_SIZE) != + WEBP_TAG_SIZE) + throw Error(kerImageWriteFailed); + ul2Data(data, static_cast(iccProfile_.size_), littleEndian); if (outIo.write(data, WEBP_TAG_SIZE) != WEBP_TAG_SIZE) throw Error(kerImageWriteFailed); if (outIo.write(iccProfile_.pData_, iccProfile_.size_) != iccProfile_.size_) { throw Error(kerImageWriteFailed); @@ -397,12 +399,12 @@ namespace Exiv2 { } if (has_exif) { - if (outIo.write((const byte*)WEBP_CHUNK_HEADER_EXIF, WEBP_TAG_SIZE) != WEBP_TAG_SIZE) throw Error(kerImageWriteFailed); - us2Data(data, (uint16_t) blob.size()+8, bigEndian); - ul2Data(data, (uint32_t) blob.size(), littleEndian); + if (outIo.write(reinterpret_cast(WEBP_CHUNK_HEADER_EXIF), WEBP_TAG_SIZE) != WEBP_TAG_SIZE) + throw Error(kerImageWriteFailed); + us2Data(data, static_cast(blob.size()) + 8, bigEndian); + ul2Data(data, static_cast(blob.size()), littleEndian); if (outIo.write(data, WEBP_TAG_SIZE) != WEBP_TAG_SIZE) throw Error(kerImageWriteFailed); - if (outIo.write((const byte*)&blob[0], static_cast(blob.size())) != (long)blob.size()) - { + if (outIo.write(&blob[0], static_cast(blob.size())) != static_cast(blob.size())) { throw Error(kerImageWriteFailed); } if (outIo.tell() % 2) { @@ -411,10 +413,12 @@ namespace Exiv2 { } if (has_xmp) { - if (outIo.write((const byte*)WEBP_CHUNK_HEADER_XMP, WEBP_TAG_SIZE) != WEBP_TAG_SIZE) throw Error(kerImageWriteFailed); - ul2Data(data, (uint32_t) xmpPacket().size(), littleEndian); + if (outIo.write(reinterpret_cast(WEBP_CHUNK_HEADER_XMP), WEBP_TAG_SIZE) != WEBP_TAG_SIZE) + throw Error(kerImageWriteFailed); + ul2Data(data, static_cast(xmpPacket().size()), littleEndian); if (outIo.write(data, WEBP_TAG_SIZE) != WEBP_TAG_SIZE) throw Error(kerImageWriteFailed); - if (outIo.write((const byte*)xmp.data(), static_cast(xmp.size())) != (long)xmp.size()) { + if (outIo.write(reinterpret_cast(xmp.data()), static_cast(xmp.size())) != + static_cast(xmp.size())) { throw Error(kerImageWriteFailed); } if (outIo.tell() % 2) { @@ -426,7 +430,7 @@ namespace Exiv2 { outIo.seek(0, BasicIo::beg); filesize = outIo.size() - 8; outIo.seek(4, BasicIo::beg); - ul2Data(data, (uint32_t) filesize, littleEndian); + ul2Data(data, static_cast(filesize), littleEndian); if (outIo.write(data, WEBP_TAG_SIZE) != WEBP_TAG_SIZE) throw Error(kerImageWriteFailed); } // WebPImage::writeMetadata @@ -463,8 +467,8 @@ namespace Exiv2 { } io_->seek(0,BasicIo::beg); // rewind - while ( !io_->eof() && (uint64_t) io_->tell() < filesize) { - auto offset = (uint64_t)io_->tell(); + while (!io_->eof() && static_cast(io_->tell()) < filesize) { + auto offset = static_cast(io_->tell()); byte size_buff[WEBP_TAG_SIZE]; io_->read(chunkId.pData_, WEBP_TAG_SIZE); io_->read(size_buff, WEBP_TAG_SIZE); @@ -474,9 +478,10 @@ namespace Exiv2 { if ( bPrint ) { out << Internal::indent(depth) - << Internal::stringFormat(" %s | %8u | %8u | ", (const char*)chunkId.pData_,(uint32_t)size,(uint32_t)offset) - << Internal::binaryToString(makeSlice(payload, 0, payload.size_ > 32 ? 32 : payload.size_)) - << std::endl; + << Internal::stringFormat(" %s | %8u | %8u | ", reinterpret_cast(chunkId.pData_), + static_cast(size), static_cast(offset)) + << Internal::binaryToString(makeSlice(payload, 0, payload.size_ > 32 ? 32 : payload.size_)) + << std::endl; } if ( equalsWebPTag(chunkId, WEBP_CHUNK_HEADER_EXIF) && option==kpsRecursive ) { @@ -489,7 +494,7 @@ namespace Exiv2 { || (equalsWebPTag(chunkId, WEBP_CHUNK_HEADER_ICCP) && option==kpsIccProfile) ; if ( bPrintPayload ) { - out.write((const char*) payload.pData_,payload.size_); + out.write(reinterpret_cast(payload.pData_), payload.size_); } if ( offset && io_->tell() % 2 ) io_->seek(+1, BasicIo::cur); // skip padding byte on sub-chunks @@ -644,22 +649,22 @@ namespace Exiv2 { bool s_header = false; bool le_header = false; bool be_header = false; - long pos = getHeaderOffset (payload.pData_, payload.size_, (byte*)&exifLongHeader, 4); + long pos = getHeaderOffset(payload.pData_, payload.size_, reinterpret_cast(&exifLongHeader), 4); if (pos == -1) { - pos = getHeaderOffset (payload.pData_, payload.size_, (byte*)&exifLongHeader, 6); + pos = getHeaderOffset(payload.pData_, payload.size_, reinterpret_cast(&exifLongHeader), 6); if (pos != -1) { s_header = true; } } if (pos == -1) { - pos = getHeaderOffset (payload.pData_, payload.size_, (byte*)&exifTiffLEHeader, 3); + pos = getHeaderOffset(payload.pData_, payload.size_, reinterpret_cast(&exifTiffLEHeader), 3); if (pos != -1) { le_header = true; } } if (pos == -1) { - pos = getHeaderOffset (payload.pData_, payload.size_, (byte*)&exifTiffBEHeader, 4); + pos = getHeaderOffset(payload.pData_, payload.size_, reinterpret_cast(&exifTiffBEHeader), 4); if (pos != -1) { be_header = true; } @@ -673,25 +678,25 @@ namespace Exiv2 { } const long sizePayload = payload.size_ + offset; - rawExifData = (byte*)malloc(sizePayload); + rawExifData = static_cast(malloc(sizePayload)); if (s_header) { - us2Data(size_buff2, (uint16_t) (sizePayload - 6), bigEndian); - memcpy(rawExifData, (char*)&exifLongHeader, 4); - memcpy(rawExifData + 4, (char*)&size_buff2, 2); + us2Data(size_buff2, static_cast(sizePayload - 6), bigEndian); + memcpy(rawExifData, reinterpret_cast(&exifLongHeader), 4); + memcpy(rawExifData + 4, reinterpret_cast(&size_buff2), 2); } if (be_header || le_header) { - us2Data(size_buff2, (uint16_t) (sizePayload - 6), bigEndian); - memcpy(rawExifData, (char*)&exifLongHeader, 4); - memcpy(rawExifData + 4, (char*)&size_buff2, 2); - memcpy(rawExifData + 6, (char*)&exifShortHeader, 6); + us2Data(size_buff2, static_cast(sizePayload - 6), bigEndian); + memcpy(rawExifData, reinterpret_cast(&exifLongHeader), 4); + memcpy(rawExifData + 4, reinterpret_cast(&size_buff2), 2); + memcpy(rawExifData + 6, reinterpret_cast(&exifShortHeader), 6); } memcpy(rawExifData + offset, payload.pData_, payload.size_); #ifdef EXIV2_DEBUG_MESSAGES - std::cout << "Display Hex Dump [size:" << (unsigned long)sizePayload << "]" << std::endl; + std::cout << "Display Hex Dump [size:" << static_cast(sizePayload) << "]" << std::endl; std::cout << Internal::binaryToHex(rawExifData, sizePayload); #endif @@ -720,7 +725,8 @@ namespace Exiv2 { #endif } else { #ifdef EXIV2_DEBUG_MESSAGES - std::cout << "Display Hex Dump [size:" << (unsigned long)payload.size_ << "]" << std::endl; + std::cout << "Display Hex Dump [size:" << static_cast(payload.size_) << "]" + << std::endl; std::cout << Internal::binaryToHex(payload.pData_, payload.size_); #endif } @@ -792,7 +798,7 @@ namespace Exiv2 { byte size[4] = { 0x0A, 0x00, 0x00, 0x00 }; byte data[10] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - iIo.write((const byte*)WEBP_CHUNK_HEADER_VP8X, WEBP_TAG_SIZE); + iIo.write(reinterpret_cast(WEBP_CHUNK_HEADER_VP8X), WEBP_TAG_SIZE); iIo.write(size, WEBP_TAG_SIZE); if (has_alpha) { @@ -829,7 +835,7 @@ namespace Exiv2 { if (has_icc) { byte size_buff[WEBP_TAG_SIZE]; ul2Data(size_buff, iccProfile_.size_, littleEndian); - if (iIo.write((const byte*)WEBP_CHUNK_HEADER_VP8X, WEBP_TAG_SIZE) != WEBP_TAG_SIZE) + if (iIo.write(reinterpret_cast(WEBP_CHUNK_HEADER_VP8X), WEBP_TAG_SIZE) != WEBP_TAG_SIZE) throw Error(kerImageWriteFailed); if (iIo.write(size_buff, WEBP_TAG_SIZE) != WEBP_TAG_SIZE) throw Error(kerImageWriteFailed); diff --git a/src/xmp.cpp b/src/xmp.cpp index 81d30e0f..ccc94842 100644 --- a/src/xmp.cpp +++ b/src/xmp.cpp @@ -500,7 +500,7 @@ namespace Exiv2 { } if ( bURI || bNS ) { - auto p = (std::map*)refCon; + auto p = static_cast*>(refCon); std::map& m = *p; std::string b; diff --git a/src/xmpsidecar.cpp b/src/xmpsidecar.cpp index 4a71ae3a..d732d675 100644 --- a/src/xmpsidecar.cpp +++ b/src/xmpsidecar.cpp @@ -37,7 +37,7 @@ // ***************************************************************************** namespace { const char* xmlHeader = "\n"; - const long xmlHdrCnt = (long) std::strlen(xmlHeader); // without the trailing 0-character + const long xmlHdrCnt = static_cast(std::strlen(xmlHeader)); // without the trailing 0-character const char* xmlFooter = ""; }