Bug 177007

Summary: [Win] Warning fix.
Product: WebKit Reporter: Per Arne Vollan <pvollan>
Component: JavaScriptCoreAssignee: Fujii Hironori <Hironori.Fujii>
Status: RESOLVED FIXED    
Severity: Normal CC: benjamin, cdumez, cmarcelo, commit-queue, dbates, don.olmstead, ews-watchlist, Hironori.Fujii, keith_miller, mark.lam, msaboff, saam, webkit-bug-importer, ysuzuki
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch none

Description Per Arne Vollan 2017-09-15 09:07:08 PDT
On Win64, MSVC is currently giving a warning about conversion from signed to unsigned.
Comment 1 Fujii Hironori 2018-01-30 02:02:31 PST
I saw following JSC compilation warnings by building WinCairo port.

> [121/1324] Building CXX object Source\WTF\wtf\CMakeFiles\WTF.dir\ThreadingWin.cpp.obj
> ..\..\Source\WTF\wtf\ThreadingWin.cpp(326): warning C4312: 'type cast': conversion from 'unsigned int' to 'WTF::Thread *' of greater size
> ..\..\Source\WTF\wtf\ThreadingWin.cpp(362): warning C4312: 'type cast': conversion from 'unsigned int' to 'WTF::Thread *' of greater size
> ..\..\Source\WTF\wtf\ThreadingWin.cpp(365): warning C4312: 'type cast': conversion from 'unsigned int' to 'WTF::Thread *' of greater size

> [223/1324] Building CXX object Source\JavaScriptCore\CMake...ces\JavaScriptCore\unified-sources\UnifiedSource76.cpp.obj
> C:\webkit\ga\Source\JavaScriptCore\interpreter/StackVisitor.cpp(464): warning C4312: 'reinterpret_cast': conversion from 'unsigned int' to 'void *' of greater size
> [244/1324] Building CXX object Source\JavaScriptCore\CMake...es\JavaScriptCore\unified-sources\UnifiedSource100.cpp.obj
> c:\webkit\ga\source\javascriptcore\runtime\intlnumberformat.cpp(395) : warning C4701: potentially uninitialized local variable 'style' used
Comment 2 Fujii Hironori 2018-01-30 02:27:32 PST
MSDN: Rules for Using Pointers (Windows)
https://msdn.microsoft.com/library/windows/desktop/aa384242
Comment 3 Fujii Hironori 2018-01-30 02:27:53 PST
Created attachment 332641 [details]
Patch
Comment 4 Fujii Hironori 2018-01-30 02:36:12 PST
Created attachment 332642 [details]
Patch
Comment 5 Yusuke Suzuki 2018-01-30 02:57:41 PST
Comment on attachment 332642 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=332642&action=review

> Source/WTF/wtf/ThreadingWin.cpp:270
> +#define InvalidThread ((Thread*)(UINT_PTR)(0xbbadbeef))

I like `uintptr_t` even in Windows only code. And we prefer C++ casts.
`reinterpret_cast<Thread*>(static_cast<uintptr_t>(0xbbadbeef))` is better.
Comment 6 Fujii Hironori 2018-01-30 17:14:53 PST
Comment on attachment 332642 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=332642&action=review

Thank you for the review.

>> Source/WTF/wtf/ThreadingWin.cpp:270
>> +#define InvalidThread ((Thread*)(UINT_PTR)(0xbbadbeef))
> 
> I like `uintptr_t` even in Windows only code. And we prefer C++ casts.
> `reinterpret_cast<Thread*>(static_cast<uintptr_t>(0xbbadbeef))` is better.

Agreed.
Comment 7 Fujii Hironori 2018-01-30 17:17:40 PST
Created attachment 332730 [details]
Patch
Comment 8 WebKit Commit Bot 2018-01-30 20:47:49 PST
Comment on attachment 332730 [details]
Patch

Clearing flags on attachment: 332730

Committed r227872: <https://trac.webkit.org/changeset/227872>
Comment 9 WebKit Commit Bot 2018-01-30 20:47:50 PST
All reviewed patches have been landed.  Closing bug.
Comment 10 Radar WebKit Bug Importer 2018-01-30 20:48:27 PST
<rdar://problem/37055494>