Skip to content

Commit

Permalink
Fix msbuild warnings C4005, C4242 (VowpalWabbit#2619)
Browse files Browse the repository at this point in the history
* Fix msbuild typecast warnings

* Better way to fix C4005

* Fix formatting errors and invalid USHORT cast

Co-authored-by: Schuyler Goodman <[email protected]>
Co-authored-by: Jack Gerrits <[email protected]>
  • Loading branch information
3 people authored Oct 29, 2020
1 parent e1a9485 commit 73f3d7f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
7 changes: 3 additions & 4 deletions vowpalwabbit/allreduce_sockets.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ socket_t AllReduceSockets::sock_connect(const uint32_t ip, const int port)

sockaddr_in far_end;
far_end.sin_family = AF_INET;
far_end.sin_port = port;
far_end.sin_port = (u_short)port;

far_end.sin_addr = *(in_addr*)&ip;
memset(&far_end.sin_zero, '\0', 8);
Expand All @@ -56,8 +56,7 @@ socket_t AllReduceSockets::sock_connect(const uint32_t ip, const int port)
if (getnameinfo((sockaddr*)&far_end, sizeof(sockaddr), hostname, NI_MAXHOST, servInfo, NI_MAXSERV, NI_NUMERICSERV))
THROWERRNO("getnameinfo(" << dotted_quad << ")");

if (!quiet)
cerr << "connecting to " << dotted_quad << " = " << hostname << ':' << ntohs(port) << endl;
if (!quiet) cerr << "connecting to " << dotted_quad << " = " << hostname << ':' << ntohs((u_short)port) << endl;
}

size_t count = 0;
Expand Down Expand Up @@ -132,7 +131,7 @@ void AllReduceSockets::all_reduce_init()

uint32_t master_ip = *((uint32_t*)master->h_addr);

socket_t master_sock = sock_connect(master_ip, htons(port));
socket_t master_sock = sock_connect(master_ip, htons((u_short)port));
if (send(master_sock, (const char*)&unique_id, sizeof(unique_id), 0) < (int)sizeof(unique_id))
{
THROW("write unique_id=" << unique_id << " to span server failed");
Expand Down
5 changes: 4 additions & 1 deletion vowpalwabbit/v_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
// license as described in the file LICENSE.

#pragma once
#define NOMINMAX
#ifndef NOMINMAX
# define NOMINMAX
#endif

#include <iostream>
#include <algorithm>
#include <cstdlib>
Expand Down

0 comments on commit 73f3d7f

Please sign in to comment.