Explorar el Código

Merge pull request #21 from mfxmfx/silence-warnings

Silence compiler warnings
albertodemichelis hace 9 años
padre
commit
a9362e22df

+ 2 - 2
include/sqconfig.h

@@ -60,10 +60,10 @@ typedef wchar_t SQChar;
 
 
 #define scstrcmp    wcscmp
-#ifdef _MSC_VER
+#ifdef _WIN32
 #define scsprintf   _snwprintf
 #else
-#define scsprintf   snwprintf
+#define scsprintf   swprintf
 #endif
 #define scstrlen    wcslen
 #define scstrtod    wcstod

+ 6 - 5
sq/sq.c

@@ -46,20 +46,22 @@ SQInteger quit(HSQUIRRELVM v)
     return 0;
 }
 
-void printfunc(HSQUIRRELVM v,const SQChar *s,...)
+void printfunc(HSQUIRRELVM v, const SQChar *s,...)
 {
     va_list vl;
     va_start(vl, s);
     scvprintf(stdout, s, vl);
     va_end(vl);
+    (void)v; /* UNUSED */
 }
 
-void errorfunc(HSQUIRRELVM v,const SQChar *s,...)
+void errorfunc(HSQUIRRELVM v, const SQChar *s,...)
 {
     va_list vl;
     va_start(vl, s);
     scvprintf(stderr, s, vl);
     va_end(vl);
+    (void)v; /* UNUSED */
 }
 
 void PrintVersionInfos()
