Skip to content

Commit

Permalink
src: disable unfixable MSVC warnings
Browse files Browse the repository at this point in the history
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: #37334
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
targos committed Jun 11, 2021
1 parent 38afa3f commit 6b1052d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/base64-inl.h
Expand Up @@ -23,6 +23,11 @@ inline uint32_t ReadUint32BE(const unsigned char* p) {
static_cast<uint32_t>(p[3]);
}

#ifdef _MSC_VER
#pragma warning(push)
// MSVC C4003: not enough actual parameters for macro 'identifier'
#pragma warning(disable : 4003)
#endif

template <typename TypeName>
bool base64_decode_group_slow(char* const dst, const size_t dstlen,
Expand Down Expand Up @@ -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 <typename TypeName>
size_t base64_decode_fast(char* const dst, const size_t dstlen,
Expand Down
10 changes: 10 additions & 0 deletions src/node_revert.h
Expand Up @@ -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) {
Expand All @@ -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));
Expand Down

0 comments on commit 6b1052d

Please sign in to comment.