From 82dbe6199ddb825813a23230047a2249a79b3e9f Mon Sep 17 00:00:00 2001 From: Robin Mills Date: Thu, 29 Jun 2017 22:13:26 +0100 Subject: [PATCH] https://github.com/Exiv2/exiv2/issues/11 Closed. Coincidentally Raphael reported issues with Visual Studio 2015 Community Edition. Issue 11 and Raphael's issues should now be resolved. --- samples/iotest.cpp | 4 ++-- samples/largeiptc-test.cpp | 2 +- samples/mmap-test.cpp | 2 +- src/basicio.cpp | 10 +++++----- src/cr2image.cpp | 4 ++-- src/crwimage.cpp | 6 +++--- src/exif.cpp | 6 +++--- src/jp2image.cpp | 2 +- src/orfimage.cpp | 4 ++-- src/pgfimage.cpp | 2 +- src/pngimage.cpp | 4 ++-- src/preview.cpp | 2 +- src/rw2image.cpp | 2 +- src/tiffimage.cpp | 4 ++-- 14 files changed, 27 insertions(+), 27 deletions(-) diff --git a/samples/iotest.cpp b/samples/iotest.cpp index 71ec9a7a..2dc50fe3 100644 --- a/samples/iotest.cpp +++ b/samples/iotest.cpp @@ -142,7 +142,7 @@ int WriteReadSeek(BasicIo &io) throw Error(9, io.path(), strError()); } IoCloser closer(io); - if ((size_t) io.write((byte*)tester1, size1) != size1) { + if ((size_t) io.write((byte*)tester1, (long)size1) != size1) { std::cerr << ": WRS initial write failed\n"; return 2; } @@ -195,7 +195,7 @@ int WriteReadSeek(BasicIo &io) } io.seek(insert, BasicIo::beg); - if((size_t)io.write((byte*)tester2, size2) != size2) { + if((size_t)io.write((byte*)tester2, (long)size2) != size2) { std::cerr << ": WRS bad write 1\n"; return 9; } diff --git a/samples/largeiptc-test.cpp b/samples/largeiptc-test.cpp index 98d8e391..0cc843f9 100644 --- a/samples/largeiptc-test.cpp +++ b/samples/largeiptc-test.cpp @@ -20,7 +20,7 @@ try { if (io.open() != 0) { throw Exiv2::Error(9, io.path(), Exiv2::strError()); } - Exiv2::DataBuf buf(io.size()); + Exiv2::DataBuf buf((long)io.size()); std::cout << "Reading " << buf.size_ << " bytes from " << data << "\n"; io.read(buf.pData_, buf.size_); if (io.error() || !io.eof()) throw Exiv2::Error(14); diff --git a/samples/mmap-test.cpp b/samples/mmap-test.cpp index e4f2980e..1604356e 100644 --- a/samples/mmap-test.cpp +++ b/samples/mmap-test.cpp @@ -24,7 +24,7 @@ try { } // Map it to memory const Exiv2::byte* pData = file.mmap(); - long size = file.size(); + long size = (long)file.size(); DataBuf buf(size); // Read from the memory mapped region memcpy(buf.pData_, pData, buf.size_); diff --git a/src/basicio.cpp b/src/basicio.cpp index 95589cd2..28aa454d 100644 --- a/src/basicio.cpp +++ b/src/basicio.cpp @@ -1674,7 +1674,7 @@ namespace Exiv2 { while (blockIndex < nBlocks && !src.eof() && !findDiff) { blockSize = p_->blocksMap_[blockIndex].getSize(); bool isFakeData = p_->blocksMap_[blockIndex].isKnown(); // fake data - readCount = src.read(buf, blockSize); + readCount = (size_t) src.read(buf, (long) 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)) { @@ -1695,7 +1695,7 @@ namespace Exiv2 { findDiff = true; } else { bool isFakeData = p_->blocksMap_[blockIndex].isKnown(); // fake data - readCount = src.read(buf, blockSize); + readCount = src.read(buf, (long) 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)) { @@ -1713,15 +1713,15 @@ namespace Exiv2 { if (buf) std::free(buf); // submit to the remote machine. - long dataSize = src.size() - left - right; + long dataSize = (long) (src.size() - left - right); if (dataSize > 0) { byte* data = (byte*) std::malloc(dataSize); src.seek(left, BasicIo::beg); src.read(data, dataSize); - p_->writeRemote(data, (size_t)dataSize, left, (long) p_->size_ - right); + p_->writeRemote(data, (size_t)dataSize, (long)left, (long) (p_->size_ - right)); if (data) std::free(data); } - return src.size(); + return (long) src.size(); } int RemoteIo::putb(byte /*unused data*/) diff --git a/src/cr2image.cpp b/src/cr2image.cpp index 2907426c..8e9629ee 100644 --- a/src/cr2image.cpp +++ b/src/cr2image.cpp @@ -113,7 +113,7 @@ namespace Exiv2 { iptcData_, xmpData_, io_->mmap(), - io_->size()); + (uint32_t) io_->size()); setByteOrder(bo); } // Cr2Image::readMetadata @@ -130,7 +130,7 @@ namespace Exiv2 { // Ensure that this is the correct image type if (isCr2Type(*io_, false)) { pData = io_->mmap(true); - size = io_->size(); + size = (long) io_->size(); Cr2Header cr2Header; if (0 == cr2Header.read(pData, 16)) { bo = cr2Header.byteOrder(); diff --git a/src/crwimage.cpp b/src/crwimage.cpp index ca79aa74..ffdd8d08 100644 --- a/src/crwimage.cpp +++ b/src/crwimage.cpp @@ -137,11 +137,11 @@ namespace Exiv2 { std::ofstream devnull; printStructure(devnull,kpsRecursive,0); } catch (Exiv2::Error& /* e */) { - DataBuf file(io().size()); + DataBuf file( (long) io().size()); io_->read(file.pData_,file.size_); } - CrwParser::decode(this, io_->mmap(), io_->size()); + CrwParser::decode(this, io_->mmap(), (uint32_t) io_->size()); } // CrwImage::readMetadata @@ -157,7 +157,7 @@ namespace Exiv2 { // Ensure that this is the correct image type if (isCrwType(*io_, false)) { // Read the image into a memory buffer - buf.alloc(io_->size()); + buf.alloc((long) 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 628fa63f..b167c31c 100644 --- a/src/exif.cpp +++ b/src/exif.cpp @@ -718,7 +718,7 @@ namespace Exiv2 { header.get(), 0); if (mio1.size() <= 65527) { - append(blob, mio1.mmap(), mio1.size()); + append(blob, mio1.mmap(), (uint32_t) mio1.size()); return wm; } @@ -820,7 +820,7 @@ namespace Exiv2 { TiffMapping::findEncoder, header.get(), 0); - append(blob, mio2.mmap(), mio2.size()); + append(blob, mio2.mmap(), (uint32_t) mio2.size()); #ifdef DEBUG if (wm == wmIntrusive) { std::cerr << "SIZE OF EXIF DATA IS " << std::dec << mio2.size() << " BYTES\n"; @@ -897,7 +897,7 @@ namespace { Exiv2::IptcData emptyIptc; Exiv2::XmpData emptyXmp; Exiv2::TiffParser::encode(io, 0, 0, Exiv2::littleEndian, thumb, emptyIptc, emptyXmp); - return io.read(io.size()); + return io.read((long) io.size()); } const char* JpegThumbnail::mimeType() const diff --git a/src/jp2image.cpp b/src/jp2image.cpp index 1892fd43..747145cf 100644 --- a/src/jp2image.cpp +++ b/src/jp2image.cpp @@ -735,7 +735,7 @@ namespace Exiv2 std::cout << "Exiv2::Jp2Image::doWriteMetadata: Null Box size has been found. " "This is the last box of file." << std::endl; #endif - box.length = io_->size() - io_->tell() + 8; + box.length = (uint32_t) (io_->size() - io_->tell() + 8); } if (box.length == 1) { diff --git a/src/orfimage.cpp b/src/orfimage.cpp index c5165911..5639b25f 100644 --- a/src/orfimage.cpp +++ b/src/orfimage.cpp @@ -125,7 +125,7 @@ namespace Exiv2 { iptcData_, xmpData_, io_->mmap(), - io_->size()); + (uint32_t) io_->size()); setByteOrder(bo); } // OrfImage::readMetadata @@ -142,7 +142,7 @@ namespace Exiv2 { // Ensure that this is the correct image type if (isOrfType(*io_, false)) { pData = io_->mmap(true); - size = io_->size(); + size = (long) io_->size(); OrfHeader orfHeader; if (0 == orfHeader.read(pData, 8)) { bo = orfHeader.byteOrder(); diff --git a/src/pgfimage.cpp b/src/pgfimage.cpp index 82706d11..2b0ccb81 100644 --- a/src/pgfimage.cpp +++ b/src/pgfimage.cpp @@ -203,7 +203,7 @@ namespace Exiv2 { img->setIptcData(iptcData_); img->setXmpData(xmpData_); img->writeMetadata(); - int imgSize = img->io().size(); + long imgSize = (long) img->io().size(); DataBuf imgBuf = img->io().read(imgSize); #ifdef DEBUG diff --git a/src/pngimage.cpp b/src/pngimage.cpp index 11b41982..d9b78f43 100644 --- a/src/pngimage.cpp +++ b/src/pngimage.cpp @@ -229,7 +229,7 @@ namespace Exiv2 { out << " address | chunk | length | data | checksum" << std::endl; } - const long imgSize = io_->size(); + const long imgSize = (long) io_->size(); DataBuf cheaderBuf(8); while( !io_->eof() && ::strcmp(chType,"IEND") ) { @@ -390,7 +390,7 @@ namespace Exiv2 { } clearMetadata(); - const long imgSize = io_->size(); + const long imgSize = (long) io_->size(); DataBuf cheaderBuf(8); // Chunk header size : 4 bytes (data size) + 4 bytes (chunk type). while(!io_->eof()) diff --git a/src/preview.cpp b/src/preview.cpp index c34c8bd2..e5352be4 100644 --- a/src/preview.cpp +++ b/src/preview.cpp @@ -830,7 +830,7 @@ namespace { IptcData emptyIptc; XmpData emptyXmp; TiffParser::encode(mio, 0, 0, Exiv2::littleEndian, preview, emptyIptc, emptyXmp); - return DataBuf(mio.mmap(), mio.size()); + return DataBuf(mio.mmap(), (long) mio.size()); } LoaderXmpJpeg::LoaderXmpJpeg(PreviewId id, const Image &image, int parIdx) diff --git a/src/rw2image.cpp b/src/rw2image.cpp index 95f3b28e..52b0f12e 100644 --- a/src/rw2image.cpp +++ b/src/rw2image.cpp @@ -136,7 +136,7 @@ namespace Exiv2 { iptcData_, xmpData_, io_->mmap(), - io_->size()); + (uint32_t) io_->size()); setByteOrder(bo); // A lot more metadata is hidden in the embedded preview image diff --git a/src/tiffimage.cpp b/src/tiffimage.cpp index f20c69eb..da2b8a6c 100644 --- a/src/tiffimage.cpp +++ b/src/tiffimage.cpp @@ -193,7 +193,7 @@ namespace Exiv2 { iptcData_, xmpData_, io_->mmap(), - io_->size()); + (uint32_t) io_->size()); setByteOrder(bo); // read profile from the metadata @@ -219,7 +219,7 @@ namespace Exiv2 { // Ensure that this is the correct image type if (isTiffType(*io_, false)) { pData = io_->mmap(true); - size = io_->size(); + size = (long) io_->size(); TiffHeader tiffHeader; if (0 == tiffHeader.read(pData, 8)) { bo = tiffHeader.byteOrder();