Skip to content

Commit 941017d

Browse files
authored
Fix issues on ARM builds (#2205)
* Specify base class initialization in Copy Constructor * Fix printing of uint64_t variable in ARM 32bits Use cinttypes * Fix alignment issues on ARM 32 bits * tests: add assertion with custom message
1 parent 6203ded commit 941017d

File tree

6 files changed

+12
-16
lines changed

6 files changed

+12
-16
lines changed

src/bmffimage.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "types.hpp"
1717

1818
// + standard includes
19+
#include <cinttypes>
1920
#include <cstdio>
2021
#include <cstring>
2122
#include <iostream>
@@ -184,7 +185,7 @@ long BmffImage::boxHandler(std::ostream& out /* = std::cout*/, Exiv2::PrintStruc
184185
if (bTrace) {
185186
bLF = true;
186187
out << indent(depth) << "Exiv2::BmffImage::boxHandler: " << toAscii(box_type)
187-
<< Internal::stringFormat(" %8ld->%lu ", address, box_length);
188+
<< Internal::stringFormat(" %8ld->%" PRIu64 " ", address, box_length);
188189
}
189190

190191
if (box_length == 1) {

src/datasets.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ IptcKey::IptcKey(uint16_t tag, uint16_t record) : tag_(tag), record_(record) {
508508
makeKey();
509509
}
510510

511-
IptcKey::IptcKey(const IptcKey& rhs) : tag_(rhs.tag_), record_(rhs.record_), key_(rhs.key_) {
511+
IptcKey::IptcKey(const IptcKey& rhs) : Key(), tag_(rhs.tag_), record_(rhs.record_), key_(rhs.key_) {
512512
}
513513

514514
std::string IptcKey::key() const {

src/jp2image.cpp

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -604,25 +604,20 @@ void Jp2Image::encodeJp2Header(const DataBuf& boxBuf, DataBuf& outBuf) {
604604
size_t outlen = boxHSize; // now many bytes have we written to output?
605605
size_t inlen = boxHSize; // how many bytes have we read from boxBuf?
606606
enforce(boxHSize <= output.size(), ErrorCode::kerCorruptedMetadata);
607-
auto pBox = reinterpret_cast<const Internal::Jp2BoxHeader*>(boxBuf.c_data());
608-
uint32_t length = getLong(reinterpret_cast<const byte*>(&pBox->length), bigEndian);
607+
uint32_t length = getLong(boxBuf.c_data(0), bigEndian);
609608
enforce(length <= output.size(), ErrorCode::kerCorruptedMetadata);
610609
uint32_t count = boxHSize;
611-
auto p = boxBuf.c_str();
612610
bool bWroteColor = false;
613611

614612
while (count < length && !bWroteColor) {
615613
enforce(boxHSize <= length - count, ErrorCode::kerCorruptedMetadata);
616-
auto pSubBox = reinterpret_cast<const Internal::Jp2BoxHeader*>(p + count);
617-
618-
// copy data. pointer could be into a memory mapped file which we will decode!
619614
Internal::Jp2BoxHeader subBox;
620-
memcpy(&subBox, pSubBox, boxHSize);
615+
memcpy(&subBox, boxBuf.c_data(count), boxHSize);
621616
Internal::Jp2BoxHeader newBox = subBox;
622617

623618
if (count < length) {
624-
subBox.length = getLong(reinterpret_cast<byte*>(&subBox.length), bigEndian);
625-
subBox.type = getLong(reinterpret_cast<byte*>(&subBox.type), bigEndian);
619+
subBox.length = getLong(boxBuf.c_data(count), bigEndian);
620+
subBox.type = getLong(boxBuf.c_data(count + 4), bigEndian);
626621
#ifdef EXIV2_DEBUG_MESSAGES
627622
std::cout << "Jp2Image::encodeJp2Header subbox: " << toAscii(subBox.type) << " length = " << subBox.length
628623
<< std::endl;
@@ -671,9 +666,8 @@ void Jp2Image::encodeJp2Header(const DataBuf& boxBuf, DataBuf& outBuf) {
671666
// allocate the correct number of bytes, copy the data and update the box header
672667
outBuf.alloc(outlen);
673668
std::copy_n(output.c_data(), outlen, outBuf.begin());
674-
auto oBox = reinterpret_cast<Internal::Jp2BoxHeader*>(outBuf.data());
675-
ul2Data(reinterpret_cast<byte*>(&oBox->type), kJp2BoxTypeHeader, bigEndian);
676-
ul2Data(reinterpret_cast<byte*>(&oBox->length), static_cast<uint32_t>(outlen), bigEndian);
669+
ul2Data(outBuf.data(0), static_cast<uint32_t>(outlen), bigEndian);
670+
ul2Data(outBuf.data(4), kJp2BoxTypeHeader, bigEndian);
677671
}
678672

679673
#ifdef __clang__

src/properties.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5097,7 +5097,7 @@ XmpKey::XmpKey(const std::string& prefix, const std::string& property) : p_(std:
50975097

50985098
XmpKey::~XmpKey() = default;
50995099

5100-
XmpKey::XmpKey(const XmpKey& rhs) : p_(std::make_unique<Impl>(*rhs.p_)) {
5100+
XmpKey::XmpKey(const XmpKey& rhs) : Key(), p_(std::make_unique<Impl>(*rhs.p_)) {
51015101
}
51025102

51035103
XmpKey& XmpKey::operator=(const XmpKey& rhs) {

src/tags.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ ExifKey::ExifKey(const std::string& key) : p_(std::make_unique<Impl>()) {
266266
p_->decomposeKey(key);
267267
}
268268

269-
ExifKey::ExifKey(const ExifKey& rhs) : p_(std::make_unique<Impl>(*rhs.p_)) {
269+
ExifKey::ExifKey(const ExifKey& rhs) : Key(), p_(std::make_unique<Impl>(*rhs.p_)) {
270270
}
271271

272272
ExifKey::~ExifKey() = default;

tests/bash_tests/testcases.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,7 @@ def test1120(img):
484484
BT.copyTestFile('large.icc', iccname)
485485
out += BT.Executer('exiv2 -iC {img}', vars())
486486
e = BT.Executer('exiv2 -pC {img}', vars(), compatible_output=False, decode_output=False)
487+
self.assertIsNotNone(e.stdout, msg="Empty ICC profile in {}".format(img))
487488
BT.save(e.stdout, stub + '_large_1.icc')
488489
out += BT.Executer('exiv2 -pS {img}', vars())
489490
out += BT.Executer('exiv2 -eC --force {img}', vars())

0 commit comments

Comments
 (0)