From: Tobias Markus Date: Tue, 3 Mar 2015 16:06:37 +0000 (+0100) Subject: Patch Squirrel before starting coverity analysis X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=43302b043f7a8268d4221b961bfc2c603c5b95e9;p=supertux.git Patch Squirrel before starting coverity analysis --- diff --git a/external/squirrel/CMakeLists.txt b/external/squirrel/CMakeLists.txt index 0c4ef292d..8a95f7f3d 100644 --- a/external/squirrel/CMakeLists.txt +++ b/external/squirrel/CMakeLists.txt @@ -17,6 +17,16 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # +## Apply patch that fixes some Coverity errors + +## Apply coverity patch to Squirrel? +SET(APPLY_COVERITY_PATCH TRUE) + +FIND_PROGRAM(PATCH_EXECUTABLE patch) +IF(PATCH_EXECUTABLE AND APPLY_COVERITY_PATCH) + EXECUTE_PROCESS(COMMAND patch -p1 --forward -i squirrel_coverity.patch) +ENDIF(PATCH_EXECUTABLE AND APPLY_COVERITY_PATCH) + ## Add include/ to include directories INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include/) diff --git a/squirrel_coverity.patch b/squirrel_coverity.patch new file mode 100644 index 000000000..82681aa89 --- /dev/null +++ b/squirrel_coverity.patch @@ -0,0 +1,72 @@ +diff --git a/external/squirrel/sqstdlib/sqstdstring.cpp b/external/squirrel/sqstdlib/sqstdstring.cpp +index 33316fa..a213135 100644 +--- a/external/squirrel/sqstdlib/sqstdstring.cpp ++++ b/external/squirrel/sqstdlib/sqstdstring.cpp +@@ -116,6 +116,7 @@ SQRESULT sqstd_format(HSQUIRRELVM v,SQInteger nformatstringidx,SQInteger *outlen + fmt[fpos++] = _SC('\0'); + } + #endif ++ break; + case 'c': + if(SQ_FAILED(sq_getinteger(v,nparam,&ti))) + return sq_throwerror(v,_SC("integer expected for the specified format")); +diff --git a/external/squirrel/squirrel/sqfuncstate.cpp b/external/squirrel/squirrel/sqfuncstate.cpp +index aff80e5..1667815 100644 +--- a/external/squirrel/squirrel/sqfuncstate.cpp ++++ b/external/squirrel/squirrel/sqfuncstate.cpp +@@ -460,6 +460,7 @@ void SQFuncState::AddInstruction(SQInstruction &i) + pi._arg1 = i._arg1; + return; + } ++ break; + case _OP_SET: + case _OP_NEWSLOT: + if(i._arg0 == i._arg3) { +diff --git a/external/squirrel/squirrel/sqlexer.cpp b/external/squirrel/squirrel/sqlexer.cpp +index 547835b..9df5f1f 100644 +--- a/external/squirrel/squirrel/sqlexer.cpp ++++ b/external/squirrel/squirrel/sqlexer.cpp +@@ -192,6 +192,7 @@ SQInteger SQLexer::Lex() + NEXT(); + if (CUR_CHAR != _SC('=')){ RETURN_TOKEN('!')} + else { NEXT(); RETURN_TOKEN(TK_NE); } ++ break; + case _SC('@'): { + SQInteger stype; + NEXT(); +@@ -211,6 +212,7 @@ SQInteger SQLexer::Lex() + } + Error(_SC("error parsing the string")); + } ++ break; + case _SC('{'): case _SC('}'): case _SC('('): case _SC(')'): case _SC('['): case _SC(']'): + case _SC(';'): case _SC(','): case _SC('?'): case _SC('^'): case _SC('~'): + {SQInteger ret = CUR_CHAR; +diff --git a/external/squirrel/squirrel/sqvm.cpp b/external/squirrel/squirrel/sqvm.cpp +index de0927f..e941231 100644 +--- a/external/squirrel/squirrel/sqvm.cpp ++++ b/external/squirrel/squirrel/sqvm.cpp +@@ -306,6 +306,7 @@ bool SQVM::ToString(const SQObjectPtr &o,SQObjectPtr &res) + } + } + } ++ break; + default: + scsprintf(_sp(rsl(sizeof(void*)+20)),_SC("(%s : 0x%p)"),GetTypeName(o),(void*)_rawval(o)); + } +@@ -561,6 +562,7 @@ bool SQVM::FOREACH_OP(SQObjectPtr &o1,SQObjectPtr &o2,SQObjectPtr + _generator(o1)->Resume(this, o3); + _FINISH(0); + } ++ break; + default: + Raise_Error(_SC("cannot iterate %s"), GetTypeName(o1)); + } +@@ -724,6 +726,7 @@ exception_restore: + continue; + } + } ++ break; + case _OP_CALL: { + SQObjectPtr clo = STK(arg1); + switch (type(clo)) {