Remove code specific to older versions of Visual Studio.

Remove -DBUILD_WINDOWS and sections of code that we no longer use.

Bug: 14715
Change-Id: Iae1a950e2f52f4ce45fcf0ae5dea06c1172c3a28
Reviewed-on: https://code.wireshark.org/review/28466
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Graham Bloice <graham.bloice@trihedral.com>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
This commit is contained in:
Gerald Combs 2018-06-15 10:52:53 -07:00
parent c68a1f049e
commit fe94133f0d
6 changed files with 13 additions and 108 deletions

View File

@ -286,17 +286,11 @@ if( CMAKE_C_COMPILER_ID MATCHES "MSVC")
# resolution of symbols, add Psapi.lib to the TARGETLIBS macro and compile the program
# with -DPSAPI_VERSION=1.To use run-time dynamic linking, load Psapi.dll.
# http://msdn.microsoft.com/en-us/library/windows/desktop/ms683219(v=vs.85).aspx
# -DBUILD_WINDOWS Starting from VS2013, GetVersionEx is deprecated and we are recommended to use
# VerifyVersionInfo instead
# http://msdn.microsoft.com/en-us/library/windows/desktop/ms724429(v=vs.85).aspx
# http://msdn.microsoft.com/en-us/library/windows/desktop/ms725491(v=vs.85).aspx
# To continue to use GetVersionEx, we can define BUILD_WINDOWS
# -D_ALLOW_KEYWORD_MACROS For VS2012 onwards the, C++ STL does not permit macro redefinitions of keywords
# (see http://msdn.microsoft.com/en-us/library/bb531344(v=vs.110).aspx)
# This definition prevents the complaint about the redefinition of inline by WinPCap
# in pcap-stdinc.h when compiling C++ files, e.g. the Qt UI
/DPSAPI_VERSION=1
/DBUILD_WINDOWS
/D_ALLOW_KEYWORD_MACROS
)

View File

@ -183,36 +183,6 @@ parse_as_guid(const char *guid_text, GUID *guid)
return TRUE;
}
/**********************************************************************************/
gboolean IsWindowsVistaOrLater()
{
#if (_MSC_VER >= 1800)
/*
* On VS2103, GetVersionEx is deprecated. Microsoft recommend to
* use VerifyVersionInfo instead
*/
OSVERSIONINFOEX osvi;
DWORDLONG dwlConditionMask = 0;
int op = VER_GREATER_EQUAL;
SecureZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
osvi.dwMajorVersion = 6;
VER_SET_CONDITION(dwlConditionMask, VER_MAJORVERSION, op);
return VerifyVersionInfo(&osvi, VER_MAJORVERSION, dwlConditionMask);
#else
OSVERSIONINFO osvi;
SecureZeroMemory(&osvi, sizeof(OSVERSIONINFO));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
if(GetVersionEx(&osvi)){
return osvi.dwMajorVersion >= 6;
}
return FALSE;
#endif
}
/**********************************************************************************/
/* Get the friendly name for the given GUID */
char *

View File

@ -123,7 +123,7 @@ void proto_report_dissector_bug(const char *format, ...)
/** Macro used to provide a hint to static analysis tools.
* (Currently only Visual C++.)
*/
#if _MSC_VER >= 1400
#ifdef _MSC_VER
/* XXX - Is there a way to say "quit checking at this point"? */
#define __DISSECTOR_ASSERT_STATIC_ANALYSIS_HINT(expression) \
; __analysis_assume(expression);

View File

