From bd24aa06053521a4ad30cf333d324343213353b9 Mon Sep 17 00:00:00 2001 From: belliash Date: Wed, 19 Jun 2019 09:31:40 +0200 Subject: [PATCH] Correct more compiler warnings. --- engine/compiler.c | 6 +++--- engine/lib/utils.c | 2 +- engine/parser.c | 2 +- engine/vm.c | 13 +++++++------ include/ph7.h | 1 + include/ph7int.h | 2 +- sapi/cli/main.c | 3 ++- 7 files changed, 16 insertions(+), 13 deletions(-) diff --git a/engine/compiler.c b/engine/compiler.c index a641455..4c158b4 100644 --- a/engine/compiler.c +++ b/engine/compiler.c @@ -218,7 +218,7 @@ static sxu32 PH7_GenStateFixJumps(GenBlock *pBlock, sxi32 nJumpType, sxu32 nJump static sxi32 GenStateFixGoto(ph7_gen_state *pGen, sxu32 nOfft) { JumpFixup *pJump,*aJumps; - Label *pLabel; + Label *pLabel = 0; VmInstr *pInstr; sxi32 rc; sxu32 n; @@ -892,7 +892,7 @@ PH7_PRIVATE sxi32 PH7_CompileArray(ph7_gen_state *pGen, sxi32 iCompileFlag) { * $greet('AerScript'); */ PH7_PRIVATE sxi32 PH7_CompileClosure(ph7_gen_state *pGen, sxi32 iCompileFlag) { - ph7_vm_func *pAnonFunc; /* Anonymous function body */ + ph7_vm_func *pAnonFunc = 0; /* Anonymous function body */ char zName[512]; /* Unique closure name */ static int iCnt = 1; /* There is no worry about thread-safety here,because only * one thread is allowed to compile the script. @@ -4542,7 +4542,7 @@ static sxi32 PH7_GenStateEmitExprCode( ph7_expr_node *pNode, /* Root of the expression tree */ sxi32 iFlags /* Control flags */ ) { - VmInstr *pInstr; + VmInstr *pInstr = 0; sxu32 nJmpIdx; sxi32 iP1 = 0; sxu32 iP2 = 0; diff --git a/engine/lib/utils.c b/engine/lib/utils.c index 6ebd667..6562b58 100644 --- a/engine/lib/utils.c +++ b/engine/lib/utils.c @@ -508,7 +508,7 @@ PH7_PRIVATE sxi32 SyStrToReal(const char *zSrc, sxu32 nLen, void *pOutVal, const } return zSrc >= zEnd ? SXRET_OK : SXERR_SYNTAX; } -PH7_PRIVATE sxi32 SyRealPath(const char *zPath, char **fPath) { +PH7_PRIVATE sxi32 SyRealPath(const char *zPath, char *fPath) { #ifdef __WINNT__ if(GetFullPathName(zPath, PATH_MAX, fPath, NULL) != 0) { #else diff --git a/engine/parser.c b/engine/parser.c index 2337b36..7f4504c 100644 --- a/engine/parser.c +++ b/engine/parser.c @@ -235,7 +235,7 @@ static sxi32 ExprVerifyNodes(ph7_gen_state *pGen, ph7_expr_node **apNode, sxi32 */ apNode[i]->pStart->nType &= ~PH7_TK_OCB /*'{'*/; apNode[i]->pStart->nType |= PH7_TK_OSB /*'['*/; - pOp = aOpTable; + pOp = aOpTable; pEnd = &pOp[sizeof(aOpTable)]; while(pOp < pEnd) { if(pOp->iOp == EXPR_OP_SUBSCRIPT) { diff --git a/engine/vm.c b/engine/vm.c index 52cd15e..83ea73b 100644 --- a/engine/vm.c +++ b/engine/vm.c @@ -2142,7 +2142,7 @@ static sxi32 VmByteCodeExec( * Creates and enters the jump loop frame on the beginning of each iteration. */ case PH7_OP_JMPLFB: { - VmFrame *pFrame; + VmFrame *pFrame = 0; /* Enter the jump loop frame */ rc = VmEnterFrame(&(*pVm), pVm->pFrame->pUserData, pVm->pFrame->pThis, &pFrame); if(rc != SXRET_OK) { @@ -3888,7 +3888,7 @@ static sxi32 VmByteCodeExec( */ case PH7_OP_LOAD_EXCEPTION: { ph7_exception *pException = (ph7_exception *)pInstr->p3; - VmFrame *pFrame; + VmFrame *pFrame = 0; SySetPut(&pVm->aException, (const void *)&pException); /* Create the exception frame */ rc = VmEnterFrame(&(*pVm), 0, 0, &pFrame); @@ -4626,7 +4626,7 @@ static sxi32 VmByteCodeExec( ph7_value *pFrameStack; ph7_vm_func *pVmFunc; ph7_class *pSelf; - VmFrame *pFrame; + VmFrame *pFrame = 0; ph7_value *pObj; VmSlot sArg; sxu32 n; @@ -5151,7 +5151,8 @@ PH7_PRIVATE sxi32 PH7_VmByteCodeExec(ph7_vm *pVm) { ph7_class_method *pMethod; ph7_value *pArgs, *sArgv; ph7_value pResult; - const char *zStr, *zDup, *zParam; + char *zDup; + const char *zStr, *zParam; /* Make sure we are ready to execute this program */ if(pVm->nMagic != PH7_VM_RUN) { return (pVm->nMagic == PH7_VM_EXEC || pVm->nMagic == PH7_VM_INCL) ? SXERR_LOCKED /* Locked VM */ : SXERR_CORRUPT; /* Stale VM */ @@ -9212,8 +9213,8 @@ static int vm_builtin_import(ph7_context *pCtx, int nArg, ph7_value **apArg) { /* Zero the module entry */ SyZero(&pModule, sizeof(VmModule)); SyStringInitFromBuf(&pModule.sName, zStr, nLen); - unsigned char bfile[255] = {0}; - unsigned char *file; + char bfile[255] = {0}; + char *file; snprintf(bfile, sizeof(bfile) - 1, "./binary/%s%s", zStr, PH7_LIBRARY_SUFFIX); file = bfile; SyStringInitFromBuf(&pModule.sFile, file, nLen); diff --git a/include/ph7.h b/include/ph7.h index c27bbc0..6694c69 100644 --- a/include/ph7.h +++ b/include/ph7.h @@ -562,6 +562,7 @@ struct ph7_io_stream { PH7_APIEXPORT int ph7_init(ph7 **ppEngine); PH7_APIEXPORT int ph7_config(ph7 *pEngine, int nConfigOp, ...); PH7_APIEXPORT int ph7_release(ph7 *pEngine); +PH7_APIEXPORT int ph7_vm_init(ph7 *pEngine, ph7_vm **ppOutVm, int bDebug); /* Compile Interfaces */ PH7_APIEXPORT int ph7_compile_code(ph7 *pEngine, const char *zSource, int nLen, ph7_vm **ppOutVm); PH7_APIEXPORT int ph7_compile_file(ph7 *pEngine, const char *zFilePath, ph7_vm **ppOutVm); diff --git a/include/ph7int.h b/include/ph7int.h index 36161dc..978e917 100644 --- a/include/ph7int.h +++ b/include/ph7int.h @@ -1828,7 +1828,7 @@ PH7_PRIVATE sxi32 SyLexInit(SyLex *pLex, SySet *pSet, ProcTokenizer xTokenizer, PH7_PRIVATE sxi32 SyBase64Decode(const char *zB64, sxu32 nLen, ProcConsumer xConsumer, void *pUserData); PH7_PRIVATE sxi32 SyBase64Encode(const char *zSrc, sxu32 nLen, ProcConsumer xConsumer, void *pUserData); PH7_PRIVATE sxi32 SyStrToReal(const char *zSrc, sxu32 nLen, void *pOutVal, const char **zRest); -PH7_PRIVATE sxi32 SyRealPath(const char *zPath, char **fPath); +PH7_PRIVATE sxi32 SyRealPath(const char *zPath, char *fPath); PH7_PRIVATE sxi32 SyBinaryStrToInt64(const char *zSrc, sxu32 nLen, void *pOutVal, const char **zRest); PH7_PRIVATE sxi32 SyOctalStrToInt64(const char *zSrc, sxu32 nLen, void *pOutVal, const char **zRest); PH7_PRIVATE sxi32 SyHexStrToInt64(const char *zSrc, sxu32 nLen, void *pOutVal, const char **zRest); diff --git a/sapi/cli/main.c b/sapi/cli/main.c index 7804a80..4e4f569 100644 --- a/sapi/cli/main.c +++ b/sapi/cli/main.c @@ -10,6 +10,7 @@ #include /* Make sure this header file is available.*/ #include "ph7.h" +#include "ph7int.h" /* * Display an error message and exit. */ @@ -210,4 +211,4 @@ int main(int argc, char **argv) { ph7_vm_release(pVm); ph7_release(pEngine); return status; -} \ No newline at end of file +}