From 847abb23f03ca911bd9ed7dbdef97ac2c5469145 Mon Sep 17 00:00:00 2001 From: kovalev0 <107109684+kovalev0@users.noreply.github.com> Date: Sun, 8 Oct 2023 16:36:15 +0300 Subject: Fix warnings and throwing an exception instead of ignoring the error (#1229) * EMVCard.cpp: ArrayToHexWideString: prohibit conversion of a string constant ../Common/EMVCard.cpp: In function 'std::wstring VeraCrypt::ArrayToHexWideString(con st unsigned char*, size_t)': ../Common/EMVCard.cpp:28:43: warning: ISO C++ forbids converting a string constant to 'wchar_t*' [-Wwrite-strings] 28 | static wchar_t* hexChar = L"0123456789ABCDEF"; | ^~~~~~~~~~~~~~~~~~~ Signed-off-by: Vasiliy Kovalev * EMVCard.cpp: ArrayToHexWideString: fix of the comparison of different types ../Common/EMVCard.cpp: In function 'std::wstring VeraCrypt::ArrayToHexWideString(con st unsigned char*, size_t)': ../Common/EMVCard.cpp:32:43: warning: comparison of integer expressions of different signedness: 'int' and 'size_t' {aka 'long unsigned int'} [-Wsign-compare] 32 | for (int i = 0; i < cbData; i++) | ~~^~~~~~~~ Signed-off-by: Vasiliy Kovalev * SecurityTokenKeyfilesDialog.cpp: removed initialization of an unused variable Forms/SecurityTokenKeyfilesDialog.cpp:58:24: warning: unused variable 'i' [-Wunused- variable] 58 | size_t i = 0; | ^ Signed-off-by: Vasiliy Kovalev * Core/Unix: throwing an exception instead of ignoring the error Fixes: 5a6b445f ("fix warnings and UB (#1164)") Signed-off-by: Vasiliy Kovalev --------- Signed-off-by: Vasiliy Kovalev Co-authored-by: Vasiliy Kovalev --- src/Common/EMVCard.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Common') diff --git a/src/Common/EMVCard.cpp b/src/Common/EMVCard.cpp index 5f694240..e96422b1 100644 --- a/src/Common/EMVCard.cpp +++ b/src/Common/EMVCard.cpp @@ -25,11 +25,11 @@ namespace VeraCrypt #ifndef TC_WINDOWS wstring ArrayToHexWideString(const unsigned char * pbData, size_t cbData) { - static wchar_t* hexChar = L"0123456789ABCDEF"; + static const wchar_t* hexChar = L"0123456789ABCDEF"; wstring result; if (pbData) { - for (int i = 0; i < cbData; i++) + for (size_t i = 0; i < cbData; i++) { result += hexChar[pbData[i] >> 4]; result += hexChar[pbData[i] & 0x0F]; -- cgit v1.2.3