build: use native file open flags in Windows-specific code

To comply with official documentation. Also to make code compile with
`NO_OLDNAMES` (mingw-w64) or `_CRT_DECLARE_NONSTDC_NAMES=0` (MSVC) set.

Ref: #15652

Closes #20516
This commit is contained in:
Viktor Szakats 2026-02-04 14:32:11 +01:00
parent 94349aa932
commit 462244447e
No known key found for this signature in database
6 changed files with 10 additions and 8 deletions

View file

@ -11,7 +11,7 @@ extend-ignore-identifiers-re = [
"^0x[0-9a-fA-F]+FUL$", # unsigned long hex literals ending with 'F'
"^(eyeballers|HELO_smtp|Januar|optin|passin|perfec|SMTP_HELO)$",
"^(clen|req_clen|smtp_perform_helo|smtp_state_helo_resp|Tru64|_stati64)$",
"(ccontains|controllen|secur32)",
"(_ccontains|_controllen|O_WRONLY|secur32)",
"proxys", # this should be limited to tests/http/*. Short for secure proxy.
]

View file

@ -125,8 +125,8 @@ CURLcode Curl_fopen(struct Curl_easy *data, const char *filename,
result = CURLE_WRITE_ERROR;
#ifdef _WIN32
fd = curlx_open(tempstore, O_WRONLY | O_CREAT | O_EXCL,
S_IREAD | S_IWRITE);
fd = curlx_open(tempstore, _O_WRONLY | _O_CREAT | _O_EXCL,
_S_IREAD | _S_IWRITE);
#elif (defined(ANDROID) || defined(__ANDROID__)) && \
(defined(__i386__) || defined(__arm__))
fd = curlx_open(tempstore, O_WRONLY | O_CREAT | O_EXCL,

View file

@ -864,7 +864,9 @@
/* Since O_BINARY is used in bitmasks, setting it to zero makes it usable in
source code but yet it does not ruin anything */
#ifdef O_BINARY
#ifdef _O_BINARY /* for _WIN32 */
#define CURL_O_BINARY _O_BINARY
#elif defined(O_BINARY)
#define CURL_O_BINARY O_BINARY
#else
#define CURL_O_BINARY 0

View file

@ -29,7 +29,7 @@
#include "tool_operate.h"
#ifdef _WIN32
#define OPENMODE S_IREAD | S_IWRITE
#define OPENMODE _S_IREAD | _S_IWRITE
#else
#define OPENMODE S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH
#endif

View file

@ -420,7 +420,7 @@ static ssize_t write_behind(struct testcase *test, int convert)
snprintf(outfile, sizeof(outfile), "%s/upload.%ld", logdir, test->testno);
test->ofile = curlx_open(outfile, O_CREAT | O_RDWR | CURL_O_BINARY,
#ifdef _WIN32
S_IREAD | S_IWRITE
_S_IREAD | _S_IWRITE
#else
S_IRUSR | S_IWUSR | S_IXUSR |
S_IRGRP | S_IWGRP | S_IXGRP |

View file

@ -333,8 +333,8 @@ static void exit_signal_handler(int signum)
else {
int fd = -1;
#ifdef _WIN32
if(!_sopen_s(&fd, serverlogfile, O_WRONLY | O_CREAT | O_APPEND,
_SH_DENYNO, S_IREAD | S_IWRITE) &&
if(!_sopen_s(&fd, serverlogfile, _O_WRONLY | _O_CREAT | _O_APPEND,
_SH_DENYNO, _S_IREAD | _S_IWRITE) &&
fd != -1) {
#else
/* !checksrc! disable BANNEDFUNC 1 */