Skip to content

Commit

Permalink
Use appropriate print format specifiers and constants
Browse files Browse the repository at this point in the history
  • Loading branch information
kmilos committed Nov 13, 2023
1 parent de8f1bd commit e9ba894
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions src/rafimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "safe_op.hpp"
#include "tiffimage.hpp"

#include <cinttypes>
#include <iostream>

// *****************************************************************************
Expand Down Expand Up @@ -71,7 +72,7 @@ void RafImage::printStructure(std::ostream& out, PrintStructureOption option, si
if (bPrint) {
io_->seek(0, BasicIo::beg); // rewind
size_t address = io_->tell();
constexpr auto format = " %9zu | %9ld | ";
constexpr auto format = " %9zu | %9" PRIu32 " | ";

{
out << Internal::indent(depth) << "STRUCTURE OF RAF FILE: " << io().path() << std::endl;
Expand All @@ -82,7 +83,7 @@ void RafImage::printStructure(std::ostream& out, PrintStructureOption option, si
io_->readOrThrow(magicdata, 16);
magicdata[16] = 0;
{
out << Internal::indent(depth) << Internal::stringFormat(format, address, 16L) // 0
out << Internal::indent(depth) << Internal::stringFormat(format, address, 16U) // 0
<< " magic : " << reinterpret_cast<char*>(magicdata) << std::endl;
}

Expand All @@ -91,7 +92,7 @@ void RafImage::printStructure(std::ostream& out, PrintStructureOption option, si
io_->read(data1, 4);
data1[4] = 0;
{
out << Internal::indent(depth) << Internal::stringFormat(format, address, 4L) // 16
out << Internal::indent(depth) << Internal::stringFormat(format, address, 4U) // 16
<< " data1 : " << std::string(reinterpret_cast<char*>(&data1)) << std::endl;
}

Expand All @@ -100,7 +101,7 @@ void RafImage::printStructure(std::ostream& out, PrintStructureOption option, si
io_->read(data2, 8);
data2[8] = 0;
{
out << Internal::indent(depth) << Internal::stringFormat(format, address, 8L) // 20
out << Internal::indent(depth) << Internal::stringFormat(format, address, 8U) // 20
<< " data2 : " << std::string(reinterpret_cast<char*>(&data2)) << std::endl;
}

Expand All @@ -109,7 +110,7 @@ void RafImage::printStructure(std::ostream& out, PrintStructureOption option, si
io_->read(camdata, 32);
camdata[32] = 0;
{
out << Internal::indent(depth) << Internal::stringFormat(format, address, 32L) // 28
out << Internal::indent(depth) << Internal::stringFormat(format, address, 32U) // 28
<< " camera : " << std::string(reinterpret_cast<char*>(&camdata)) << std::endl;
}

Expand All @@ -118,15 +119,15 @@ void RafImage::printStructure(std::ostream& out, PrintStructureOption option, si
io_->read(dir_version, 4);
dir_version[4] = 0;
{
out << Internal::indent(depth) << Internal::stringFormat(format, address, 4L) // 60
out << Internal::indent(depth) << Internal::stringFormat(format, address, 4U) // 60
<< " version : " << std::string(reinterpret_cast<char*>(&dir_version)) << std::endl;
}

address = io_->tell();
DataBuf unknown(20);
io_->readOrThrow(unknown.data(), unknown.size());
{
out << Internal::indent(depth) << Internal::stringFormat(format, address, 20L)
out << Internal::indent(depth) << Internal::stringFormat(format, address, 20U)
<< " unknown : " << Internal::binaryToString(makeSlice(unknown, 0, unknown.size())) << std::endl;
}

Expand All @@ -144,9 +145,9 @@ void RafImage::printStructure(std::ostream& out, PrintStructureOption option, si
std::stringstream j_len;
j_off << jpg_img_off;
j_len << jpg_img_len;
out << Internal::indent(depth) << Internal::stringFormat(format, address, 4L) << " JPEG offset : " << j_off.str()
out << Internal::indent(depth) << Internal::stringFormat(format, address, 4U) << " JPEG offset : " << j_off.str()
<< std::endl;
out << Internal::indent(depth) << Internal::stringFormat(format, address2, 4L) << " JPEG length : " << j_len.str()
out << Internal::indent(depth) << Internal::stringFormat(format, address2, 4U) << " JPEG length : " << j_len.str()
<< std::endl;
}

Expand All @@ -166,9 +167,9 @@ void RafImage::printStructure(std::ostream& out, PrintStructureOption option, si
std::stringstream c_len;
c_off << meta_off[i];
c_len << meta_len[i];
out << Internal::indent(depth) << Internal::stringFormat(format, address, 4L) << "meta offset" << i + 1 << " : "
out << Internal::indent(depth) << Internal::stringFormat(format, address, 4U) << "meta offset" << i + 1 << " : "
<< c_off.str() << std::endl;
out << Internal::indent(depth) << Internal::stringFormat(format, address2, 4L) << "meta length" << i + 1
out << Internal::indent(depth) << Internal::stringFormat(format, address2, 4U) << "meta length" << i + 1
<< " : " << c_len.str() << std::endl;
}

Expand Down Expand Up @@ -198,15 +199,15 @@ void RafImage::printStructure(std::ostream& out, PrintStructureOption option, si
c_skip << cfa_skip[i];
c_size << cfa_size[i];
c_stride << cfa_stride[i];
out << Internal::indent(depth) << Internal::stringFormat(format, address, 4L) << " CFA offset" << i + 1 << " : "
out << Internal::indent(depth) << Internal::stringFormat(format, address, 4U) << " CFA offset" << i + 1 << " : "
<< c_off.str() << std::endl;
out << Internal::indent(depth) << Internal::stringFormat(format, address2, 4L) << " CFA length" << i + 1
out << Internal::indent(depth) << Internal::stringFormat(format, address2, 4U) << " CFA length" << i + 1
<< " : " << c_len.str() << std::endl;
out << Internal::indent(depth) << Internal::stringFormat(format, address3, 4L) << " CFA skip" << i + 1
out << Internal::indent(depth) << Internal::stringFormat(format, address3, 4U) << " CFA skip" << i + 1
<< " : " << c_skip.str() << std::endl;
out << Internal::indent(depth) << Internal::stringFormat(format, address4, 4L) << " CFA chunk" << i + 1
out << Internal::indent(depth) << Internal::stringFormat(format, address4, 4U) << " CFA chunk" << i + 1
<< " : " << c_size.str() << std::endl;
out << Internal::indent(depth) << Internal::stringFormat(format, address5, 4L) << " CFA stride" << i + 1
out << Internal::indent(depth) << Internal::stringFormat(format, address5, 4U) << " CFA stride" << i + 1
<< " : " << c_stride.str() << std::endl;
}
}
Expand Down

0 comments on commit e9ba894

Please sign in to comment.