Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: fix more MSVC warnings #37334

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
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.
  • Loading branch information
targos committed Feb 12, 2021
commit 6e89d7364c03f6398f2a3f8cdc9b49a17776ddf1
8 changes: 8 additions & 0 deletions src/base64-inl.h
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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