diff --git a/include/exiv2/types.hpp b/include/exiv2/types.hpp index c45537c8..55a6d2bf 100644 --- a/include/exiv2/types.hpp +++ b/include/exiv2/types.hpp @@ -503,7 +503,7 @@ namespace Exiv2 { T stringTo(const std::string& s, bool& ok) { std::istringstream is(s); - T tmp; + T tmp = T(); ok = bool(is >> tmp); std::string rest; is >> std::skipws >> rest; diff --git a/include/exiv2/value.hpp b/include/exiv2/value.hpp index 9a7d2dba..27002553 100644 --- a/include/exiv2/value.hpp +++ b/include/exiv2/value.hpp @@ -1560,7 +1560,7 @@ namespace Exiv2 { int ValueType::read(const std::string& buf) { std::istringstream is(buf); - T tmp; + T tmp = T(); ValueList val; while (!(is.eof())) { is >> tmp; diff --git a/samples/Jzon.cpp b/samples/Jzon.cpp index 9ee26232..617cc832 100644 --- a/samples/Jzon.cpp +++ b/samples/Jzon.cpp @@ -203,7 +203,7 @@ namespace Jzon if (IsNumber()) { std::stringstream sstr(valueStr); - int val; + int val = 0; sstr >> val; return val; } @@ -214,7 +214,7 @@ namespace Jzon if (IsNumber()) { std::stringstream sstr(valueStr); - float val; + float val = 0; sstr >> val; return val; } @@ -225,7 +225,7 @@ namespace Jzon if (IsNumber()) { std::stringstream sstr(valueStr); - double val; + double val = 0; sstr >> val; return val; } diff --git a/samples/geotag.cpp b/samples/geotag.cpp index c0d5f409..55520a4c 100644 --- a/samples/geotag.cpp +++ b/samples/geotag.cpp @@ -235,8 +235,8 @@ std::string Position::toExifTimeStamp(std::string& t) int mm = 0 ; int SS1 = 0 ; if ( strstr(arg,":") || strstr(arg,"-") ) { - int YY,MM,DD ; - char a,b,c,d,e ; + int YY=0,MM=0,DD=0; + char a=0,b=0,c=0,d=0,e=0; sscanf(arg,"%d%c%d%c%d%c%d%c%d%c%d",&YY,&a,&MM,&b,&DD,&c,&HH,&d,&mm,&e,&SS1); } sprintf(result,"%d/1 %d/1 %d/1",HH,mm,SS1); @@ -406,8 +406,8 @@ time_t parseTime(const char* arg,bool bAdjust) // if ( strstr(arg,":") || strstr(arg,"-") ) { - int YY,MM,DD,HH,mm,SS1 ; - char a,b,c,d,e ; + int YY=0,MM=0,DD=0,HH=0,mm=0,SS1=0; + char a=0,b=0,c=0,d=0,e=0; sscanf(arg,"%d%c%d%c%d%c%d%c%d%c%d",&YY,&a,&MM,&b,&DD,&c,&HH,&d,&mm,&e,&SS1); struct tm T; @@ -741,7 +741,7 @@ int parseTZ(const char* adjust) { int h=0; int m=0; - char c ; + char c=0; try { sscanf(adjust,"%d%c%d",&h,&c,&m); } catch ( ... ) {} ; diff --git a/samples/largeiptc-test.cpp b/samples/largeiptc-test.cpp index 62bab71b..99ee5db0 100644 --- a/samples/largeiptc-test.cpp +++ b/samples/largeiptc-test.cpp @@ -69,8 +69,8 @@ int main(int argc, char* const argv[]) Exiv2::DataBuf irb = Exiv2::Photoshop::setIptcIrb(nullptr, 0, iptcData); std::cout << "IRB buffer : " << irb.size_ << "\n"; const Exiv2::byte* record; - uint32_t sizeHdr; - uint32_t sizeData; + uint32_t sizeHdr = 0; + uint32_t sizeData = 0; Exiv2::Photoshop::locateIptcIrb(irb.pData_, irb.size_, &record, &sizeHdr, &sizeData); Exiv2::DataBuf rawIptc = Exiv2::IptcParser::encode(iptcData); std::cout << "Comparing IPTC and IRB size... "; diff --git a/samples/stringto-test.cpp b/samples/stringto-test.cpp index a308c8f1..d4f8fe70 100644 --- a/samples/stringto-test.cpp +++ b/samples/stringto-test.cpp @@ -76,7 +76,7 @@ int main() try { std::string s(testcase); std::cout << std::setw(12) << std::left << s; - bool ok; + bool ok = false; long l = Exiv2::parseLong(s, ok); std::cout << std::setw(12) << std::left; diff --git a/samples/write-test.cpp b/samples/write-test.cpp index 2c571272..f084348d 100644 --- a/samples/write-test.cpp +++ b/samples/write-test.cpp @@ -58,7 +58,7 @@ int main(int argc, char* const argv[]) std::string testFile = argv[1]; std::istringstream iss(argv[2]); - int testNo; + int testNo = 0; iss >> testNo; int rc = 0; diff --git a/src/actions.cpp b/src/actions.cpp index 0c04e214..7398d87f 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -1805,7 +1805,7 @@ namespace { std::memset(tm, 0x0, sizeof(struct tm)); tm->tm_isdst = -1; - long tmp; + long tmp = 0; if (!Util::strtol(timeStr.substr(0,4).c_str(), tmp)) return 5; tm->tm_year = tmp - 1900; if (!Util::strtol(timeStr.substr(5,2).c_str(), tmp)) return 6; diff --git a/src/bmffimage.cpp b/src/bmffimage.cpp index d686997e..3713251d 100644 --- a/src/bmffimage.cpp +++ b/src/bmffimage.cpp @@ -564,6 +564,7 @@ namespace Exiv2 visits_max_ = io_->size() / 16; unknownID_ = 0xffff; exifID_ = unknownID_; + xmpID_ = unknownID_; long address = 0; while (address < static_cast(io_->size())) { diff --git a/src/canonmn_int.cpp b/src/canonmn_int.cpp index ce304a21..5fe8d824 100644 --- a/src/canonmn_int.cpp +++ b/src/canonmn_int.cpp @@ -2686,7 +2686,7 @@ namespace Exiv2 { const ExifData*) { std::istringstream is(value.toString()); - uint32_t l; + uint32_t l = 0; is >> l; return os << std::setw(4) << std::setfill('0') << std::hex << ((l & 0xffff0000) >> 16) diff --git a/src/convert.cpp b/src/convert.cpp index 1185e900..c113bf08 100644 --- a/src/convert.cpp +++ b/src/convert.cpp @@ -567,7 +567,7 @@ namespace Exiv2 { auto pos = exifData_->findKey(ExifKey(from)); if (pos == exifData_->end()) return; if (!prepareXmpTarget(to)) return; - int year, month, day, hour, min, sec; + int year=0, month=0, day=0, hour=0, min=0, sec=0; std::string subsec; char buf[30]; diff --git a/src/datasets.cpp b/src/datasets.cpp index 7d0f2722..9cd62df5 100644 --- a/src/datasets.cpp +++ b/src/datasets.cpp @@ -497,7 +497,7 @@ namespace Exiv2 { uint16_t IptcDataSets::dataSet(const std::string& dataSetName, uint16_t recordId) { - uint16_t dataSet; + uint16_t dataSet = 0; int idx = dataSetIdx(dataSetName, recordId); if (idx != -1) { // dataSetIdx checks the range of recordId diff --git a/src/http.cpp b/src/http.cpp index 27ad42c0..d82770f9 100644 --- a/src/http.cpp +++ b/src/http.cpp @@ -308,7 +308,7 @@ int Exiv2::http(Exiv2::Dictionary& request,Exiv2::Dictionary& response,std::stri //////////////////////////////////// // read and process the response - int err ; + int err = 0; n = forgive(recv(sockfd, buffer, static_cast(buff_l), 0), err); while ( n >= 0 && OK(status) ) { if ( n ) { diff --git a/src/image.cpp b/src/image.cpp index ee962217..bc80549e 100644 --- a/src/image.cpp +++ b/src/image.cpp @@ -257,7 +257,7 @@ namespace Exiv2 { uint16_t Image::byteSwap2(const DataBuf& buf,size_t offset,bool bSwap) { - uint16_t v; + uint16_t v = 0; auto p = reinterpret_cast(&v); p[0] = buf.pData_[offset]; p[1] = buf.pData_[offset+1]; @@ -266,7 +266,7 @@ namespace Exiv2 { uint32_t Image::byteSwap4(const DataBuf& buf,size_t offset,bool bSwap) { - uint32_t v; + uint32_t v = 0; auto p = reinterpret_cast(&v); p[0] = buf.pData_[offset]; p[1] = buf.pData_[offset+1]; @@ -277,7 +277,7 @@ namespace Exiv2 { uint64_t Image::byteSwap8(const DataBuf& buf,size_t offset,bool bSwap) { - uint64_t v; + uint64_t v = 0; auto p = reinterpret_cast(&v); for(int i = 0; i < 8; i++) diff --git a/src/pgfimage.cpp b/src/pgfimage.cpp index b65a1990..0b36d140 100644 --- a/src/pgfimage.cpp +++ b/src/pgfimage.cpp @@ -66,7 +66,7 @@ namespace Exiv2 { static uint32_t byteSwap_(Exiv2::DataBuf& buf,size_t offset,bool bSwap) { - uint32_t v; + uint32_t v = 0; auto p = reinterpret_cast(&v); int i; for ( i = 0 ; i < 4 ; i++ ) p[i] = buf.pData_[offset+i]; @@ -189,7 +189,7 @@ namespace Exiv2 { readPgfHeaderSize(*io_); - int w, h; + int w = 0, h = 0; DataBuf header = readPgfHeaderStructure(*io_, w, h); Image::UniquePtr img = ImageFactory::create(ImageType::png); diff --git a/src/preview.cpp b/src/preview.cpp index 8d885672..de010057 100644 --- a/src/preview.cpp +++ b/src/preview.cpp @@ -482,8 +482,8 @@ namespace { if (nativePreview_.filter_ == "hex-irb") { const DataBuf psData = decodeHex(data + nativePreview_.position_, static_cast(nativePreview_.size_)); const byte *record; - uint32_t sizeHdr; - uint32_t sizeData; + uint32_t sizeHdr = 0; + uint32_t sizeData = 0; if (Photoshop::locatePreviewIrb(psData.pData_, psData.size_, &record, &sizeHdr, &sizeData) != 0) { #ifndef SUPPRESS_WARNINGS EXV_WARNING << "Missing preview IRB in Photoshop EPS preview.\n"; diff --git a/src/tags_int.cpp b/src/tags_int.cpp index 1809df7f..492f1990 100644 --- a/src/tags_int.cpp +++ b/src/tags_int.cpp @@ -2603,7 +2603,7 @@ namespace Exiv2 { if (ti != nullptr && ti->tag_ != 0xffff) return ti->tag_; if (!isHex(tagName, 4, "0x")) throw Error(kerInvalidTag, tagName, ifdId); std::istringstream is(tagName); - uint16_t tag; + uint16_t tag = 0; is >> std::hex >> tag; return tag; } // tagNumber diff --git a/src/types.cpp b/src/types.cpp index 8fbb3a9f..c1886371 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -532,7 +532,7 @@ namespace Exiv2 { assert(buf != 0); assert(tm != 0); int rc = 1; - int year, mon, mday, hour, min, sec; + int year = 0, mon = 0, mday = 0, hour = 0, min = 0, sec = 0; int scanned = std::sscanf(buf, "%4d:%2d:%2d %2d:%2d:%2d", &year, &mon, &mday, &hour, &min, &sec); if (scanned == 6) { diff --git a/src/value.cpp b/src/value.cpp index eedc2032..f71d498b 100644 --- a/src/value.cpp +++ b/src/value.cpp @@ -172,7 +172,7 @@ namespace Exiv2 { int DataValue::read(const std::string& buf) { std::istringstream is(buf); - int tmp; + int tmp = 0; ValueType val; while (!(is.eof())) { is >> tmp; @@ -1092,7 +1092,7 @@ namespace Exiv2 { { int rc = 1; Time t; - char plusMinus; + char plusMinus = 0; int scanned = sscanf(buf, format, &t.hour, &t.minute, &t.second, &plusMinus, &t.tzHour, &t.tzMinute); if ( scanned == 6 diff --git a/src/webpimage.cpp b/src/webpimage.cpp index 647f8308..b880d57f 100644 --- a/src/webpimage.cpp +++ b/src/webpimage.cpp @@ -191,7 +191,7 @@ namespace Exiv2 { DataBuf payload(size); readOrThrow(*io_, payload.pData_, payload.size_, Exiv2::kerCorruptedMetadata); if ( payload.size_ % 2 ) { - byte c; + byte c = 0; readOrThrow(*io_, &c, 1, Exiv2::kerCorruptedMetadata); } diff --git a/src/xmp.cpp b/src/xmp.cpp index 58dfe13f..0c13f069 100644 --- a/src/xmp.cpp +++ b/src/xmp.cpp @@ -604,7 +604,7 @@ namespace Exiv2 { SXMPMeta meta(xmpPacket.data(), static_cast(xmpPacket.size())); SXMPIterator iter(meta); std::string schemaNs, propPath, propValue; - XMP_OptionBits opt; + XMP_OptionBits opt = 0; while (iter.Next(&schemaNs, &propPath, &propValue, &opt)) { printNode(schemaNs, propPath, propValue, opt); if (XMP_PropIsAlias(opt)) { @@ -659,7 +659,7 @@ namespace Exiv2 { bool simpleArray = true; SXMPIterator aIter(meta, schemaNs.c_str(), propPath.c_str()); std::string aSchemaNs, aPropPath, aPropValue; - XMP_OptionBits aOpt; + XMP_OptionBits aOpt = 0; while (aIter.Next(&aSchemaNs, &aPropPath, &aPropValue, &aOpt)) { if (propPath == aPropPath) continue; if ( !XMP_PropIsSimple(aOpt)