@@ -87,10 +89,10 @@ int getargs(HSQUIRRELVM v,int argc, char* argv[],SQInteger *retval)
 {
     int i;
     int compiles_only = 0;
+#ifdef SQUNICODE
     static SQChar temp[500];
-    const SQChar *ret=NULL;
+#endif
     char * output = NULL;
-    int lineinfo=0;
     *retval = 0;
     if(argc>1)
     {
@@ -307,7 +309,6 @@ int main(int argc, char* argv[])
 {
     HSQUIRRELVM v;
     SQInteger retval = 0;
-    const SQChar *filename=NULL;
 #if defined(_MSC_VER) && defined(_DEBUG)
     _CrtSetAllocHook(MemAllocHook);
 #endif

+ 3 - 3
sqstdlib/sqstdblob.cpp

@@ -114,7 +114,7 @@ static SQInteger _blob__typeof(HSQUIRRELVM v)
     return 1;
 }
 
-static SQInteger _blob_releasehook(SQUserPointer p, SQInteger size)
+static SQInteger _blob_releasehook(SQUserPointer p, SQInteger /*size*/)
 {
     SQBlob *self = (SQBlob*)p;
     self->~SQBlob();
@@ -172,7 +172,7 @@ static const SQRegFunction _blob_methods[] = {
     _DECL_BLOB_FUNC(_typeof,1,_SC("x")),
     _DECL_BLOB_FUNC(_nexti,2,_SC("x")),
     _DECL_BLOB_FUNC(_cloned,2,_SC("xx")),
-    {0,0,0,0}
+    {NULL,(SQFUNCTION)0,0,NULL}
 };
 
 
@@ -230,7 +230,7 @@ static const SQRegFunction bloblib_funcs[]={
     _DECL_GLOBALBLOB_FUNC(swap2,2,_SC(".n")),
     _DECL_GLOBALBLOB_FUNC(swap4,2,_SC(".n")),
     _DECL_GLOBALBLOB_FUNC(swapfloat,2,_SC(".n")),
-    {0,0}
+    {NULL,(SQFUNCTION)0,0,NULL}
 };
 
 SQRESULT sqstd_getblob(HSQUIRRELVM v,SQInteger idx,SQUserPointer *ptr)

+ 3 - 3
sqstdlib/sqstdio.cpp

@@ -115,7 +115,7 @@ static SQInteger _file__typeof(HSQUIRRELVM v)
     return 1;
 }
 
-static SQInteger _file_releasehook(SQUserPointer p, SQInteger size)
+static SQInteger _file_releasehook(SQUserPointer p, SQInteger /*size*/)
 {
     SQFile *self = (SQFile*)p;
     self->~SQFile();
@@ -168,7 +168,7 @@ static const SQRegFunction _file_methods[] = {
     _DECL_FILE_FUNC(constructor,3,_SC("x")),
     _DECL_FILE_FUNC(_typeof,1,_SC("x")),
     _DECL_FILE_FUNC(close,1,_SC("x")),
-    {0,0,0,0},
+    {NULL,(SQFUNCTION)0,0,NULL}
 };
 
 
@@ -463,7 +463,7 @@ static const SQRegFunction iolib_funcs[]={
     _DECL_GLOBALIO_FUNC(loadfile,-2,_SC(".sb")),
     _DECL_GLOBALIO_FUNC(dofile,-2,_SC(".sb")),
     _DECL_GLOBALIO_FUNC(writeclosuretofile,3,_SC(".sc")),
-    {0,0}
+    {NULL,(SQFUNCTION)0,0,NULL}
 };
 
 SQRESULT sqstd_register_iolib(HSQUIRRELVM v)

+ 1 - 1
sqstdlib/sqstdmath.cpp

@@ -78,7 +78,7 @@ static const SQRegFunction mathlib_funcs[] = {
     _DECL_FUNC(rand,1,NULL),
     _DECL_FUNC(fabs,2,_SC(".n")),
     _DECL_FUNC(abs,2,_SC(".n")),
-    {0,0},
+    {NULL,(SQFUNCTION)0,0,NULL}
 };
 #undef _DECL_FUNC
 

+ 1 - 1
sqstdlib/sqstdrex.cpp

@@ -550,7 +550,7 @@ static const SQChar *sqstd_rex_matchnode(SQRex* exp,SQRexNode *node,const SQChar
 /* public api */
 SQRex *sqstd_rex_compile(const SQChar *pattern,const SQChar **error)
 {
-    SQRex *exp = (SQRex *)sq_malloc(sizeof(SQRex));
+    SQRex * volatile exp = (SQRex *)sq_malloc(sizeof(SQRex)); // "volatile" is needed for setjmp()
     exp->_eol = exp->_bol = NULL;
     exp->_p = pattern;
     exp->_nallocated = (SQInteger)scstrlen(pattern) * sizeof(SQChar);

+ 1 - 1
sqstdlib/sqstdstream.cpp

@@ -249,7 +249,7 @@ static const SQRegFunction _stream_methods[] = {
     _DECL_STREAM_FUNC(eos,1,_SC("x")),
     _DECL_STREAM_FUNC(flush,1,_SC("x")),
     _DECL_STREAM_FUNC(_cloned,0,NULL),
-    {0,0}
+    {NULL,(SQFUNCTION)0,0,NULL}
 };
 
 void init_streamclass(HSQUIRRELVM v)

+ 6 - 6
sqstdlib/sqstdstring.cpp

@@ -94,9 +94,9 @@ SQRESULT sqstd_format(HSQUIRRELVM v,SQInteger nformatstringidx,SQInteger *outlen
             if(n < 0) return -1;
             SQInteger addlen = 0;
             SQInteger valtype = 0;
-            const SQChar *ts;
-            SQInteger ti;
-            SQFloat tf;
+            const SQChar *ts = NULL;
+            SQInteger ti = 0;
+            SQFloat tf = 0;
             switch(format[n]) {
             case 's':
                 if(SQ_FAILED(sq_getstring(v,nparam,&ts)))
@@ -350,7 +350,7 @@ static SQInteger _string_endswith(HSQUIRRELVM v)
     SQRex *self = NULL; \
     sq_getinstanceup(v,1,(SQUserPointer *)&self,0);
 
-static SQInteger _rexobj_releasehook(SQUserPointer p, SQInteger size)
+static SQInteger _rexobj_releasehook(SQUserPointer p, SQInteger /*size*/)
 {
     SQRex *self = ((SQRex *)p);
     sqstd_rex_free(self);
@@ -452,7 +452,7 @@ static const SQRegFunction rexobj_funcs[]={
     _DECL_REX_FUNC(capture,-2,_SC("xsn")),
     _DECL_REX_FUNC(subexpcount,1,_SC("x")),
     _DECL_REX_FUNC(_typeof,1,_SC("x")),
-    {0,0}
+    {NULL,(SQFUNCTION)0,0,NULL}
 };
 #undef _DECL_REX_FUNC
 
@@ -466,7 +466,7 @@ static const SQRegFunction stringlib_funcs[]={
     _DECL_FUNC(escape,2,_SC(".s")),
     _DECL_FUNC(startswith,3,_SC(".ss")),
     _DECL_FUNC(endswith,3,_SC(".ss")),
-    {0,0}
+    {NULL,(SQFUNCTION)0,0,NULL}
 };
 #undef _DECL_FUNC
 

+ 1 - 1
sqstdlib/sqstdsystem.cpp

@@ -126,7 +126,7 @@ static const SQRegFunction systemlib_funcs[]={
     _DECL_FUNC(date,-1,_SC(".nn")),
     _DECL_FUNC(remove,2,_SC(".s")),
     _DECL_FUNC(rename,3,_SC(".ss")),
-    {0,0}
+    {NULL,(SQFUNCTION)0,0,NULL}
 };
 #undef _DECL_FUNC
 

+ 1 - 1
squirrel/sqapi.cpp

@@ -180,7 +180,7 @@ SQBool sq_release(HSQUIRRELVM v,HSQOBJECT *po)
 #endif
 }
 
-SQUnsignedInteger sq_getvmrefcount(HSQUIRRELVM v, const HSQOBJECT *po)
+SQUnsignedInteger sq_getvmrefcount(HSQUIRRELVM /*v*/, const HSQOBJECT *po)
 {
     if (!ISREFCOUNTED(type(*po))) return 0;
     return po->_unVal.pRefCounted->_uiRef;

+ 13 - 13
squirrel/sqbaselib.cpp

@@ -40,7 +40,7 @@ static bool str2num(const SQChar *s,SQObjectPtr &res,SQInteger base)
     return true;
 }
 
-static SQInteger base_dummy(HSQUIRRELVM v)
+static SQInteger base_dummy(HSQUIRRELVM /*v*/)
 {
     return 0;
 }
@@ -296,7 +296,7 @@ static const SQRegFunction base_funcs[]={
     {_SC("collectgarbage"),base_collectgarbage,0, NULL},
     {_SC("resurrectunreachable"),base_resurectureachable,0, NULL},
 #endif
-    {0,0}
+    {NULL,(SQFUNCTION)0,0,NULL}
 };
 
 void sq_base_register(HSQUIRRELVM v)
@@ -475,7 +475,7 @@ const SQRegFunction SQSharedState::_table_default_delegate_funcz[]={
     {_SC("clear"),obj_clear,1, _SC(".")},
     {_SC("setdelegate"),table_setdelegate,2, _SC(".t|o")},
     {_SC("getdelegate"),table_getdelegate,1, _SC(".")},
-    {0,0}
+    {NULL,(SQFUNCTION)0,0,NULL}
 };
 
 //ARRAY DEFAULT DELEGATE///////////////////////////////////////
@@ -721,7 +721,7 @@ static bool _hsort_sift_down(HSQUIRRELVM v,SQArray *arr, SQInteger root, SQInteg
     return true;
 }
 
-static bool _hsort(HSQUIRRELVM v,SQObjectPtr &arr, SQInteger l, SQInteger r,SQInteger func)
+static bool _hsort(HSQUIRRELVM v,SQObjectPtr &arr, SQInteger /*l*/, SQInteger /*r*/, SQInteger func)
 {
     SQArray *a = _array(arr);
     SQInteger i;
@@ -794,7 +794,7 @@ const SQRegFunction SQSharedState::_array_default_delegate_funcz[]={
     {_SC("reduce"),array_reduce,2, _SC("ac")},
     {_SC("filter"),array_filter,2, _SC("ac")},
     {_SC("find"),array_find,2, _SC("a.")},
-    {0,0}
+    {NULL,(SQFUNCTION)0,0,NULL}
 };
 
 //STRING DEFAULT DELEGATE//////////////////////////
@@ -863,7 +863,7 @@ const SQRegFunction SQSharedState::_string_default_delegate_funcz[]={
     {_SC("tolower"),string_tolower,-1, _SC("s n n")},
     {_SC("toupper"),string_toupper,-1, _SC("s n n")},
     {_SC("weakref"),obj_delegate_weakref,1, NULL },
-    {0,0}
+    {NULL,(SQFUNCTION)0,0,NULL}
 };
 
 //INTEGER DEFAULT DELEGATE//////////////////////////
@@ -873,7 +873,7 @@ const SQRegFunction SQSharedState::_number_default_delegate_funcz[]={
     {_SC("tostring"),default_delegate_tostring,1, _SC(".")},
     {_SC("tochar"),number_delegate_tochar,1, _SC("n|b")},
     {_SC("weakref"),obj_delegate_weakref,1, NULL },
-    {0,0}
+    {NULL,(SQFUNCTION)0,0,NULL}
 };
 
 //CLOSURE DEFAULT DELEGATE//////////////////////////
@@ -983,7 +983,7 @@ const SQRegFunction SQSharedState::_closure_default_delegate_funcz[]={
     {_SC("getinfos"),closure_getinfos,1, _SC("c")},
     {_SC("getroot"),closure_getroot,1, _SC("c")},
     {_SC("setroot"),closure_setroot,2, _SC("ct")},
-    {0,0}
+    {NULL,(SQFUNCTION)0,0,NULL}
 };
 
 //GENERATOR DEFAULT DELEGATE
@@ -1002,7 +1002,7 @@ const SQRegFunction SQSharedState::_generator_default_delegate_funcz[]={
     {_SC("getstatus"),generator_getstatus,1, _SC("g")},
     {_SC("weakref"),obj_delegate_weakref,1, NULL },
     {_SC("tostring"),default_delegate_tostring,1, _SC(".")},
-    {0,0}
+    {NULL,(SQFUNCTION)0,0,NULL}
 };
 
 //THREAD DEFAULT DELEGATE
@@ -1162,7 +1162,7 @@ const SQRegFunction SQSharedState::_thread_default_delegate_funcz[] = {
     {_SC("weakref"),obj_delegate_weakref,1, NULL },
     {_SC("getstackinfos"),thread_getstackinfos,2, _SC("vn")},
     {_SC("tostring"),default_delegate_tostring,1, _SC(".")},
-    {0,0},
+    {NULL,(SQFUNCTION)0,0,NULL}
 };
 
 static SQInteger class_getattributes(HSQUIRRELVM v)
@@ -1229,7 +1229,7 @@ const SQRegFunction SQSharedState::_class_default_delegate_funcz[] = {
     {_SC("getbase"),class_getbase,1, _SC("y")},
     {_SC("newmember"),class_newmember,-3, _SC("y")},
     {_SC("rawnewmember"),class_rawnewmember,-3, _SC("y")},
-    {0,0}
+    {NULL,(SQFUNCTION)0,0,NULL}
 };
 
 
@@ -1247,7 +1247,7 @@ const SQRegFunction SQSharedState::_instance_default_delegate_funcz[] = {
     {_SC("rawin"),container_rawexists,2, _SC("x")},
     {_SC("weakref"),obj_delegate_weakref,1, NULL },
     {_SC("tostring"),default_delegate_tostring,1, _SC(".")},
-    {0,0}
+    {NULL,(SQFUNCTION)0,0,NULL}
 };
 
 static SQInteger weakref_ref(HSQUIRRELVM v)
@@ -1261,6 +1261,6 @@ const SQRegFunction SQSharedState::_weakref_default_delegate_funcz[] = {
     {_SC("ref"),weakref_ref,1, _SC("r")},
     {_SC("weakref"),obj_delegate_weakref,1, NULL },
     {_SC("tostring"),default_delegate_tostring,1, _SC(".")},
-    {0,0}
+    {NULL,(SQFUNCTION)0,0,NULL}
 };
 

+ 1 - 1
squirrel/sqclass.cpp

@@ -189,7 +189,7 @@ SQInstance::~SQInstance()
     if(_class){ Finalize(); } //if _class is null it was already finalized by the GC
 }
 
-bool SQInstance::GetMetaMethod(SQVM *v,SQMetaMethod mm,SQObjectPtr &res)
+bool SQInstance::GetMetaMethod(SQVM * /*v*/, SQMetaMethod mm, SQObjectPtr &res)
 {
     if(type(_class->_metamethods[mm]) != OT_NULL) {
         res = _class->_metamethods[mm];

+ 1 - 0
squirrel/sqcompiler.cpp

@@ -983,6 +983,7 @@ public:
             SQInteger key = _fs->PopTarget();
             SQInteger attrs = hasattrs ? _fs->PopTarget():-1;
             assert((hasattrs && (attrs == key-1)) || !hasattrs);
+            (void)attrs; // UNUSED
             unsigned char flags = (hasattrs?NEW_SLOT_ATTRIBUTES_FLAG:0)|(isstatic?NEW_SLOT_STATIC_FLAG:0);
             SQInteger table = _fs->TopTarget(); //<<BECAUSE OF THIS NO COMMON EMIT FUNC IS POSSIBLE
             if(separator == _SC(',')) { //hack recognizes a table from the separator

+ 1 - 1
squirrel/sqlexer.cpp

@@ -379,7 +379,7 @@ SQInteger SQLexer::ReadString(SQInteger ndelim,bool verbatim)
                         APPEND_CHAR((SQChar)scstrtoul(temp, &stemp, 16));
                     }
                     break;
-                    case _SC('U'):  
+                    case _SC('U'):
                     case _SC('u'):  {
                         const SQInteger maxdigits = x == 'u' ? 4 : 8;
                         SQChar temp[8 + 1];

+ 1 - 1
squirrel/sqlexer.h

@@ -30,7 +30,7 @@ private:
 #endif
 #else
     SQInteger AddUTF8(SQUnsignedInteger ch);
-#endif    
+#endif
     SQInteger ProcessStringHexEscape(SQChar *dest, SQInteger maxdigits);
     SQInteger _curtoken;
     SQTable *_keywords;

+ 2 - 2
squirrel/sqmem.cpp

@@ -5,7 +5,7 @@
 #ifndef SQ_EXCLUDE_DEFAULT_MEMFUNCTIONS
 void *sq_vm_malloc(SQUnsignedInteger size){ return malloc(size); }
 
-void *sq_vm_realloc(void *p, SQUnsignedInteger oldsize, SQUnsignedInteger size){ return realloc(p, size); }
+void *sq_vm_realloc(void *p, SQUnsignedInteger /*oldsize*/, SQUnsignedInteger size){ return realloc(p, size); }
 
-void sq_vm_free(void *p, SQUnsignedInteger size){   free(p); }
+void sq_vm_free(void *p, SQUnsignedInteger /*size*/) { free(p); }
 #endif

+ 1 - 1
squirrel/sqopcodes.h

@@ -110,7 +110,7 @@ struct SQInstruction
 {
     SQInstruction(){};
     SQInstruction(SQOpcode _op,SQInteger a0=0,SQInteger a1=0,SQInteger a2=0,SQInteger a3=0)
-    {   op = _op;
+    {   op = (unsigned char)_op;
         _arg0 = (unsigned char)a0;_arg1 = (SQInt32)a1;
         _arg2 = (unsigned char)a2;_arg3 = (unsigned char)a3;
     }

+ 1 - 1
squirrel/sqstate.cpp

@@ -251,7 +251,7 @@ void SQSharedState::MarkObject(SQObjectPtr &o,SQCollectable **chain)
 }
 
 
-void SQSharedState::RunMark(SQVM *vm,SQCollectable **tchain)
+void SQSharedState::RunMark(SQVM * /*vm*/, SQCollectable **tchain)
 {
     SQVM *vms = _thread(_root_vm);
 

+ 2 - 2
squirrel/sqvm.cpp

@@ -514,7 +514,7 @@ SQRESULT SQVM::Suspend()
 
 #define _FINISH(howmuchtojump) {jump = howmuchtojump; return true; }
 bool SQVM::FOREACH_OP(SQObjectPtr &o1,SQObjectPtr &o2,SQObjectPtr
-&o3,SQObjectPtr &o4,SQInteger arg_2,int exitpos,int &jump)
+&o3,SQObjectPtr &o4,SQInteger /*arg_2*/,int exitpos,int &jump)
 {
     SQInteger nrefidx;
     switch(type(o1)) {
@@ -1573,7 +1573,7 @@ SQInteger prevstackbase = _stackbase;
     return true;
 }
 
-bool SQVM::CallMetaMethod(SQObjectPtr &closure,SQMetaMethod mm,SQInteger nparams,SQObjectPtr &outres)
+bool SQVM::CallMetaMethod(SQObjectPtr &closure,SQMetaMethod /*mm*/,SQInteger nparams,SQObjectPtr &outres)
 {
     //SQObjectPtr closure;