Skip to content

Commit

Permalink
src: rename SKIP_CHECK_SIZE to SKIP_CHECK_STRLEN
Browse files Browse the repository at this point in the history
SKIP_CHECK_VALUE is a string literal, so its size is the length of the
string in chars plus one. The buffer buf is also always null-terminated,
so its size should match the size of SKIP_CHECK_VALUE, which is _not_
SKIP_CHECK_SIZE.

Rename SKIP_CHECK_SIZE to be consistent with C/C++ terminology.

PR-URL: #47845
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Darshan Sen <[email protected]>
Reviewed-By: Shelley Vohr <[email protected]>
  • Loading branch information
tniessen authored and MoLow committed Jul 6, 2023
1 parent 9b44c56 commit 4bad757
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/node_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@
#include <WinError.h>

#define SKIP_CHECK_VAR "NODE_SKIP_PLATFORM_CHECK"
#define SKIP_CHECK_SIZE 1
#define SKIP_CHECK_VALUE "1"
#define SKIP_CHECK_STRLEN (sizeof(SKIP_CHECK_VALUE) - 1)

int wmain(int argc, wchar_t* wargv[]) {
// Windows Server 2012 (not R2) is supported until 10/10/2023, so we allow it
// to run in the experimental support tier.
char buf[SKIP_CHECK_SIZE + 1];
char buf[SKIP_CHECK_STRLEN + 1];
if (!IsWindows8Point1OrGreater() &&
!(IsWindowsServer() && IsWindows8OrGreater()) &&
(GetEnvironmentVariableA(SKIP_CHECK_VAR, buf, sizeof(buf)) !=
SKIP_CHECK_SIZE ||
strncmp(buf, SKIP_CHECK_VALUE, SKIP_CHECK_SIZE + 1) != 0)) {
SKIP_CHECK_STRLEN ||
strncmp(buf, SKIP_CHECK_VALUE, SKIP_CHECK_STRLEN) != 0)) {
fprintf(stderr, "Node.js is only supported on Windows 8.1, Windows "
"Server 2012 R2, or higher.\n"
"Setting the " SKIP_CHECK_VAR " environment variable "
Expand Down

0 comments on commit 4bad757

Please sign in to comment.