From 6eff1cb8be81ebc5b33603a3437b53f4679fc92d Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Sat, 26 Nov 2016 12:45:17 +0100 Subject: [PATCH] - Fixed more GCC/Clang warnings. --- src/memarena.cpp | 4 ++-- src/memarena.h | 6 +++--- src/p_actionfunctions.cpp | 2 +- src/p_pspr.cpp | 2 +- src/scripting/codegeneration/codegen.cpp | 2 +- src/scripting/zscript/zcc_compile.cpp | 14 +++++++++++++- 6 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/memarena.cpp b/src/memarena.cpp index e6e9edd6e..8ea8b5806 100644 --- a/src/memarena.cpp +++ b/src/memarena.cpp @@ -72,11 +72,11 @@ static inline void *RoundPointer(void *ptr) // //========================================================================== -FMemArena::FMemArena(int bs) +FMemArena::FMemArena(size_t blocksize) { TopBlock = NULL; FreeBlocks = NULL; - BlockSize = bs; + BlockSize = blocksize; } //========================================================================== diff --git a/src/memarena.h b/src/memarena.h index cc0c8f148..3601469bf 100644 --- a/src/memarena.h +++ b/src/memarena.h @@ -40,7 +40,7 @@ class FMemArena { public: - FMemArena(int blocksize = 10*1024); + FMemArena(size_t blocksize = 10*1024); ~FMemArena(); void *Alloc(size_t size); @@ -55,7 +55,7 @@ protected: Block *TopBlock; Block *FreeBlocks; - int BlockSize; + size_t BlockSize; }; // An arena specializing in storage of FStrings. It knows how to free them, @@ -87,4 +87,4 @@ private: }; -#endif \ No newline at end of file +#endif diff --git a/src/p_actionfunctions.cpp b/src/p_actionfunctions.cpp index 95bcb3e25..d33695a1b 100644 --- a/src/p_actionfunctions.cpp +++ b/src/p_actionfunctions.cpp @@ -143,7 +143,7 @@ bool ACustomInventory::CallStateChain (AActor *actor, FState *state) // If an unsafe function (i.e. one that accesses user variables) is being detected, print a warning once and remove the bogus function. We may not call it because that would inevitably crash. auto owner = FState::StaticFindStateOwner(state); Printf(TEXTCOLOR_RED "Unsafe state call in state %s.%d to %s which accesses user variables. The action function has been removed from this state\n", - owner->TypeName.GetChars(), state - owner->OwnedStates, state->ActionFunc->PrintableName.GetChars()); + owner->TypeName.GetChars(), int(state - owner->OwnedStates), state->ActionFunc->PrintableName.GetChars()); state->ActionFunc = nullptr; } diff --git a/src/p_pspr.cpp b/src/p_pspr.cpp index eddeb3430..e2ea3084d 100644 --- a/src/p_pspr.cpp +++ b/src/p_pspr.cpp @@ -409,7 +409,7 @@ void DPSprite::SetState(FState *newstate, bool pending) // If an unsafe function (i.e. one that accesses user variables) is being detected, print a warning once and remove the bogus function. We may not call it because that would inevitably crash. auto owner = FState::StaticFindStateOwner(newstate); Printf(TEXTCOLOR_RED "Unsafe state call in state %s.%d to %s which accesses user variables. The action function has been removed from this state\n", - owner->TypeName.GetChars(), newstate - owner->OwnedStates, newstate->ActionFunc->PrintableName.GetChars()); + owner->TypeName.GetChars(), int(newstate - owner->OwnedStates), newstate->ActionFunc->PrintableName.GetChars()); newstate->ActionFunc = nullptr; } if (newstate->CallAction(Owner->mo, Caller, &stp, &nextstate)) diff --git a/src/scripting/codegeneration/codegen.cpp b/src/scripting/codegeneration/codegen.cpp index 0fb6b172f..1e06f5751 100644 --- a/src/scripting/codegeneration/codegen.cpp +++ b/src/scripting/codegeneration/codegen.cpp @@ -7771,7 +7771,7 @@ ExpEmit FxVMFunctionCall::Emit(VMFunctionBuilder *build) } VMFunction *vmfunc = Function->Variants[0].Implementation; - bool staticcall = (vmfunc->Final || vmfunc->VirtualIndex == -1 || NoVirtual); + bool staticcall = (vmfunc->Final || vmfunc->VirtualIndex == ~0u || NoVirtual); count = 0; // Emit code to pass implied parameters diff --git a/src/scripting/zscript/zcc_compile.cpp b/src/scripting/zscript/zcc_compile.cpp index 98ebc17d9..56f991287 100644 --- a/src/scripting/zscript/zcc_compile.cpp +++ b/src/scripting/zscript/zcc_compile.cpp @@ -1469,6 +1469,9 @@ PType *ZCCCompiler::DetermineType(PType *outertype, ZCC_TreeNode *field, FName n break; } break; + + default: + break; } break; } @@ -1520,6 +1523,9 @@ PType *ZCCCompiler::DetermineType(PType *outertype, ZCC_TreeNode *field, FName n } break; } + + default: + break; } if (retval != TypeError && retval->MemberOnly && !formember) { @@ -1997,6 +2003,9 @@ void ZCCCompiler::InitDefaults() case AST_FlagStmt: ProcessDefaultFlag(ti, static_cast(content)); break; + + default: + break; } content = static_cast(content->SiblingNext); } while (content != d->Content); @@ -3215,6 +3224,9 @@ FxExpression *ZCCCompiler::ConvertNode(ZCC_TreeNode *ast) } return new FxMultiAssign(args, ConvertNode(ass->Sources), *ast); } + + default: + break; } // only for development. I_Error is more convenient here than a normal error. I_Error("ConvertNode encountered unsupported node of type %d", ast->NodeType); @@ -3234,4 +3246,4 @@ FArgumentList &ZCCCompiler::ConvertNodeList(FArgumentList &args, ZCC_TreeNode *h } while (node != head); } return args; -} \ No newline at end of file +}