Skip to content

Commit

Permalink
surpress last minute MISRA warnings from PVS-Studio.
Browse files Browse the repository at this point in the history
  • Loading branch information
JPeterMugaas committed May 10, 2024
1 parent 6c46b87 commit 9c96f57
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

cmake_minimum_required (VERSION 3.21)

set(EFXC2_VERSION 0.0.9.212)
set(EFXC2_VERSION 0.0.10.214)
project (efxc2 VERSION ${EFXC2_VERSION}
DESCRIPTION "Enhanced fxc2"
HOMEPAGE_URL "https://github.com/JPeterMugaas/efxc2"
Expand Down
18 changes: 9 additions & 9 deletions efxc2Cmds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ void efxc2Cmds::option_ignored(_In_ const efxc2Utils::M_STRING_VIEW Opt, _In_ co
}

void efxc2Cmds::parseInputFile(_In_ const efxc2Utils::M_STRING_VIEW parameter, efxc2CompilerParams::CompilerParams& params, efxc2Files::Files& files) {
efxc2Utils::M_STRING inputFile = efxc2Utils::M_STRING_INIT;
#ifdef _WIN32
std::string c_inputFile = "";
#endif
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 6001)
Expand All @@ -72,6 +68,10 @@ void efxc2Cmds::parseInputFile(_In_ const efxc2Utils::M_STRING_VIEW parameter, e
if (params.get_verbose() && params.get_debug()) {
std::cout << "Parse input file name\n";
}
efxc2Utils::M_STRING inputFile = efxc2Utils::M_STRING_INIT;
#ifdef _WIN32
std::string c_inputFile = "";
#endif
inputFile = parameter;
#ifdef _WIN32
efxc2Utils::FixupFileName(inputFile);
Expand Down Expand Up @@ -606,10 +606,10 @@ bool efxc2Cmds::parseCompilerFileCall( //-V2506
}

for (CompileFileEntry currentEntry : g_CompilerFileCall) {
if (argument.compare(arg_idx, currentEntry.Param.size(), currentEntry.Param) != 0) {
if (argument.compare(arg_idx, currentEntry.Param.size(), currentEntry.Param) != 0) { //-V2571 //-V3546
continue;
}
arg_idx += currentEntry.Param.size();
arg_idx += currentEntry.Param.size(); //-V2571 //-V3546
if (arg_idx >= argument.size()) {
*index += 1;
if (*index >= args.size()) {
Expand Down Expand Up @@ -650,15 +650,15 @@ bool efxc2Cmds::parseIgnoredOptions( //-V2506
else {
return false; //-V2506
}
if (efxc2Utils::M_STRING_VIEW toFind = argument.substr(arg_idx, std::string::npos);
if (efxc2Utils::M_STRING_VIEW toFind = argument.substr(arg_idx, std::string::npos); //-V2571 //-V3546
std::ranges::find(g_IgnoredOptions.begin(), g_IgnoredOptions.end(), toFind) != g_IgnoredOptions.end()) {
option_ignored(argument, params);
return true;
}
return false;
}

bool efxc2Cmds::parseNotSupportedOptions( //-V2506
bool efxc2Cmds::parseNotSupportedOptions( //-V2506
_In_ const efxc2Utils::M_CMD_PARAMS& args,
_In_ const size_t* index) {
if (!index || *index >= args.size()) {
Expand All @@ -675,7 +675,7 @@ bool efxc2Cmds::parseNotSupportedOptions( //-V2506
else {
return false;
}
if (efxc2Utils::M_STRING_VIEW toFind = argument.substr(arg_idx, std::string::npos);
if (efxc2Utils::M_STRING_VIEW toFind = argument.substr(arg_idx, std::string::npos); //-V2571 //-V3546
std::ranges::find(g_NotSupportedArgs.begin(), g_NotSupportedArgs.end(), toFind) != g_NotSupportedArgs.end()) {
#ifdef _WIN32
std::wcerr << std::format(L"option -{} not supported", argument);
Expand Down
6 changes: 3 additions & 3 deletions efxc2Compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ void efxc2Compiler::Compiler::Preprocess() {
if (SourceCode == nullptr) {
efxc2Utils::print_no_input_file();
}
size_t SourceLen = SourceCode->size();
size_t SourceLen = SourceCode->size(); //-V2571 //-V3546
auto includeDirs = params.get_includeDirs();
std::string _inputFile = params.get_inputFile();
const char* inputFile = _inputFile.c_str();
Expand Down Expand Up @@ -104,7 +104,7 @@ void efxc2Compiler::Compiler::Compile() {
if (SourceCode == nullptr) {
efxc2Utils::print_no_input_file();
}
size_t SourceLen = SourceCode->size();
size_t SourceLen = SourceCode->size(); //-V2571 //-V3546
auto eflags = params.get_eflags();
auto sflags = params.get_sflags();
auto secondary_flags = params.get_secondary_flags();
Expand Down Expand Up @@ -397,7 +397,7 @@ void efxc2Compiler::Compiler::EmbedPrivateData() {
auto const* compiledString = std::bit_cast<unsigned char*>(compilerOutput->GetBufferPointer());
size_t compiledLen = compilerOutput->GetBufferSize();
auto private_data = params.get_PrivateData();
size_t private_data_size = private_data->size();
size_t private_data_size = private_data->size(); //-V2571 //-V3546
if (params.get_verbose() && params.get_debug()) {
std::cout << "Calling D3DSetBlobPart(\n";
std::cout << "\t compiledString,\n";
Expand Down
2 changes: 1 addition & 1 deletion efxc2CompilerIncludes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ namespace efxc2CompilerIncludes {
efxc2Utils::M_STRING dir = { _dir.data(), _dir.size() };

(void) dirs.emplace(dirs.end(), dir);
(void) dirs[dirs.size() - 1].make_preferred();
(void) dirs[dirs.size() - 1].make_preferred(); //-V2563 //-V3539
}

}
8 changes: 4 additions & 4 deletions efxc2Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ std::string efxc2Utils::wstring_to_utf8(std::wstring const& wstr) //-V2506
_locale_t locale = _create_locale(LC_ALL, "en_US.UTF-8"); //-V3551 //-V2578
size_t nbytes = 0;
errno_t err = 0;
err = _wcstombs_s_l(&nbytes, nullptr, 0, wstr.c_str(), wstr.length() + 1, locale);
err = _wcstombs_s_l(&nbytes, nullptr, 0, wstr.c_str(), wstr.length() + 1, locale); //-V2563 //-V3539
if (err != 0) {
std::cerr << "_wcstombs_s_l failed." << std::endl;
_free_locale(locale);
Expand All @@ -281,7 +281,7 @@ std::string efxc2Utils::wstring_to_utf8(std::wstring const& wstr) //-V2506
auto str = std::make_unique<std::vector<char>>();
str->resize(nbytes + 1);
str->data()[nbytes] = '\0'; //-V3539 //-V2563
err = _wcstombs_s_l(&nbytes, str->data(), str->size(), wstr.c_str(),wstr.length() + 1, locale);
err = _wcstombs_s_l(&nbytes, str->data(), str->size(), wstr.c_str(),wstr.length() + 1, locale); //-V2563 //-V3539
if (err != 0) {
std::cerr << "_wcstombs_s_l failed." << std::endl;
exit(1); //-V2014 //-V3506 //-V2509
Expand All @@ -300,7 +300,7 @@ std::wstring efxc2Utils::utf8_to_wstring(std::string const& str) //-V2506
_locale_t locale = _create_locale(LC_ALL, "en_US.UTF-8"); //-V3551 //-V2578
size_t nchars = 0;
errno_t err = 0;
err = _mbstowcs_s_l(&nchars, nullptr, 0, str.c_str(), str.length() + 1, locale);
err = _mbstowcs_s_l(&nchars, nullptr, 0, str.c_str(), str.length() + 1, locale); //-V2563 //-V3539
if (err != 0) {
std::cerr << "_mbstowcs_s_l failed." << std::endl;
_free_locale(locale);
Expand All @@ -315,7 +315,7 @@ std::wstring efxc2Utils::utf8_to_wstring(std::string const& str) //-V2506
auto* wstr = std::bit_cast<wchar_t*>(_wstr->data());
wstr[nchars] = L'\0'; //-V3539 //-V2563

err = _mbstowcs_s_l(&nchars, wstr, nchars, str.c_str(), str.length() + 1, locale);
err = _mbstowcs_s_l(&nchars, wstr, nchars, str.c_str(), str.length() + 1, locale); //-V2563 //-V3539
if (err != 0) {
std::cerr << "_mbstowcs_s_l failed." << std::endl;
exit(1); //-V2014 //-V3506 //-V2509
Expand Down

0 comments on commit 9c96f57

Please sign in to comment.