Bug 193271 - [Win][MiniBrowser] wchar_t strings shouldn't be treated as BSTR
Summary: [Win][MiniBrowser] wchar_t strings shouldn't be treated as BSTR
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Fujii Hironori
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2019-01-08 20:26 PST by Fujii Hironori
Modified: 2019-01-09 18:09 PST (History)
7 users (show)

See Also:


Attachments
Patch (2.05 KB, patch)
2019-01-08 20:45 PST, Fujii Hironori
no flags Details | Formatted Diff | Diff
Patch (2.78 KB, patch)
2019-01-08 20:54 PST, Fujii Hironori
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Fujii Hironori 2019-01-08 20:26:54 PST
[Win][WebKitLegacy] wchar_t strings shouldn't be treated as BSTR

BSTR | Microsoft Docs
https://docs.microsoft.com/en-us/previous-versions/windows/desktop/automat/bstr

> A BSTR is a composite data type that consists of a length prefix, a data string, and a terminator.

> The following code is incorrect:
> 
>   BSTR MyBstr = L"I am a happy BSTR";
Comment 1 Fujii Hironori 2019-01-08 20:31:12 PST
clang-cl reports the following warnings:

> ..\..\Tools\MiniBrowser\win\MiniBrowserWebHost.cpp(170,38):  warning: ISO C++11 does not allow conversion from string literal to 'BSTR' (aka 'wchar_t *') [-Wwritable-strings]
>     HRESULT hr = doc->getElementById(L"webkit logo", &element.GetInterfacePtr());
>                                      ^
> ..\..\Tools\MiniBrowser\win\MiniBrowserWebHost.cpp(178,70):  warning: ISO C++11 does not allow conversion from string literal to 'LPWSTR' (aka 'wchar_t *') [-Wwritable-strings]
>     hr = target->addEventListener(L"click", new SimpleEventListener (L"webkit logo click"), FALSE);
>                                                                      ^
> ..\..\Tools\MiniBrowser\win\MiniBrowserWebHost.cpp(178,35):  warning: ISO C++11 does not allow conversion from string literal to 'BSTR' (aka 'wchar_t *') [-Wwritable-strings]
>     hr = target->addEventListener(L"click", new SimpleEventListener (L"webkit logo click"), FALSE);
>                                   ^
Comment 2 Fujii Hironori 2019-01-08 20:45:33 PST
Created attachment 358665 [details]
Patch
Comment 3 Fujii Hironori 2019-01-08 20:54:57 PST
Created attachment 358668 [details]
Patch
Comment 4 Brent Fulgham 2019-01-08 20:59:20 PST
Comment on attachment 358668 [details]
Patch

r=me
Comment 5 Fujii Hironori 2019-01-09 18:06:07 PST
Comment on attachment 358668 [details]
Patch

Clearing flags on attachment: 358668

Committed r239812: <https://trac.webkit.org/changeset/239812>
Comment 6 Fujii Hironori 2019-01-09 18:06:09 PST
All reviewed patches have been landed.  Closing bug.
Comment 7 Radar WebKit Bug Importer 2019-01-09 18:09:29 PST
<rdar://problem/47166229>