From e9ba89411bf82a21a6925414936929d2ae369fad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Milo=C5=A1=20Komar=C4=8Devi=C4=87?= Date: Mon, 13 Nov 2023 14:39:37 +0100 Subject: [PATCH] Use appropriate print format specifiers and constants --- src/rafimage.cpp | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/rafimage.cpp b/src/rafimage.cpp index 34164e3499..3ad906a68e 100644 --- a/src/rafimage.cpp +++ b/src/rafimage.cpp @@ -14,6 +14,7 @@ #include "safe_op.hpp" #include "tiffimage.hpp" +#include #include // ***************************************************************************** @@ -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; @@ -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(magicdata) << std::endl; } @@ -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(&data1)) << std::endl; } @@ -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(&data2)) << std::endl; } @@ -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(&camdata)) << std::endl; } @@ -118,7 +119,7 @@ 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(&dir_version)) << std::endl; } @@ -126,7 +127,7 @@ void RafImage::printStructure(std::ostream& out, PrintStructureOption option, si 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; } @@ -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; } @@ -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; } @@ -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; } }