Skip to content

Commit

Permalink
Changes following review by @D4N.
Browse files Browse the repository at this point in the history
  • Loading branch information
clanmills committed Aug 29, 2019
1 parent b7e29e8 commit 2563b9f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/tags_int.cpp
Expand Up @@ -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<uint16_t>(value.toLong(i));
for (uint16_t b = 0; b < 16; ++b) { // for every bit
if (bits & (1 << b)) {
if ( comma++ ) {
Expand Down
2 changes: 1 addition & 1 deletion src/tags_int.hpp
Expand Up @@ -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*);
//@}

Expand Down
8 changes: 4 additions & 4 deletions src/tiffvisitor_int.cpp
Expand Up @@ -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<int16_t> ints;
Expand All @@ -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;

Expand Down Expand Up @@ -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());
Expand Down
16 changes: 8 additions & 8 deletions tests/bugfixes/github/test_issue_981.py
Expand Up @@ -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
Expand Down Expand Up @@ -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)

0 comments on commit 2563b9f

Please sign in to comment.