From 2563b9f99fb46235fb29af196ba4875abd6a39e6 Mon Sep 17 00:00:00 2001 From: clanmills Date: Thu, 29 Aug 2019 08:36:45 +0100 Subject: [PATCH] Changes following review by @D4N. --- src/tags_int.cpp | 2 +- src/tags_int.hpp | 2 +- src/tiffvisitor_int.cpp | 8 ++++---- tests/bugfixes/github/test_issue_981.py | 16 ++++++++-------- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/tags_int.cpp b/src/tags_int.cpp index 56cb768121..add8194635 100644 --- a/src/tags_int.cpp +++ b/src/tags_int.cpp @@ -2171,7 +2171,7 @@ namespace Exiv2 { uint16_t bit = 0; uint16_t comma = 0; for (uint16_t i = 0; i < value.count(); i++ ) { // for each element in value array - uint16_t bits = (uint16_t) value.toLong(i); + uint16_t bits = static_cast(value.toLong(i)); for (uint16_t b = 0; b < 16; ++b) { // for every bit if (bits & (1 << b)) { if ( comma++ ) { diff --git a/src/tags_int.hpp b/src/tags_int.hpp index 65f09df830..7ff48b227f 100644 --- a/src/tags_int.hpp +++ b/src/tags_int.hpp @@ -441,7 +441,7 @@ namespace Exiv2 { std::ostream& printXmpVersion(std::ostream& os, const Value& value, const ExifData*); //! Print a date following the format YYYY-MM-DDTHH:MM:SSZ std::ostream& printXmpDate(std::ostream& os, const Value& value, const ExifData*); - //! Print a mask + //! Print a bitmask as (none) | n | n,m... where: (none) = no bits set | n = bit n from left (0=left-most) | n,m.. = multiple bits " std::ostream& printBitmask(std::ostream& os, const Value& value, const ExifData*); //@} diff --git a/src/tiffvisitor_int.cpp b/src/tiffvisitor_int.cpp index 8a8ca2d04b..930a75ddc2 100644 --- a/src/tiffvisitor_int.cpp +++ b/src/tiffvisitor_int.cpp @@ -472,7 +472,7 @@ namespace Exiv2 { void TiffDecoder::decodeCanonAFInfo(const TiffEntryBase* object) { // report Exif.Canon.AFInfo as usual TiffDecoder::decodeStdTiffEntry(object); - if ( !object->pValue()->count() || object->pValue()->typeId() != unsignedShort ) return; // no data! + if ( object->pValue()->count() < 3 || object->pValue()->typeId() != unsignedShort ) return; // insufficient data // create vector of signedShorts from unsignedShorts in Exif.Canon.AFInfo std::vector ints; @@ -486,7 +486,7 @@ namespace Exiv2 { std::string familyGroup(std::string("Exif.") + groupName(object->group()) + "."); - const uint16_t nPoints = uint[2]; + const uint16_t nPoints = uint.at(2); const uint16_t nMasks = (nPoints+15)/(sizeof(uint16_t) * 8); int nStart = 0; @@ -524,9 +524,9 @@ namespace Exiv2 { Exiv2::Value::AutoPtr v = Exiv2::Value::create(records[i].bSigned?Exiv2::signedShort:Exiv2::unsignedShort); std::ostringstream s; if ( records[i].bSigned ) { - for ( int16_t k = 0 ; k < records[i].size ; k++ ) s << " " << ints[nStart++]; + for ( int16_t k = 0 ; k < records[i].size ; k++ ) s << " " << ints.at(nStart++); } else { - for ( int16_t k = 0 ; k < records[i].size ; k++ ) s << " " << uint[nStart++]; + for ( int16_t k = 0 ; k < records[i].size ; k++ ) s << " " << uint.at(nStart++); } v->read(s.str()); diff --git a/tests/bugfixes/github/test_issue_981.py b/tests/bugfixes/github/test_issue_981.py index d60355e345..8ca937de79 100644 --- a/tests/bugfixes/github/test_issue_981.py +++ b/tests/bugfixes/github/test_issue_981.py @@ -9,12 +9,12 @@ class CanonAfInfoTest(metaclass=CaseMeta): filenameC = path("$data_path/test_issue_981c.exv") filenameC = path("$data_path/test_issue_981c.exv") filenameD = path("$data_path/test_issue_981d.exv") - commands = ["$exiv2 -pa --grep Canon.AF $filenameA" - ,"$exiv2 -pa --grep Canon.AF $filenameB" - ,"$exiv2 -pv --grep Points $filenameC" - ,"$exiv2 -pt --grep Points $filenameC" - ,"$exiv2 -pv --grep Primary $filenameD" - ,"$exiv2 -pt --grep Primary $filenameD" + commands = ["$exiv2 -pa --grep Canon.AF $filenameA", + "$exiv2 -pa --grep Canon.AF $filenameB", + "$exiv2 -pv --grep Points $filenameC", + "$exiv2 -pt --grep Points $filenameC", + "$exiv2 -pv --grep Primary $filenameD", + "$exiv2 -pt --grep Primary $filenameD", ] stdout = ["""Exif.Canon.AFInfo Short 48 96 2 9 9 4752 3168 4272 2848 115 115 115 162 200 162 115 115 115 153 153 153 105 199 105 153 153 153 64409 64862 64862 0 0 0 674 674 1127 0 321 65215 603 0 64933 321 65215 0 16 256 0 65535 @@ -61,5 +61,5 @@ class CanonAfInfoTest(metaclass=CaseMeta): ""","""Exif.Canon.AFPrimaryPoint Short 4 3,4,9,10,11,30,31,35,36,40,41,55,59,60 """ ] - stderr = ["","","","","",""] - retval = [ 0, 0, 0, 0, 0,0 ] + stderr = [""]*len(commands) + retval = [ 0]*len(commands)