make conversions explicit

Found with MSVC's C4244

Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
Rosen Penev 2023-02-11 14:40:19 -08:00
parent 785a9ed084
commit 5eebbbcbfb
5 changed files with 7 additions and 8 deletions

View File

@ -469,7 +469,7 @@ int Params::option(int opt, const std::string& optArg, int optOpt) {
int Params::setLogLevel(const std::string& optArg) {
int rc = 0;
const char logLevel = tolower(optArg[0]);
const auto logLevel = static_cast<char>(tolower(optArg[0]));
switch (logLevel) {
case 'd':
Exiv2::LogMsg::setLevel(Exiv2::LogMsg::debug);

View File

@ -81,7 +81,7 @@ char to_hex(char code) {
/// @brief Convert a hex character to its integer value.
char from_hex(char ch) {
return isdigit(ch) ? ch - '0' : tolower(ch) - 'a' + 10;
return isdigit(ch) ? ch - '0' : static_cast<char>(tolower(ch)) - 'a' + 10;
}
std::string urlencode(const std::string& str) {

View File

@ -469,9 +469,9 @@ void Image::printIFDStructure(BasicIo& io, std::ostream& out, Exiv2::PrintStruct
if (bNikon) {
// tag is an embedded tiff
const long byteslen = count - jump;
DataBuf bytes(byteslen); // allocate a buffer
io.readOrThrow(bytes.data(), byteslen, ErrorCode::kerCorruptedMetadata); // read
MemIo memIo(bytes.c_data(), byteslen); // create a file
auto b = DataBuf(byteslen); // allocate a buffer
io.readOrThrow(b.data(), byteslen, ErrorCode::kerCorruptedMetadata); // read
MemIo memIo(b.c_data(), byteslen); // create a file
printTiffStructure(memIo, out, option, depth + 1);
} else {
// tag is an IFD

View File

@ -2289,7 +2289,7 @@ static DataBuf sonyTagCipher(uint16_t /* tag */, const byte* bytes, size_t size,
byte code[256];
for (uint32_t i = 0; i < 249; i++) {
if (bDecipher) {
code[(i * i * i) % 249] = i;
code[(i * i * i) % 249] = static_cast<byte>(i);
} else {
code[i] = (i * i * i) % 249;
}

View File

@ -127,8 +127,7 @@ static std::vector<std::string> getLoadedLibraries() {
char szFilename[_MAX_PATH];
for (DWORD h = 0; h < cbNeeded / sizeof(handles[0]); h++) {
GetModuleFileNameA(handles[h], szFilename, static_cast<DWORD>(std::size(szFilename)));
std::string path(szFilename);
pushPath(path, libs, paths);
pushPath(szFilename, libs, paths);
}
}
#elif defined(__APPLE__)