You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by rh...@apache.org on 2014/02/16 19:36:23 UTC
svn commit: r1568806 - in /subversion/trunk/subversion/libsvn_subr:
sysinfo.c sysinfo.h win32_crashrpt.c
Author: rhuijben
Date: Sun Feb 16 18:36:23 2014
New Revision: 1568806
URL: http://svn.apache.org/r1568806
Log:
Hide an ugly warning when compiling Subversion using the Windows 8.1 SDK:
Obtaining the actual Windows version (for comparison) is deprecated.
* subversion/libsvn_subr/sysinfo.c
(svn_sysinfo___fill_windows_version): New function, extracted from...
(system_info): ... this. Use memset instead of ZeroMemory as everywhere
else.
(win32_canonical_host,
win32_release_name): Update caller.
* subversion/libsvn_subr/sysinfo.h
(svn_sysinfo___fill_windows_version): Update caller.
* subversion/libsvn_subr/win32_crashrpt.c
(includes): Add sysinfo.h.
(write_process_info): Update caller. Properly print/convert unicode.
Modified:
subversion/trunk/subversion/libsvn_subr/sysinfo.c
subversion/trunk/subversion/libsvn_subr/sysinfo.h
subversion/trunk/subversion/libsvn_subr/win32_crashrpt.c
Modified: subversion/trunk/subversion/libsvn_subr/sysinfo.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/sysinfo.c?rev=1568806&r1=1568805&r2=1568806&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/sysinfo.c (original)
+++ subversion/trunk/subversion/libsvn_subr/sysinfo.c Sun Feb 16 18:36:23 2014
@@ -550,22 +550,46 @@ linux_release_name(apr_pool_t *pool)
typedef DWORD (WINAPI *FNGETNATIVESYSTEMINFO)(LPSYSTEM_INFO);
typedef BOOL (WINAPI *FNENUMPROCESSMODULES) (HANDLE, HMODULE*, DWORD, LPDWORD);
-/* Get system and version info, and try to tell the difference
- between the native system type and the runtime environment of the
- current process. Populate results in SYSINFO, LOCAL_SYSINFO
- (optional) and OSINFO. */
+svn_boolean_t
+svn_sysinfo___fill_windows_version(OSVERSIONINFOEXW *version_info)
+{
+ memset(version_info, 0, sizeof(*version_info));
+
+ version_info->dwOSVersionInfoSize = sizeof(*version_info);
+
+ /* Kill warnings with the Windows 8 and later platform SDK */
+#if _MSC_VER > 1600 && NTDDI_VERSION >= _0x06020000
+ /* Windows 8 deprecated the API to retrieve the Windows version to avoid
+ backwards compatibility problems... It might return a constant version
+ in future Windows versions... But let's kill the warning.
+
+ We can implementation this using a different function later. */
+#pragma warning(push)
+#pragma warning(disable: 4996)
+#endif
+
+ /* Prototype supports OSVERSIONINFO */
+ return GetVersionExW((LPVOID)version_info);
+#if _MSC_VER > 1600 && NTDDI_VERSION >= _0x06020000
+#pragma warning(pop)
+#pragma warning(disable: 4996)
+#endif
+}
+
+/* Get system info, and try to tell the difference between the native
+ system type and the runtime environment of the current process.
+ Populate results in SYSINFO and LOCAL_SYSINFO (optional). */
static BOOL
system_info(SYSTEM_INFO *sysinfo,
- SYSTEM_INFO *local_sysinfo,
- OSVERSIONINFOEXW *osinfo)
+ SYSTEM_INFO *local_sysinfo)
{
FNGETNATIVESYSTEMINFO GetNativeSystemInfo_ = (FNGETNATIVESYSTEMINFO)
GetProcAddress(GetModuleHandleA("kernel32.dll"), "GetNativeSystemInfo");
- ZeroMemory(sysinfo, sizeof *sysinfo);
+ memset(sysinfo, 0, sizeof *sysinfo);
if (local_sysinfo)
{
- ZeroMemory(local_sysinfo, sizeof *local_sysinfo);
+ memset(local_sysinfo, 0, sizeof *local_sysinfo);
GetSystemInfo(local_sysinfo);
if (GetNativeSystemInfo_)
GetNativeSystemInfo_(sysinfo);
@@ -575,11 +599,6 @@ system_info(SYSTEM_INFO *sysinfo,
else
GetSystemInfo(sysinfo);
- ZeroMemory(osinfo, sizeof *osinfo);
- osinfo->dwOSVersionInfoSize = sizeof *osinfo;
- if (!GetVersionExW((LPVOID)osinfo))
- return FALSE;
-
return TRUE;
}
@@ -612,7 +631,8 @@ win32_canonical_host(apr_pool_t *pool)
SYSTEM_INFO local_sysinfo;
OSVERSIONINFOEXW osinfo;
- if (system_info(&sysinfo, &local_sysinfo, &osinfo))
+ if (system_info(&sysinfo, &local_sysinfo)
+ && svn_sysinfo___fill_windows_version(&osinfo))
{
const char *arch = processor_name(&local_sysinfo);
const char *machine = processor_name(&sysinfo);
@@ -676,7 +696,8 @@ win32_release_name(apr_pool_t *pool)
OSVERSIONINFOEXW osinfo;
HKEY hkcv;
- if (!system_info(&sysinfo, NULL, &osinfo))
+ if (!system_info(&sysinfo, NULL)
+ || !svn_sysinfo___fill_windows_version(&osinfo))
return NULL;
if (!RegOpenKeyExW(HKEY_LOCAL_MACHINE,
Modified: subversion/trunk/subversion/libsvn_subr/sysinfo.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/sysinfo.h?rev=1568806&r1=1568805&r2=1568806&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/sysinfo.h (original)
+++ subversion/trunk/subversion/libsvn_subr/sysinfo.h Sun Feb 16 18:36:23 2014
@@ -62,6 +62,17 @@ const apr_array_header_t *svn_sysinfo__l
*/
const apr_array_header_t *svn_sysinfo__loaded_libs(apr_pool_t *pool);
+#ifdef WIN32
+/* Obtain the Windows version information as OSVERSIONINFOEXW structure.
+ *
+ * !!! Unlike other apis the caller is expected to pre-allocate the buffer
+ * !!! to allow using this api from the crash handler.
+ */
+svn_boolean_t
+svn_sysinfo___fill_windows_version(OSVERSIONINFOEXW *version_info);
+#endif
+
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
Modified: subversion/trunk/subversion/libsvn_subr/win32_crashrpt.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/win32_crashrpt.c?rev=1568806&r1=1568805&r2=1568806&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/win32_crashrpt.c (original)
+++ subversion/trunk/subversion/libsvn_subr/win32_crashrpt.c Sun Feb 16 18:36:23 2014
@@ -37,6 +37,8 @@ typedef int win32_crashrpt__dummy;
#include "svn_version.h"
+#include "sysinfo.h"
+
#include "win32_crashrpt.h"
#include "win32_crashrpt_dll.h"
@@ -188,7 +190,7 @@ static void
write_process_info(EXCEPTION_RECORD *exception, CONTEXT *context,
FILE *log_file)
{
- OSVERSIONINFOW oi;
+ OSVERSIONINFOEXW oi;
const char *cmd_line;
char workingdir[8192];
@@ -207,13 +209,11 @@ write_process_info(EXCEPTION_RECORD *exc
SVN_VERSION, __DATE__, __TIME__);
/* write information about the OS */
- oi.dwOSVersionInfoSize = sizeof(oi);
- GetVersionExW(&oi);
-
- fprintf(log_file,
- "Platform: Windows OS version %d.%d build %d %s\n\n",
- oi.dwMajorVersion, oi.dwMinorVersion, oi.dwBuildNumber,
- oi.szCSDVersion);
+ if (svn_sysinfo___fill_windows_version(&oi))
+ fprintf(log_file,
+ "Platform: Windows OS version %d.%d build %d %S\n\n",
+ oi.dwMajorVersion, oi.dwMinorVersion, oi.dwBuildNumber,
+ oi.szCSDVersion);
/* write the exception code */
fprintf(log_file,