From 66a0ec801518b13c26cf8f5e986f6b0953a6ad00 Mon Sep 17 00:00:00 2001 From: Kevin Zhang Date: Wed, 14 Jul 2021 13:34:41 +0800 Subject: [PATCH] Fix codacy issue in cpp binding. As title. --- Source/buildbindingccpp.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/buildbindingccpp.go b/Source/buildbindingccpp.go index 01fc625c..0b513195 100644 --- a/Source/buildbindingccpp.go +++ b/Source/buildbindingccpp.go @@ -411,7 +411,7 @@ func buildDynamicCLoadTableCode(component ComponentDefinition, w LanguageWriter, w.Writeln("#ifdef _WIN32") w.Writeln("// Convert filename to UTF16-string") - w.Writeln("int nLength = (int)strlen(pLibraryFileName);") + w.Writeln("int nLength = static_cast(strnlen_s(pLibraryFileName, MAX_PATH));") w.Writeln("int nBufferSize = nLength * 2 + 2;") if (!useStrictC) { w.Writeln("std::vector wsLibraryFileName(nBufferSize);") @@ -965,7 +965,7 @@ func writeCPPInputVector(w LanguageWriter, NameSpace string, ClassIdentifier str w.Writeln(" ") w.Writeln("public:") w.Writeln(" ") - w.Writeln(" C%sInputVector( const std::vector& vec)", ClassIdentifier) + w.Writeln(" explicit C%sInputVector( const std::vector& vec)", ClassIdentifier) w.Writeln(" : m_data( vec.data() ), m_size( vec.size() )") w.Writeln(" {") w.Writeln(" }") @@ -1271,7 +1271,7 @@ func buildCppHeader(component ComponentDefinition, w LanguageWriter, NameSpace s w.Writeln(" ") if ExplicitLinking { - w.Writeln(" %s%sWrapper(void* pSymbolLookupMethod)", cppClassPrefix, ClassIdentifier) + w.Writeln(" explicit %s%sWrapper(void* pSymbolLookupMethod)", cppClassPrefix, ClassIdentifier) w.Writeln(" {") w.Writeln(" CheckError(nullptr, initWrapperTable(&m_WrapperTable));") w.Writeln(" CheckError(nullptr, loadWrapperTableFromSymbolLookupMethod(&m_WrapperTable, pSymbolLookupMethod));") @@ -1280,7 +1280,7 @@ func buildCppHeader(component ComponentDefinition, w LanguageWriter, NameSpace s w.Writeln(" }") w.Writeln(" ") - w.Writeln(" %s%sWrapper(const std::string &sFileName)", cppClassPrefix, ClassIdentifier) + w.Writeln(" explicit %s%sWrapper(const std::string &sFileName)", cppClassPrefix, ClassIdentifier) w.Writeln(" {") w.Writeln(" CheckError(nullptr, initWrapperTable(&m_WrapperTable));") w.Writeln(" CheckError(nullptr, loadWrapperTable(&m_WrapperTable, sFileName.c_str()));")