cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Win32 use of GetVersionEx()

From: Myria <myriachan_at_cox.net>
Date: Sat, 18 Jan 2014 11:52:08 -0800

Sorry for the delayed reply. That you've already committed is fine, as the
critical issue was the VER_EQUAL instead of VER_GREATER_EQUAL.

> What about ASCII builds - won't using the wide function and struct break
> that as a supported build platform?

No, because builds intended for Windows 9x use already have to disable this
code. Even without UNICODE #define'd, you can still explicitly call the W
variants of Win32 functions should you desire. You just have to make sure
that you don't break the interface expected by your library's users - and
here, that's not a problem, as this is internal code.

It's not really important, thought. Since the strings of the structure are
not being checked, the difference only relates to performance - in general,
the W versions of Win32 functions are faster than the A versions because the
A version merely translates to the W version (one exception is
OutputDebugStringW, which goes the other way). However, performance on
*this* call doesn't matter - it took me longer to write this reply than the
sum of every computer will *ever* waste calling the A version.

Maybe I shouldn't have brought it up; I'm just a stickler for avoiding the A
version of Win32, treating it as deprecated, with the exception of
OutputDebugStringA.

> If it was outside the function, or a modern version of a #define at the
> top of the source file (for example) I would have no hesitation in using
> static const DWORD but is there any benefit over just a const DWORD? As
> such I haven't made either modification yet and await feedback ;-)

I don't think it matters in *this* case, but in general, it does matter.
The compiler will often emit instructions to fill in a stack variable rather
than merely either hardcode the value inlined as a machine code operand or
as a global variable. This is especially important in the distinction
between:

const char string[] = "meow";
static const char string[] = "meow";

I doubt it matters here, though.

-----Original Message-----
From: Steve Holme
Sent: Wednesday, January 15, 2014 3:34 PM
To: 'libcurl development'
Subject: RE: Win32 use of GetVersionEx()

On Wed, 15 Jan 2014, myriachan_at_cox.net wrote:

> Change VER_EQUAL to VER_GREATER_EQUAL. The existence of code
> like this is why Windows 7 is NT 6.1 and not 7.0 =^-^=

Well spotted - thank you.... and update pushed.

Believe it or not, a previous iteration of the fix used VER_GREATER_EQUAL
and somehow the copying and pasting between connect.c and curl_sspi.c
reverted that :(

> Put "static const" before DWORD majorVersion, or use #define, and
> perhaps capitalize it as VISTA_MAJOR_VERSION or something.

If it was outside the function, or a modern version of a #define at the top
of the source file (for example) I would have no hesitation in using static
const DWORD but is there any benefit over just a const DWORD? As such I
haven't made either modification yet and await feedback ;-)

> Since VerifyVersionInfo is specific to NT (I'm believing what you say),
> you might as well force Unicode use here. Use OSVERSIONINFOEXW
> and VerifyVersionInfoW.

MSDN says the function was introduced in Windows 2000 and Windows 2000
server. However...

What about ASCII builds - won't using the wide function and struct break
that as a supported build platform?

Cheers again

Steve

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2014-01-18