From e05a9354a3a9656f37e65b07d440cc7a78ea65af Mon Sep 17 00:00:00 2001 From: Glenn Strauss Date: Fri, 12 May 2023 20:40:48 -0400 Subject: [core] _WIN32 quiet compiler warnings 32-bit build --- src/fdevent_win32.c | 8 ++++---- src/plugin.c | 4 ++++ src/request.c | 4 ++-- src/server_win32.c | 3 ++- src/sys-mmap.h | 8 ++++++++ src/sys-time.h | 6 ++---- 6 files changed, 22 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/fdevent_win32.c b/src/fdevent_win32.c index 2ed631e7..efc79ee8 100644 --- a/src/fdevent_win32.c +++ b/src/fdevent_win32.c @@ -242,14 +242,14 @@ int fdevent_socketpair_nb_cloexec (int domain, int typ, int protocol, int sv[2]) int fdevent_socket_set_cloexec (int fd) { - return SetHandleInformation((HANDLE)(uint64_t)fd, + return SetHandleInformation((HANDLE)(uintptr_t)fd, HANDLE_FLAG_INHERIT, 0) ? 0 : -1; } int fdevent_socket_clr_cloexec (int fd) { - return SetHandleInformation((HANDLE)(uint64_t)fd, + return SetHandleInformation((HANDLE)(uintptr_t)fd, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT) ? 0 : -1; @@ -265,7 +265,7 @@ int fdevent_socket_set_nb (int fd) int fdevent_socket_set_nb_cloexec (int fd) { - return SetHandleInformation((HANDLE)(uint64_t)fd, HANDLE_FLAG_INHERIT, 0) + return SetHandleInformation((HANDLE)(uintptr_t)fd, HANDLE_FLAG_INHERIT, 0) ? fdevent_socket_set_nb(fd) : -1; } @@ -645,7 +645,7 @@ pid_t fdevent_createprocess (char *argv[], char *envp[], intptr_t fdin, intptr_t * Programmatically controlling which handles are inherited by new processes * in Win32: https://devblogs.microsoft.com/oldnewthing/20111216-00/?p=8873 */ - size_t sz = 0; + SIZE_T sz = 0; InitializeProcThreadAttributeList(NULL, 1, 0, &sz); /* GetLastError() == ERROR_INSUFFICIENT_BUFFER */ LPPROC_THREAD_ATTRIBUTE_LIST attrlist = info.lpAttributeList = malloc(sz); diff --git a/src/plugin.c b/src/plugin.c index 98b3114b..4728a224 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -152,7 +152,11 @@ int plugins_load(server *srv) { srv->srvconf.modules->used, sizeof(plugin *)); buffer * const tb = srv->tmp_buf; + #ifdef _WIN32 + int (WINAPI *init)(plugin *pl); + #else int (*init)(plugin *pl); + #endif for (uint32_t i = 0; i < srv->srvconf.modules->used; ++i) { const buffer * const module = &((data_string *)srv->srvconf.modules->data[i])->value; diff --git a/src/request.c b/src/request.c index b53db2be..98136d55 100644 --- a/src/request.c +++ b/src/request.c @@ -208,7 +208,7 @@ int http_request_host_normalize(buffer * const b, const int scheme_port) { if (colon[1] != '\0') { char *e; port = strtol(colon+1, &e, 0); /*(allow decimal, octal, hex)*/ - if (0 < port && port <= USHRT_MAX && *e == '\0') { + if (0 < port && port <= (long)USHRT_MAX && *e == '\0') { /* valid port */ } else { return -1; @@ -250,7 +250,7 @@ int http_request_host_normalize(buffer * const b, const int scheme_port) { if (bracket[2] != '\0') { /*(ignore stray colon at string end)*/ char *e; port = strtol(bracket+2, &e, 0); /*(allow decimal, octal, hex)*/ - if (0 < port && port <= USHRT_MAX && *e == '\0') { + if (0 < port && port <= (long)USHRT_MAX && *e == '\0') { /* valid port */ } else { return -1; diff --git a/src/server_win32.c b/src/server_win32.c index 42ea8ca6..6faac8ae 100644 --- a/src/server_win32.c +++ b/src/server_win32.c @@ -239,6 +239,7 @@ static void lighttpd_ServiceMain (DWORD dwNumServicesArgs, LPSTR *lpServiceArgVe { /* service thread; not main(); params are not program startup argc, argv */ hStatus = RegisterServiceCtrlHandlerA("lighttpd", + (LPHANDLER_FUNCTION) lighttpd_ServiceCtrlHandler); if (!hStatus) return; /*(unexpected; can not continue)*/ lighttpd_ServiceStatus(SERVICE_START_PENDING, NO_ERROR, 1000); @@ -281,7 +282,7 @@ static void lighttpd_ServiceCtrlDispatcher (int argc, char ** argv) svc_main_argv = argv; static const SERVICE_TABLE_ENTRYA lighttpd_ServiceDispatchTable[] = { - { "lighttpd", lighttpd_ServiceMain }, + { "lighttpd", (LPSERVICE_MAIN_FUNCTIONA)lighttpd_ServiceMain }, { NULL, NULL } }; UINT rc = StartServiceCtrlDispatcherA(lighttpd_ServiceDispatchTable) diff --git a/src/sys-mmap.h b/src/sys-mmap.h index bf8e815d..b740713d 100644 --- a/src/sys-mmap.h +++ b/src/sys-mmap.h @@ -40,13 +40,21 @@ mmap (void *addr, size_t length, int prot, int flags, int fd, off_t offset) HANDLE mh = CreateFileMapping((HANDLE) _get_osfhandle(fd), NULL, PAGE_READONLY, + #ifdef _WIN64 (sizeof(size_t) > 4) ? length >> 32 : 0, + #else + 0, + #endif length & 0xffffffff, NULL); if (NULL == mh) return MAP_FAILED; LPVOID p = MapViewOfFileEx(mh, FILE_MAP_READ, + #ifdef _WIN64 (sizeof(off_t) > 4) ? offset >> 32 : 0, + #else + 0, + #endif offset & 0xffffffff, length, addr); CloseHandle(mh); return (NULL != p) ? (void *)p : MAP_FAILED; diff --git a/src/sys-time.h b/src/sys-time.h index 1901b298..86ef5ff3 100644 --- a/src/sys-time.h +++ b/src/sys-time.h @@ -125,8 +125,7 @@ gmtime_y2038_kludge32 (unix_time64_t t, struct tm *result) * Thu, 01 Jan 1970 00:00:00 GMT) *(returning NULL not expected by lighttpd and might crash)*/ tt = 0; - gmtime_r(&tt, result); - return result; + return gmtime_r(&tt, result); } } @@ -161,8 +160,7 @@ localtime_y2038_kludge32 (unix_time64_t t, struct tm *result) * Thu, 01 Jan 1970 00:00:00 GMT) *(returning NULL not expected by lighttpd and might crash)*/ tt = 0; - localtime_r(&tt, result); - return result; + return localtime_r(&tt, result); } } -- cgit v1.2.1