@ -175,7 +175,7 @@ gboolean
win32_open_file (HWND h_wnd, GString *file_name, unsigned int *type, GString *display_filter) {
OPENFILENAME *ofn;
TCHAR file_name16[MAX_PATH] = _T("");
int ofnsize;
int ofnsize = sizeof(OPENFILENAME);
BOOL gofn_ok;
if (!file_name || !display_filter)
@ -191,7 +191,7 @@ win32_open_file (HWND h_wnd, GString *file_name, unsigned int *type, GString *di
g_free(g_dfilter_str);
g_dfilter_str = NULL;
}
ofnsize = sizeof(OPENFILENAME);
ofn = g_malloc0(ofnsize);
ofn->lStructSize = ofnsize;
@ -332,7 +332,7 @@ win32_save_as_file(HWND h_wnd, capture_file *cf, GString *file_name, int *file_t
GArray *savable_file_types;
OPENFILENAME *ofn;
TCHAR file_name16[MAX_PATH] = _T("");
int ofnsize;
int ofnsize = sizeof(OPENFILENAME);
BOOL gsfn_ok;
if (!file_name || !file_type || !compressed)
@ -355,7 +355,6 @@ win32_save_as_file(HWND h_wnd, capture_file *cf, GString *file_name, int *file_t
return FALSE; /* shouldn't happen - the "Save As..." item should be disabled if we can't save the file */
g_compressed = FALSE;
ofnsize = sizeof(OPENFILENAME);
ofn = g_malloc0(ofnsize);
ofn->lStructSize = ofnsize;
@ -411,11 +410,8 @@ gboolean win32_save_as_statstree(HWND h_wnd, GString *file_name, int *file_type)
{
OPENFILENAME *ofn;
TCHAR file_name16[MAX_PATH] = _T("");
int ofnsize;
int ofnsize = sizeof(OPENFILENAME);
BOOL gsfn_ok;
#if (_MSC_VER >= 1500)
OSVERSIONINFO osvi;
#endif
if (!file_name || !file_type)
return FALSE;
@ -424,20 +420,7 @@ gboolean win32_save_as_statstree(HWND h_wnd, GString *file_name, int *file_type)
StringCchCopy(file_name16, MAX_PATH, utf_8to16(file_name->str));
}
/* see OPENFILENAME comment in win32_open_file */
#if (_MSC_VER >= 1500)
SecureZeroMemory(&osvi, sizeof(OSVERSIONINFO));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&osvi);
if (osvi.dwMajorVersion >= 5) {
ofnsize = sizeof(OPENFILENAME);
} else {
ofnsize = OPENFILENAME_SIZE_VERSION_400;
}
#else
ofnsize = sizeof(OPENFILENAME) + 12;
#endif
ofn = g_malloc0(ofnsize);
ofn = g_malloc0(sizeof(OPENFILENAME));
ofn->lStructSize = ofnsize;
ofn->hwndOwner = h_wnd;
@ -484,7 +467,7 @@ win32_export_specified_packets_file(HWND h_wnd, capture_file *cf,
GArray *savable_file_types;
OPENFILENAME *ofn;
TCHAR file_name16[MAX_PATH] = _T("");
int ofnsize;
int ofnsize = sizeof(OPENFILENAME);
BOOL gsfn_ok;
if (!file_name || !file_type || !compressed || !range)
@ -503,7 +486,6 @@ win32_export_specified_packets_file(HWND h_wnd, capture_file *cf,
g_cf = cf;
g_compressed = FALSE;
ofnsize = sizeof(OPENFILENAME);
ofn = g_malloc0(ofnsize);
ofn->lStructSize = ofnsize;
@ -562,7 +544,7 @@ gboolean
win32_merge_file (HWND h_wnd, GString *file_name, GString *display_filter, int *merge_type) {
OPENFILENAME *ofn;
TCHAR file_name16[MAX_PATH] = _T("");
int ofnsize;
int ofnsize = sizeof(OPENFILENAME);
BOOL gofn_ok;
if (!file_name || !display_filter || !merge_type)
@ -579,7 +561,6 @@ win32_merge_file (HWND h_wnd, GString *file_name, GString *display_filter, int *
g_dfilter_str = NULL;
}
ofnsize = sizeof(OPENFILENAME);
ofn = g_malloc0(ofnsize);
ofn->lStructSize = ofnsize;
@ -642,11 +623,10 @@ win32_export_file(HWND h_wnd, capture_file *cf, export_type_e export_type) {
TCHAR file_name[MAX_PATH] = _T("");
char *dirname;
cf_print_status_t status;
int ofnsize;
int ofnsize = sizeof(OPENFILENAME);
g_cf = cf;
ofnsize = sizeof(OPENFILENAME);
ofn = g_malloc0(ofnsize);
ofn->lStructSize = ofnsize;
@ -754,7 +734,7 @@ win32_export_raw_file(HWND h_wnd, capture_file *cf) {
const guint8 *data_p;
char *file_name8;
int fd;
int ofnsize;
int ofnsize = sizeof(OPENFILENAME);
if (!cf->finfo_selected) {
/* This shouldn't happen */
@ -762,7 +742,6 @@ win32_export_raw_file(HWND h_wnd, capture_file *cf) {
return;
}
ofnsize = sizeof(OPENFILENAME);
ofn = g_malloc0(ofnsize);
ofn->lStructSize = ofnsize;
@ -831,7 +810,7 @@ win32_export_sslkeys_file(HWND h_wnd) {
gchar *keylist = NULL;
char *file_name8;
int fd;
int ofnsize;
int ofnsize = sizeof(OPENFILENAME);
int keylist_size;
keylist_size = ssl_session_key_count();
@ -841,7 +820,6 @@ win32_export_sslkeys_file(HWND h_wnd) {
return;
}
ofnsize = sizeof(OPENFILENAME);
ofn = g_malloc0(ofnsize);
ofn->lStructSize = ofnsize;
@ -909,10 +887,9 @@ win32_export_color_file(HWND h_wnd, capture_file *cf, gpointer filter_list) {
OPENFILENAME *ofn;
TCHAR file_name[MAX_PATH] = _T("");
gchar *dirname;
int ofnsize;
int ofnsize = sizeof(OPENFILENAME);
gchar *err_msg = NULL;
ofnsize = sizeof(OPENFILENAME);
ofn = g_malloc0(ofnsize);
ofn->lStructSize = ofnsize;
@ -964,10 +941,9 @@ win32_import_color_file(HWND h_wnd, gpointer color_filters) {
OPENFILENAME *ofn;
TCHAR file_name[MAX_PATH] = _T("");
gchar *dirname;
int ofnsize;
int ofnsize = sizeof(OPENFILENAME);
gchar *err_msg = NULL;
ofnsize = sizeof(OPENFILENAME);
ofn = g_malloc0(ofnsize);
ofn->lStructSize = ofnsize;

View File

@ -2017,28 +2017,11 @@ file_exists(const char *fname)
return FALSE;
}
#if defined(_MSC_VER) && _MSC_VER < 1900
/*
* This is a bit tricky on win32. The st_ino field is documented as:
* "The inode, and therefore st_ino, has no meaning in the FAT, ..."
* but it *is* set to zero if stat() returns without an error,
* so this is working, but maybe not quite the way expected. ULFL
*/
file_stat.st_ino = 1; /* this will make things work if an error occurred */
ws_stat64(fname, &file_stat);
if (file_stat.st_ino == 0) {
return TRUE;
} else {
return FALSE;
}
#else
if (ws_stat64(fname, &file_stat) != 0 && errno == ENOENT) {
return FALSE;
} else {
return TRUE;
}
#endif
}
/*

View File

@ -25,22 +25,6 @@ extern "C" {
#ifdef _WIN32
#include <strsafe.h>
#if _MSC_VER < 1900
#include <stdarg.h>
/*
* vsnprintf_s's return value isn't compatible with C99 vsnprintf. We don't
* return anything in order to avoid confusion.
*/
static __inline void
ws_vsnprintf(char *buffer, size_t size_of_buffer, const char *format, va_list argptr) {
/* We could alternatively use StringCchVPrintfA */
vsnprintf_s(buffer, size_of_buffer, _TRUNCATE, format, argptr);
}
#else /* _MSC_VER uses UCRT */
/* The UCRT versions of snprintf and vsnprintf conform to C99 */
static __inline void
@ -49,8 +33,6 @@ ws_vsnprintf(char *buffer, size_t size_of_buffer, const char *format, va_list ar
vsnprintf(buffer, size_of_buffer, format, argptr);
}
#endif /* _MSC_VER */
#else /* _WIN32 */
#include <glib.h>