From e65f3fef984ffe6b291a5a3e5da459d7a1b09d00 Mon Sep 17 00:00:00 2001 From: Andreas Huggel Date: Mon, 12 Sep 2005 16:15:48 +0000 Subject: [PATCH] Fixed MSVC and MinGW warnings --- msvc/exiv2lib/exiv2lib.vcproj | 18 ++++++++++++++++ src/actions.hpp | 4 ++-- src/crwimage.cpp | 40 +++++++++++++++++------------------ src/crwimage.hpp | 36 +++++++++++++++---------------- src/exiv2.cpp | 2 +- src/tags.cpp | 2 +- src/types.hpp | 6 ++++++ src/utils.cpp | 27 +++++++++++++---------- src/utils.hpp | 2 +- 9 files changed, 82 insertions(+), 55 deletions(-) diff --git a/msvc/exiv2lib/exiv2lib.vcproj b/msvc/exiv2lib/exiv2lib.vcproj index cd9e6a90..48d32128 100644 --- a/msvc/exiv2lib/exiv2lib.vcproj +++ b/msvc/exiv2lib/exiv2lib.vcproj @@ -124,6 +124,21 @@ ObjectFile="$(IntDir)/$(InputName)1.obj"/> + + + + + + + + @@ -363,6 +378,9 @@ + + diff --git a/src/actions.hpp b/src/actions.hpp index 9f275969..b6ce3cb8 100644 --- a/src/actions.hpp +++ b/src/actions.hpp @@ -314,8 +314,8 @@ namespace Action { private: virtual Modify* clone_() const; - //! Copy contructor needed because of AutoPtr memeber - Modify(const Modify& src) {} + //! Copy contructor needed because of AutoPtr member + Modify(const Modify& /*src*/) {} //! Add a metadatum according to \em modifyCmd void addMetadatum(const ModifyCmd& modifyCmd); diff --git a/src/crwimage.cpp b/src/crwimage.cpp index 2c8e6f48..276db3d5 100644 --- a/src/crwimage.cpp +++ b/src/crwimage.cpp @@ -84,13 +84,13 @@ namespace Exiv2 { } } // CrwImage::CrwImage - int CrwImage::initImage(const byte initData[], size_t dataSize) + int CrwImage::initImage(const byte initData[], long dataSize) { if (io_->open() != 0) { return 4; } IoCloser closer(*io_); - if (static_cast(io_->write(initData, dataSize)) != dataSize) { + if (io_->write(initData, dataSize) != dataSize) { return 4; } return 0; @@ -162,7 +162,7 @@ namespace Exiv2 { clearMetadata(); // Read the image into a memory buffer - size_t imageSize = io_->size(); + long imageSize = io_->size(); DataBuf image(imageSize); io_->read(image.pData_, imageSize); if (io_->error() || io_->eof()) throw Error(14); @@ -196,10 +196,10 @@ namespace Exiv2 { } void CiffComponent::read(const byte* buf, - size_t len, - size_t start, - ByteOrder byteOrder, - long /*shift*/) + uint32_t len, + uint32_t start, + ByteOrder byteOrder, + int32_t /*shift*/) { if (len < 10) throw Error(33); tag_ = getUShort(buf + start, byteOrder); @@ -293,10 +293,10 @@ namespace Exiv2 { } // CiffDirectory::add void CiffDirectory::read(const byte* buf, - size_t len, - size_t start, - ByteOrder byteOrder, - long /*shift*/) + uint32_t len, + uint32_t start, + ByteOrder byteOrder, + int32_t /*shift*/) { CiffComponent::read(buf, len, start, byteOrder); readDirectory(buf + offset(), size(), 0, byteOrder, 0); @@ -324,10 +324,10 @@ namespace Exiv2 { } // CiffDirectory::print void CiffDirectory::readDirectory(const byte* buf, - size_t len, - size_t start, - ByteOrder byteOrder, - long /*shift*/) + uint32_t len, + uint32_t start, + ByteOrder byteOrder, + int32_t /*shift*/) { uint32_t dataSize = getULong(buf + len - 4, byteOrder); uint32_t o = start + dataSize; @@ -363,10 +363,10 @@ namespace Exiv2 { } // CiffHeader::add void CiffHeader::read(const byte* buf, - size_t len, - size_t start, - ByteOrder byteOrder, - long /*shift*/) + uint32_t len, + uint32_t start, + ByteOrder byteOrder, + int32_t /*shift*/) { if (len < 14) throw Error(33); @@ -580,7 +580,7 @@ namespace Exiv2 { // Todo: use _r version struct tm* tm = std::gmtime(&t); - size_t m = 20; + const size_t m = 20; char s[m]; std::strftime(s, m, "%Y:%m:%d %T", tm); diff --git a/src/crwimage.hpp b/src/crwimage.hpp index 92d85baa..2a56a050 100644 --- a/src/crwimage.hpp +++ b/src/crwimage.hpp @@ -166,9 +166,7 @@ namespace Exiv2 { //! @name Manipulators //@{ - - int initImage(const byte initData[], size_t dataSize); - + int initImage(const byte initData[], long dataSize); //@} //! @name Accessors @@ -248,10 +246,10 @@ namespace Exiv2 { @throw Error If the component cannot be parsed. */ virtual void read(const byte* buf, - size_t len, - size_t start, + uint32_t len, + uint32_t start, ByteOrder byteOrder, - long shift =0) =0; + int32_t shift =0) =0; //@} //! @name Accessors @@ -304,10 +302,10 @@ namespace Exiv2 { // See base class comment virtual void read(const byte* buf, - size_t len, - size_t start, + uint32_t len, + uint32_t start, ByteOrder byteOrder, - long shift =0); + int32_t shift =0); //! Set the directory tag for this component. void setDir(uint16_t dir) { dir_ = dir; } @@ -421,10 +419,10 @@ namespace Exiv2 { // See base class comment virtual void read(const byte* buf, - size_t len, - size_t start, + uint32_t len, + uint32_t start, ByteOrder byteOrder, - long shift =0); + int32_t shift =0); /*! @brief Parse a CIFF directory from a memory buffer @@ -436,10 +434,10 @@ namespace Exiv2 { @param shift Not used */ void readDirectory(const byte* buf, - size_t len, - size_t start, - ByteOrder byteOrder, - long shift =0); + uint32_t len, + uint32_t start, + ByteOrder byteOrder, + int32_t shift =0); //@} //! @name Accessors @@ -482,10 +480,10 @@ namespace Exiv2 { // See base class comment virtual void read(const byte* buf, - size_t len, - size_t start, + uint32_t len, + uint32_t start, ByteOrder byteOrder, - long shift =0); + int32_t shift =0); //@} //! @name Accessors diff --git a/src/exiv2.cpp b/src/exiv2.cpp index b9ca5191..47df8f6f 100644 --- a/src/exiv2.cpp +++ b/src/exiv2.cpp @@ -580,7 +580,7 @@ int Params::getopt(int argc, char* const argv[]) << ": -l option can only be used with extract or insert actions\n"; rc = 1; } - if (!suffix_.empty() && !action_ == Action::insert) { + if (!suffix_.empty() && !(action_ == Action::insert)) { std::cerr << progname() << ": -s option can only be used with insert action\n"; rc = 1; diff --git a/src/tags.cpp b/src/tags.cpp index 4da78b40..1bd267cd 100644 --- a/src/tags.cpp +++ b/src/tags.cpp @@ -1286,7 +1286,7 @@ namespace Exiv2 { float fnumber(float apertureValue) { - return std::exp(std::log(2.0) * apertureValue / 2); + return static_cast(std::exp(std::log(2.0) * apertureValue / 2)); } URational exposureTime(float shutterSpeedValue) diff --git a/src/types.hpp b/src/types.hpp index 27a85922..075223fc 100644 --- a/src/types.hpp +++ b/src/types.hpp @@ -313,10 +313,16 @@ namespace Exiv2 { // This is abs() - given the existence of broken compilers with Koenig // lookup issues and other problems, I code this explicitly. (Remember, // IntType may be a user-defined type). +#ifdef _MSC_VER +#pragma warning( disable : 4146 ) +#endif if (n < zero) n = -n; if (m < zero) m = -m; +#ifdef _MSC_VER +#pragma warning( default : 4146 ) +#endif // As n and m are now positive, we can be sure that %= returns a // positive value (the standard guarantees this for built-in types, diff --git a/src/utils.cpp b/src/utils.cpp index 69bb0fb1..c2d8c28f 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -60,20 +60,25 @@ namespace Util { // ***************************************************************************** // class Getopt -int Getopt::getopt(int argc, char* const argv[], const std::string& optstring) -{ - progname_ = Util::basename(argv[0]); + int Getopt::getopt(int argc, char* const argv[], const std::string& optstring) + { + progname_ = Util::basename(argv[0]); - for (;;) { - int c = ::getopt(argc, argv, optstring.c_str()); - if (c == -1) break; - errcnt_ += option(c, ::optarg == 0 ? "" : ::optarg, ::optopt); + for (;;) { + int c = ::getopt(argc, argv, optstring.c_str()); + if (c == -1) break; + errcnt_ += option(c, ::optarg == 0 ? "" : ::optarg, ::optopt); + } + for (int i = ::optind; i < argc; i++) { + errcnt_ += nonoption(argv[i]); + } + return errcnt_; } - for (int i = ::optind; i < argc; i++) { - errcnt_ += nonoption(argv[i]); + + int Getopt::nonoption(const std::string& /*argv*/) + { + return 0; } - return errcnt_; -} // ***************************************************************************** // free functions diff --git a/src/utils.hpp b/src/utils.hpp index f6b001e3..c257d6d6 100644 --- a/src/utils.hpp +++ b/src/utils.hpp @@ -111,7 +111,7 @@ public: @return 0 if successful, 1 in case of an error. */ - virtual int nonoption(const std::string& argv) { return 0; } + virtual int nonoption(const std::string& argv); //! Program name (argv[0]) const std::string& progname() const { return progname_; }