fix: zero initialize local variables. (#1743)
* Zero initialize local variables. * Initialize xmpID_
This commit is contained in:
parent
fe83c739a2
commit
2b84f4bd64
@ -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;
|
||||
|
||||
@ -1560,7 +1560,7 @@ namespace Exiv2 {
|
||||
int ValueType<T>::read(const std::string& buf)
|
||||
{
|
||||
std::istringstream is(buf);
|
||||
T tmp;
|
||||
T tmp = T();
|
||||
ValueList val;
|
||||
while (!(is.eof())) {
|
||||
is >> tmp;
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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)
|
||||
// <time>2012-07-14T17:33:16Z</time>
|
||||
|
||||
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 ( ... ) {} ;
|
||||
|
||||
@ -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... ";
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -564,6 +564,7 @@ namespace Exiv2
|
||||
visits_max_ = io_->size() / 16;
|
||||
unknownID_ = 0xffff;
|
||||
exifID_ = unknownID_;
|
||||
xmpID_ = unknownID_;
|
||||
|
||||
long address = 0;
|
||||
while (address < static_cast<long>(io_->size())) {
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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];
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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<int>(buff_l), 0), err);
|
||||
while ( n >= 0 && OK(status) ) {
|
||||
if ( n ) {
|
||||
|
||||
@ -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<char*>(&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<char*>(&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<byte*>(&v);
|
||||
|
||||
for(int i = 0; i < 8; i++)
|
||||
|
||||
@ -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<char*>(&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);
|
||||
|
||||
@ -482,8 +482,8 @@ namespace {
|
||||
if (nativePreview_.filter_ == "hex-irb") {
|
||||
const DataBuf psData = decodeHex(data + nativePreview_.position_, static_cast<long>(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";
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
||||
@ -604,7 +604,7 @@ namespace Exiv2 {
|
||||
SXMPMeta meta(xmpPacket.data(), static_cast<XMP_StringLen>(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)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user