From 6b1052d034b02a776970725de2685b4b234d0eca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Fri, 12 Feb 2021 20:58:42 +0100 Subject: [PATCH] src: disable unfixable MSVC warnings The following warnings are disabled: - C4065 in node_revert.h: there are no security reversions on the master branch. - C4003 in base64-inl.h: a macro is used four times, only once without parameters. PR-URL: https://github.com/nodejs/node/pull/37334 Reviewed-By: James M Snell --- src/base64-inl.h | 8 ++++++++ src/node_revert.h | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/base64-inl.h b/src/base64-inl.h index 92804542226dfe..9efb9d076ea8e5 100644 --- a/src/base64-inl.h +++ b/src/base64-inl.h @@ -23,6 +23,11 @@ inline uint32_t ReadUint32BE(const unsigned char* p) { static_cast(p[3]); } +#ifdef _MSC_VER +#pragma warning(push) +// MSVC C4003: not enough actual parameters for macro 'identifier' +#pragma warning(disable : 4003) +#endif template bool base64_decode_group_slow(char* const dst, const size_t dstlen, @@ -50,6 +55,9 @@ bool base64_decode_group_slow(char* const dst, const size_t dstlen, return true; // Continue decoding. } +#ifdef _MSC_VER +#pragma warning(pop) +#endif template size_t base64_decode_fast(char* const dst, const size_t dstlen, diff --git a/src/node_revert.h b/src/node_revert.h index 0f0c32412ef0b5..edf6ad772eecb0 100644 --- a/src/node_revert.h +++ b/src/node_revert.h @@ -28,6 +28,12 @@ namespace per_process { extern unsigned int reverted_cve; } +#ifdef _MSC_VER +#pragma warning(push) +// MSVC C4065: switch statement contains 'default' but no 'case' labels +#pragma warning(disable : 4065) +#endif + inline const char* RevertMessage(const reversion cve) { #define V(code, label, msg) case SECURITY_REVERT_##code: return label ": " msg; switch (cve) { @@ -38,6 +44,10 @@ inline const char* RevertMessage(const reversion cve) { #undef V } +#ifdef _MSC_VER +#pragma warning(pop) +#endif + inline void Revert(const reversion cve) { per_process::reverted_cve |= 1 << cve; printf("SECURITY WARNING: Reverting %s\n", RevertMessage(cve));