Closed Bug 925599 Opened 11 years ago Closed 11 years ago

GetVersionEx is deprecated in VS2013, breaks dirs that use FAIL_ON_WARNINGS (update version checking apis for windows)

Categories

(Firefox Build System :: General, defect)

x86_64
Windows 7
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
mozilla28

People

(Reporter: away, Assigned: emk)

References

Details

Attachments

(7 files, 1 obsolete file)

Build breaks with Windows 8.1 SDK (installed by VS2013) and ac_add_options --enable-warnings-as-errors netwerk/protocol/http/nsHttpHandler.cpp(706) : warning C4996: 'GetVersionExW': was declared deprecated xpcom/base/nsWindowsHelpers.h(117) : warning C4996: 'GetVersionExW': was declared deprecated GetVersionEx on MSDN: http://msdn.microsoft.com/en-us/library/windows/desktop/ms724451%28v=vs.85%29.aspx It seems that a lot of people get version comparisons wrong, so Microsoft is promoting a new family of APIs to do the comparison for you: IsWindowsVistaOrGreater() etc. But the user agent code really does need to get the raw numeric values, so we may just want to suppress the warning for that one.
There are two potential ways to fix nsWindowsHelpers.h (http://hg.mozilla.org/mozilla-central/annotate/0e26e6f12ad9/xpcom/base/nsWindowsHelpers.h#l109). 1. Check the SDK version, and if we're compiling with 8.1 then use the new ::IsWindowsVistaOrGreater(). 2. Suppress the warning. As long as we still support older SDKs, then we have to keep using GetVersionEx with those SDKs anyway. We might as well keep the code consistent. Personally I lean towards 2. Normally I like fixing warnings, but I don't think this one gives us enough benefit since we'd still have to keep the old code path. (By the way, these two hits on GetVersionEx are the only thing preventing us from --enable-warnings-as-errors. Whew. I was worried it would be worse.)
3. Use ::VerifyVersionInfo(). The new version helper API is just a thin wrapper of this function.
(In reply to Masatoshi Kimura [:emk] from comment #2) > 3. Use ::VerifyVersionInfo(). The new version helper API is just a thin > wrapper of this function. You are right, it seems that VerifyVersionInfo is available on all SDKs that we need to support. #3 is probably the best option.
Assignee: nobody → VYV03354
Status: NEW → ASSIGNED
Attachment #817537 - Flags: review?(benjamin)
Attachment #817540 - Flags: review?(bas)
Attached patch Suppress warning in netwerk/ (deleted) — Splinter Review
nsHttpHandler essentially requires GetVersionEx() to build the UA string.
Attachment #817542 - Flags: review?(mcmanus)
Attachment #817543 - Flags: review?(benjamin)
Attachment #817546 - Flags: review?(jmathies)
Attachment #817537 - Attachment is patch: true
Attachment #817543 - Attachment is patch: true
Attached patch Replace GetVersion() uses (deleted) — Splinter Review
Attachment #817565 - Flags: review?(benjamin)
Attachment #817537 - Flags: review?(benjamin) → review?(netzen)
Attachment #817543 - Flags: review?(benjamin) → review+
Comment on attachment 817545 [details] [diff] [review] Replace WinUtils::GetWindowsVersion() and GetWindowsServicePackVersion() Review of attachment 817545 [details] [diff] [review]: ----------------------------------------------------------------- I'm not a fan of 'IsOsSomeVersionOrTest' helper functions in the global scope. We've been migrating away from these and toward the WinUtils versions for a while now. I'll default to other windows folks though if people like them. Generally maybe we should wrap everything in a deeper namespace (mozilla::winver or similar?) so we can just pull the whole name space in vs. pulling in individual functions. Or better yet, don't pull in the namespace at all so people know where these calls are coming from. ::: widget/windows/nsLookAndFeel.cpp @@ +26,5 @@ > + WIN8_VERSION = 0x602, > + WIN8_1_VERSION = 0x603 > +}; > + > +static WinVersion GetWindowsVersion() Can we move this into WindowsVersion.h, but modify it such that it works like the WinUtils helpers we had that allow value comparisons?
Summary: GetVersionEx is deprecated in VS2013, breaks dirs that use FAIL_ON_WARNINGS → GetVersionEx is deprecated in VS2013, breaks dirs that use FAIL_ON_WARNINGS (update version checking apis for windows)
Also looks like we've lost the caching WinUtils performed. I'd really like to see that included in these new utils.
What's the benefit of pulling it out of widget/windows by the way? Is xpcomglue_s linked somewhere else than xul.dll that needs to use it? WinUtils.h is already exported.
> Is xpcomglue_s linked somewhere else than xul.dll that needs to use it? Yes. firefox.exe needs this, as do a few other places, AIUI.
(In reply to Benjamin Smedberg [:bsmedberg] from comment #15) > > Is xpcomglue_s linked somewhere else than xul.dll that needs to use it? > > Yes. firefox.exe needs this, as do a few other places, AIUI. Is xpcomglue_s the ideal place for it? For example some apps like updater don't link to it but would benefit from functions like the windows version helpers. I've gotten around this in the past by making the self contained static/unnamed-namespace nsWindowsHelpers.h. But I think that would lead to larger file sizes. Maybe it should go in its own winglue library?
You don't need it to be static/unnamed: you can just make it inline and then the compiler will either inline or combine them.
(In reply to Benjamin Smedberg [:bsmedberg] from comment #17) > You don't need it to be static/unnamed: you can just make it inline and then > the compiler will either inline or combine them. In C99 and possibly other places that doesn't hold true, but in general I think that doing both static and inline wouldn't hurt with link time optimizations. So should we make it header only code, and then it doesn't matter where it lives as long as it is added to the EXPORTS?
Not static inline, just inline.
They'll lea to the same file size, but that's fine. . As long as we never plan to include the new proposed, uncoded yet, header only version in .c files that's fine.
Comment on attachment 817542 [details] [diff] [review] Suppress warning in netwerk/ though you can't tell it from the directory structure, gerv is the owner of the UA code. gerv as this is code not content and you want to delegate it back to me then that would be fine by me.
Attachment #817542 - Flags: review?(mcmanus) → review?(gerv)
(In reply to Jim Mathies [:jimm] from comment #12) > ::: widget/windows/nsLookAndFeel.cpp > @@ +26,5 @@ > > + WIN8_VERSION = 0x602, > > + WIN8_1_VERSION = 0x603 > > +}; > > + > > +static WinVersion GetWindowsVersion() > > Can we move this into WindowsVersion.h, but modify it such that it works > like the WinUtils helpers we had that allow value comparisons? I would like to discourage the use of GetVersionEx as much as possible. If I moved the function to a public header, people may find the function and start to use it. (In reply to Jim Mathies [:jimm] from comment #13) > Also looks like we've lost the caching WinUtils performed. I'd really like > to see that included in these new utils. I copy & pasted the function from WinUtils. How we've lost the caching? The |version| variable will be calculated only once because it is designated with |static| in the function.
(In reply to Jim Mathies [:jimm] from comment #13) > Also looks like we've lost the caching WinUtils performed. I'd really like > to see that included in these new utils. Ah, are you saying about IsWindowsVersionOrLater()? It will cache |minVersion| and |maxVersion| to avoid calling VerifyVersionInfo() as much as possible. |minVersion| is the lowest possible version number of the system (inclusive). |maxVersion| is the highest possible version number of the system (exclusive). These values will be updated every time we could narrow the possible version range. I couldn't think of any better caching method because VerifyVersionInfo() will not return the exact version number directly.
(In reply to Masatoshi Kimura [:emk] from comment #23) > (In reply to Jim Mathies [:jimm] from comment #13) > > Also looks like we've lost the caching WinUtils performed. I'd really like > > to see that included in these new utils. > > Ah, are you saying about IsWindowsVersionOrLater()? It will cache > |minVersion| and |maxVersion| to avoid calling VerifyVersionInfo() as much > as possible. > |minVersion| is the lowest possible version number of the system > (inclusive). |maxVersion| is the highest possible version number of the > system (exclusive). These values will be updated every time we could narrow > the possible version range. > I couldn't think of any better caching method because VerifyVersionInfo() > will not return the exact version number directly. Sorry I missed that minVersion/maxVersion while looking it over.
I made a single .cpp file to increase efficiency of the caching as much as possible. Can compilers really combine the function even if it includes |static| variables? (I admit I don't familiar with C++ black magic so much.)
For a single occurrence, you can also use #pragma warning(suppress:4996), it's a little more compact than push/disable/pop.
Comment on attachment 817542 [details] [diff] [review] Suppress warning in netwerk/ Patrick: thanks for thinking of me; I'm very happy to delegate to you review of all patches to the UA code which do not affect policy (i.e. what string it sends when). Gerv
Attachment #817542 - Flags: review?(gerv) → review?(mcmanus)
Indeed adding |inline| keyword did the trick.
Attachment #817537 - Attachment is obsolete: true
Attachment #817537 - Flags: review?(netzen)
Attachment #818400 - Flags: review?(netzen)
Attachment #817542 - Flags: review?(mcmanus) → review+
Hi guys) This code https://bitbucket.org/AnyCPU/findversion was written in a matter of keeping score/ for fun) Enjoy)
This part does not depend on other parts and needed to build with VS2013. https://hg.mozilla.org/integration/mozilla-inbound/rev/185202a68dc9
Whiteboard: [leave open]
Attachment #817542 - Flags: checkin+
Comment on attachment 818400 [details] [diff] [review] Introduce version test functions using VerifyVersionInfo(), v2 Review of attachment 818400 [details] [diff] [review]: ----------------------------------------------------------------- Look great overall :) I think you missed one in http://dxr.mozilla.org/mozilla-central/source/toolkit/mozapps/update/common/uachelper.cpp and the declaration in the .h file. ::: xpcom/base/WindowsVersion.h @@ +9,5 @@ > +#include <windows.h> > + > +namespace mozilla > +{ > + inline bool nit: MOZ_INLINE.... except if the updater file I mentioned gives you problems with the nscore.h include. If it does, then just use inline everywhere and get rid of the nscore.h include.
Attachment #818400 - Flags: review?(netzen) → feedback+
BTW, where UACHelper::IsVistaOrLater is used? I couldn't find any callers. > review?(netzen@gmail.com) → feedback+ Who do I have to ask for an additional review?
(In reply to Masatoshi Kimura [:emk] from comment #32) > BTW, where UACHelper::IsVistaOrLater is used? I couldn't find any callers. > > > review?(netzen@gmail.com) → feedback+ > > Who do I have to ask for an additional review? Great it doesn't look like it is used, so just remove it. I didn't r+ yet because I wanted to see what the next patch would be fixing the IsVistaOrLater in UACHelper. Since you're just removing it though I'll r+ since that's pretty trivial to remove :)
Attachment #818400 - Flags: review+
Depends on: 928210
(In reply to Brian R. Bondy [:bbondy] from comment #31) > nit: MOZ_INLINE.... except if the updater file I mentioned gives you > problems with the nscore.h include. If it does, then just use inline > everywhere and get rid of the nscore.h include. I'd rather get rid of MOZ_INLINE from our tree. Filed bug 928210.
Attachment #817565 - Flags: review?(benjamin) → review+
Comment on attachment 817545 [details] [diff] [review] Replace WinUtils::GetWindowsVersion() and GetWindowsServicePackVersion() Review of attachment 817545 [details] [diff] [review]: ----------------------------------------------------------------- (In reply to Masatoshi Kimura [:emk] from comment #22) > (In reply to Jim Mathies [:jimm] from comment #12) > > ::: widget/windows/nsLookAndFeel.cpp > > @@ +26,5 @@ > > > + WIN8_VERSION = 0x602, > > > + WIN8_1_VERSION = 0x603 > > > +}; > > > + > > > +static WinVersion GetWindowsVersion() > > > > Can we move this into WindowsVersion.h, but modify it such that it works > > like the WinUtils helpers we had that allow value comparisons? > > I would like to discourage the use of GetVersionEx as much as possible. If I > moved the function to a public header, people may find the function and > start to use it. I'm not saying we should use GetVersionEx, I'm suggesting we keep using a value comparison helper available. ::: content/media/wmf/WMFUtils.cpp @@ +370,2 @@ > HRESULT > MFStartup() The check here doesn't match up, is this correct? if (WinUtils::GetWindowsVersion() == WinUtils::VISTA_VERSION) vs. f (!IsWin7OrLater())
Attachment #817545 - Flags: review?(jmathies) → review+
Attachment #817546 - Flags: review?(jmathies) → review+
(In reply to Jim Mathies [:jimm] from comment #40) > I'm not saying we should use GetVersionEx, I'm suggesting we keep using a > value comparison helper available. Sorry, I don't parse your suggestion. What "value comparison helper" means? GetWindowsVersion() and GetWindowsServicePackVersion() do not compare the version. They will just return the version value. And it is unimplementable using VerifyVersionInfo() unless doing brute-force bisect (such as comment #29). I didn't remove any other functions from WinUtils. > ::: content/media/wmf/WMFUtils.cpp > @@ +370,2 @@ > > HRESULT > > MFStartup() > > The check here doesn't match up, is this correct? > > if (WinUtils::GetWindowsVersion() == WinUtils::VISTA_VERSION) > > vs. > > f (!IsWin7OrLater()) WMF is unavaliable on WinXP anyway. So WMFDecoder::Init() will always fail before calling this function.
Comment on attachment 817540 [details] [diff] [review] Replace gfxWindowsPlatform::WindowsOSVersion() Bas is unresponsive.
Attachment #817540 - Flags: review?(bas) → review?(bjacob)
Comment on attachment 817540 [details] [diff] [review] Replace gfxWindowsPlatform::WindowsOSVersion() Bas is actually a much better reviewer than me for this. Let's try again pinging him ;-)
Attachment #817540 - Flags: review?(bjacob) → review?(bas)
Bas, if you're not checking your review requests, here's hoping that you are checking your needinfo requests!
Flags: needinfo?(bas)
Bas is currently on vacation, he should be back on next Monday.
Comment on attachment 817540 [details] [diff] [review] Replace gfxWindowsPlatform::WindowsOSVersion() Review of attachment 817540 [details] [diff] [review]: ----------------------------------------------------------------- ::: gfx/thebes/gfxWindowsPlatform.cpp @@ -629,5 @@ > -#ifdef CAIRO_HAS_DWRITE_FONT > -#define WINDOWS7_RTM_BUILD 7600 > - > -static bool > -AllowDirectWrite() Can we just remove this?
(In reply to Bas Schouten (:bas.schouten) from comment #46) > ::: gfx/thebes/gfxWindowsPlatform.cpp > @@ -629,5 @@ > > -#ifdef CAIRO_HAS_DWRITE_FONT > > -#define WINDOWS7_RTM_BUILD 7600 > > - > > -static bool > > -AllowDirectWrite() > > Can we just remove this? Preview versions of Windows 7 are all expired now. No one would hit this anymore.
Comment on attachment 817540 [details] [diff] [review] Replace gfxWindowsPlatform::WindowsOSVersion() Review of attachment 817540 [details] [diff] [review]: ----------------------------------------------------------------- I suppose I can live with that explanation :)
Attachment #817540 - Flags: review?(bas) → review+
Blocks: 942402
Depends on: 970483
Depends on: 986347
Depends on: 1406793
Product: Core → Firefox Build System
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: