Skip to content

Commit

Permalink
Merge branch 'sverker/windows-compile-warnings' into maint
Browse files Browse the repository at this point in the history
  • Loading branch information
sverker committed Oct 3, 2023
2 parents e022d28 + 386e91b commit e6a02fc
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
9 changes: 4 additions & 5 deletions lib/crypto/c_src/crypto_callback.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,10 @@ DLLEXPORT struct crypto_callbacks* get_crypto_callbacks(int nlocks)
#ifdef HAVE_DYNAMIC_CRYPTO_LIB
/* This is not really a NIF library, but we use ERL_NIF_INIT in order to
* get access to the erl_nif API (on Windows).
*
* Unused 'dummy_funcv' has size 1 to avoid warning "sizeof returns 0".
*/
static struct {
int dummy__;
ErlNifFunc funcv[0];
} empty;
ERL_NIF_INIT(dummy, empty.funcv, NULL, NULL, NULL, NULL)
ErlNifFunc dummy_funcv[1];
ERL_NIF_INIT(dummy, dummy_funcv, NULL, NULL, NULL, NULL)
#endif

2 changes: 1 addition & 1 deletion lib/erl_interface/src/prog/erl_call.c
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,7 @@ static DWORD WINAPI timer_thread(void *data) {
}

static void start_timeout(int timeout) {
if (CreateThread(NULL, 0, timer_thread, (void*)timeout, 0, NULL) == NULL) {
if (CreateThread(NULL, 0, timer_thread, (void*)(DWORD_PTR)timeout, 0, NULL) == NULL) {
fprintf(stderr,"erl_call: Failed to start timer thread\n");
exit(1);
}
Expand Down
4 changes: 3 additions & 1 deletion lib/os_mon/c_src/win32sysinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,9 @@ void output_drive_info(char* drive){
}
else
if (fpGetDiskFreeSpaceEx(drive,&availbytes,&totbytes,&totbytesfree)){
sprintf(answer,"%s DRIVE_FIXED %I64u %I64u %I64u\n",drive,availbytes,totbytes,totbytesfree);
sprintf(answer,"%s DRIVE_FIXED %I64u %I64u %I64u\n",
drive, availbytes.QuadPart, totbytes.QuadPart,
totbytesfree.QuadPart);
return_answer(answer);
}
else {
Expand Down
15 changes: 10 additions & 5 deletions lib/runtime_tools/c_src/trace_ip_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,13 @@
# define ASSERT(X)
#endif

#define sock2event(s) ((ErlDrvEvent)(long)(s))
#define event2sock(p) ((SOCKET)(long)(p))
#ifdef __WIN32__
# define sock2event(s) ((ErlDrvEvent)(INT_PTR)(s))
# define event2sock(p) ((SOCKET)(INT_PTR)(p))
#else
# define sock2event(s) ((ErlDrvEvent)(long)(s))
# define event2sock(p) ((SOCKET)(long)(p))
#endif

#include "erl_driver.h"

Expand Down Expand Up @@ -432,7 +437,7 @@ static void trace_ip_ready_input(ErlDrvData handle, ErlDrvEvent fd)
* but better make sure.
*/

if ((SOCKET)(long)fd == data->fd) {
if (event2sock(fd) == data->fd) {
#ifdef __WIN32__
close_client(data);
#else
Expand Down Expand Up @@ -496,7 +501,7 @@ static void trace_ip_ready_output(ErlDrvData handle, ErlDrvEvent fd)

ASSERT(!(data->flags & FLAG_LISTEN_PORT) &&
data->que[data->questart] != NULL &&
(SOCKET)(long)fd == data->fd);
event2sock(fd) == data->fd);

tim = data->que[data->questart];
towrite = tim->siz - tim->written;
Expand Down Expand Up @@ -906,7 +911,7 @@ static int my_driver_select(TraceIpData *desc, SOCKET fd, int flags, enum MySele

static void stop_select(ErlDrvEvent event, void* _)
{
closesocket((SOCKET)(long)event);
closesocket(event2sock(event));
}

#endif /* !__WIN32__ */
Expand Down

0 comments on commit e6a02fc

Please sign in to comment.