From 422b407e790d5904afa96d53b9851f4355c3f35e Mon Sep 17 00:00:00 2001 From: ac-stef Date: Sat, 27 Aug 2016 12:03:23 +0200 Subject: [PATCH] misc VS warning fixes --- source/src/command.cpp | 2 +- source/src/crypto.cpp | 4 +++- source/src/crypto_tools.h | 4 ++-- source/src/platform.h | 4 +--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/source/src/command.cpp b/source/src/command.cpp index fec5807e..2f71bc93 100644 --- a/source/src/command.cpp +++ b/source/src/command.cpp @@ -768,7 +768,7 @@ int execute(const char *p) #ifndef STANDALONE bool exechook(int context, const char *ident, const char *body,...) // execute cubescript hook if available and allowed in current context/gamemode { // always use one of HOOK_SP_MP, HOOK_SP or HOOK_MP and then OR them (as needed) with HOOK_TEAM, HOOK_NOTEAM, HOOK_BOTMODE, HOOK_FLAGMODE, HOOK_ARENA - if(multiplayer(NULL) && (context & HOOK_FLAGMASK) != HOOK_MP && (context & HOOK_FLAGMASK) != HOOK_SP_MP) return false; // hook is singleplayer-only + if(multiplayer(false) && (context & HOOK_FLAGMASK) != HOOK_MP && (context & HOOK_FLAGMASK) != HOOK_SP_MP) return false; // hook is singleplayer-only if(((context & HOOK_TEAM) && !m_teammode) || ((context & HOOK_NOTEAM) && m_teammode) || ((context & HOOK_BOTMODE) && !m_botmode) || diff --git a/source/src/crypto.cpp b/source/src/crypto.cpp index b9d0f584..56fc3fed 100644 --- a/source/src/crypto.cpp +++ b/source/src/crypto.cpp @@ -608,7 +608,7 @@ void ed25519test(char *vectorfilename) // check ed25519 functions with test vec { // a line consists of 32 bytes private key, 32 byte public key, ":", 32 byte public key (again), ":", message, ":", signed message, ":" char *vprivpub = l, *vpub = strchr(l, ':'), *vmsg, *vsmsg, hextemp[65]; int linelen = strlen(l), msglen = 0; - uchar privpub[64], pub[32], msg[linelen], smsg[linelen], temp[64]; + uchar privpub[64], pub[32], *msg = new uchar[linelen], *smsg = new uchar[linelen], temp[64]; lines++; if(!vpub || !(vmsg = strchr(vpub + 1, ':')) || !(vsmsg = strchr(vmsg + 1, ':')) || hex2bin(privpub, vprivpub, 64) != 64 || hex2bin(pub, ++vpub, 32) != 32 || (msglen = hex2bin(msg, ++vmsg, linelen)) < 0 || hex2bin(smsg, ++vsmsg, linelen) != (msglen + 64) || @@ -629,6 +629,8 @@ void ed25519test(char *vectorfilename) // check ed25519 functions with test vec } pub[msglen % 32]++; if(ed25519_sign_check(smsg, msglen + 64, pub)) { verifyfail2++; continue; } // verification of altered signed message didn't fail (...but should've) + delete[] smsg; + delete[] msg; } DELETEA(vectorfile); conoutf("processed %d lines in %d milliseconds", lines, watch.elapsed()); diff --git a/source/src/crypto_tools.h b/source/src/crypto_tools.h index 721c74a9..bbdfe4ff 100644 --- a/source/src/crypto_tools.h +++ b/source/src/crypto_tools.h @@ -120,7 +120,7 @@ void fe25519_freeze(fe25519 *r) m &= equal(r->v[i],255); m &= ge(r->v[0],237); - m = -m; + m = (uint32_t) -int(m); r->v[31] -= m&127; for(i=30;i>0;i--) @@ -173,7 +173,7 @@ void fe25519_cmov(fe25519 *r, const fe25519 *x, unsigned char b) { int i; uint32_t mask = b; - mask = -mask; + mask = (uint32_t) -int(mask); for(i=0;i<32;i++) r->v[i] ^= mask & (x->v[i] ^ r->v[i]); } diff --git a/source/src/platform.h b/source/src/platform.h index 15d307e8..c5ce35b8 100644 --- a/source/src/platform.h +++ b/source/src/platform.h @@ -12,9 +12,7 @@ #include #include #include -#ifdef __MINGW32__ - #include -#endif +#include #ifdef __GNUC__ #include #include