Welcome! Log In Create A New Profile

Advanced

[PATCH] Win32: Don't discards const qualifiers for WriteFile

Kentaro Hayashi
November 27, 2018 12:10AM
Hi,
It seems that there is a mismatch between ngx_write_fd and WriteFile
prototype.
I've attached a patch for it.

# HG changeset patch
# User hayashi@clear-code.com
# Date 1543294459 -32400
# Tue Nov 27 13:54:19 2018 +0900
# Branch use-const-void-pointer
# Node ID 04809b6012bd8a744e3beded6fc385cdb3f788ee
# Parent a7ff19afbb14795fef14f599a304d0ad21052b70
Win32: Don't discards const qualifiers for WriteFile

The 2nd argument of ngx_write_fd() is declared as
void pointer instead of const void pointer.
It means that void pointer is passed to WriteFile which accepts
LPCVOID pointer, instead of LPVOID. Thus const qualifier isn't respected.

ref.
https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-writefile

It causes a compile warning.

diff -r a7ff19afbb14 -r 04809b6012bd src/os/win32/ngx_files.c
--- a/src/os/win32/ngx_files.c Mon Nov 26 18:29:56 2018 +0300
+++ b/src/os/win32/ngx_files.c Tue Nov 27 13:54:19 2018 +0900
@@ -175,7 +175,7 @@


ssize_t
-ngx_write_fd(ngx_fd_t fd, void *buf, size_t size)
+ngx_write_fd(ngx_fd_t fd, const void *buf, size_t size)
{
u_long n;

diff -r a7ff19afbb14 -r 04809b6012bd src/os/win32/ngx_files.h
--- a/src/os/win32/ngx_files.h Mon Nov 26 18:29:56 2018 +0300
+++ b/src/os/win32/ngx_files.h Tue Nov 27 13:54:19 2018 +0900
@@ -107,7 +107,7 @@
#define ngx_read_fd_n "ReadFile()"


-ssize_t ngx_write_fd(ngx_fd_t fd, void *buf, size_t size);
+ssize_t ngx_write_fd(ngx_fd_t fd, const void *buf, size_t size);
#define ngx_write_fd_n "WriteFile()"

--
Kentaro Hayashi <kenhys@gmail.com>
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[PATCH] Win32: Don't discards const qualifiers for WriteFile

Kentaro Hayashi 296 November 27, 2018 12:10AM

Re: [PATCH] Win32: Don't discards const qualifiers for WriteFile

Maxim Dounin 130 November 27, 2018 08:28AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 226
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready