Check for return value of WSAStartup on all executables.

Windows vscodeanalysis complains even though the event is probably
very unlikely.

Change-Id: Iafe158eea5586908209d6bfe1e45540117558673
Reviewed-on: https://code.wireshark.org/review/20727
Reviewed-by: Michael Mann <mmann78@netscape.net>
This commit is contained in:
Michael Mann 2017-03-26 18:46:13 -04:00
parent 520cfcf53b
commit 3b588dffcf
6 changed files with 43 additions and 6 deletions

View File

@ -3779,6 +3779,7 @@ main(int argc, char *argv[])
gboolean arg_error = FALSE;
#ifdef _WIN32
int result;
WSADATA wsaData;
#else
struct sigaction action, oldaction;
@ -3970,7 +3971,13 @@ main(int argc, char *argv[])
/*wpcap_packet_load();*/
/* Start windows sockets */
WSAStartup( MAKEWORD( 1, 1 ), &wsaData );
result = WSAStartup( MAKEWORD( 1, 1 ), &wsaData );
if (result != 0)
{
g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_ERROR,
"ERROR: WSAStartup failed with error: %d", result);
exit_main(1);
}
/* Set handler for Ctrl+C key */
SetConsoleCtrlHandler(capture_cleanup_handler, TRUE);

View File

@ -429,6 +429,7 @@ main(int argc, char *argv[])
gboolean arg_error = FALSE;
#ifdef _WIN32
int result;
WSADATA wsaData;
#else
struct rlimit limit;
@ -824,7 +825,12 @@ main(int argc, char *argv[])
#ifdef _WIN32
/* Start windows sockets */
WSAStartup( MAKEWORD( 1, 1 ), &wsaData );
result = WSAStartup( MAKEWORD( 1, 1 ), &wsaData );
if (result != 0)
{
ret = INIT_ERROR;
goto clean_exit;
}
#endif /* _WIN32 */
/* At this point MATE will have registered its field array so we can

View File

@ -73,8 +73,13 @@ socket_init(char *path)
#ifdef _WIN32
WSADATA wsaData;
int result;
WSAStartup(MAKEWORD(1, 1), &wsaData);
result = WSAStartup(MAKEWORD(1, 1), &wsaData);
if (result != 0) {
g_warning("ERROR: WSAStartup failed with error: %d", result);
return INVALID_SOCKET;
}
#endif
#ifdef SHARKD_UNIX_SUPPORT

View File

@ -661,6 +661,7 @@ main(int argc, char *argv[])
gboolean arg_error = FALSE;
#ifdef _WIN32
int result;
WSADATA wsaData;
#endif /* _WIN32 */
@ -1769,7 +1770,12 @@ main(int argc, char *argv[])
#ifdef _WIN32
/* Start windows sockets */
WSAStartup( MAKEWORD( 1, 1 ), &wsaData );
result = WSAStartup( MAKEWORD( 1, 1 ), &wsaData );
if (result != 0)
{
exit_status = INIT_FAILED;
goto clean_exit;
}
#endif /* _WIN32 */
/* Notify all registered modules that have had any of their preferences

View File

@ -2066,6 +2066,7 @@ main(int argc, char *argv[])
#ifdef _WIN32
WSADATA wsaData;
int result;
#endif /* _WIN32 */
char *rf_path;
@ -2197,7 +2198,13 @@ main(int argc, char *argv[])
#ifdef _WIN32
/* Start windows sockets */
WSAStartup( MAKEWORD( 1, 1 ), &wsaData );
result = WSAStartup( MAKEWORD( 1, 1 ), &wsaData );
if (result != 0) {
simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
"Error: WSAStartup failed with error: %d", result);
ret = INIT_FAILED;
goto clean_exit;
}
#endif /* _WIN32 */
profile_store_persconffiles (TRUE);

View File

@ -339,6 +339,7 @@ int main(int argc, char *qt_argv[])
char **argv = qt_argv;
#ifdef _WIN32
int result;
WSADATA wsaData;
#endif /* _WIN32 */
@ -509,7 +510,12 @@ int main(int argc, char *qt_argv[])
#ifdef _WIN32
/* Start windows sockets */
WSAStartup( MAKEWORD( 1, 1 ), &wsaData );
result = WSAStartup( MAKEWORD( 1, 1 ), &wsaData );
if (result != 0)
{
ret_val = INIT_FAILED;
goto clean_exit;
}
#endif /* _WIN32 */
/* Read the profile dependent (static part) of the recent file. */