diff options
| author | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-23 22:04:53 +0000 |
|---|---|---|
| committer | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-23 22:04:53 +0000 |
| commit | 900634e0e697f152b54c2783cc1d6f325695caf5 (patch) | |
| tree | 80e2d12223175bfdd16c53398497647b9f827bfb /printing | |
| parent | c8680d6ef7d3dd49752859cc95a1867214135bd7 (diff) | |
| download | chromium_src-900634e0e697f152b54c2783cc1d6f325695caf5.zip chromium_src-900634e0e697f152b54c2783cc1d6f325695caf5.tar.gz chromium_src-900634e0e697f152b54c2783cc1d6f325695caf5.tar.bz2 | |
clang/win: Fix most -Wwriteable-strings warnings.
Many win32 APIs take non-const string pointers. I checked that MSDN documents
them as _In_ and says that they are inputs, and then added const_cast<>s at
the calling sites. (In one test, I introduced a helper struct so that there
can be fewer casts.)
This wasn't just busywork, I found one function that we were handing string
literals where the documentation explicitly said that that's not valid
(filed http://crbug.com/396705).
I didn't change the DECLARE_REGISTRY_APPID_RESOURCEID() call in cloud_print;
it sounds like that'll fix itself when we update to the 2014 sdk:
http://connect.microsoft.com/VisualStudio/feedback/details/806376/atl-hindrances-to-adopting-new-strictstrings-conformance-option-in-vs2013
BUG=396705,82385
R=rnk@chromium.org, rsleevi@chromium.org, sergeyu@chromium.org, vitalybuka@chromium.org
Review URL: https://codereview.chromium.org/413763003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@285051 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'printing')
| -rw-r--r-- | printing/backend/win_helper.cc | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/printing/backend/win_helper.cc b/printing/backend/win_helper.cc index ac5892b..6aba7c6 100644 --- a/printing/backend/win_helper.cc +++ b/printing/backend/win_helper.cc @@ -472,14 +472,18 @@ scoped_ptr<DEVMODE, base::FreeDeleter> CreateDevModeWithColor( scoped_ptr<DEVMODE, base::FreeDeleter> CreateDevMode(HANDLE printer, DEVMODE* in) { - LONG buffer_size = DocumentProperties(NULL, printer, L"", NULL, NULL, 0); + LONG buffer_size = DocumentProperties( + NULL, printer, const_cast<wchar_t*>(L""), NULL, NULL, 0); if (buffer_size < static_cast<int>(sizeof(DEVMODE))) return scoped_ptr<DEVMODE, base::FreeDeleter>(); scoped_ptr<DEVMODE, base::FreeDeleter> out( reinterpret_cast<DEVMODE*>(malloc(buffer_size))); DWORD flags = (in ? (DM_IN_BUFFER) : 0) | DM_OUT_BUFFER; - if (DocumentProperties(NULL, printer, L"", out.get(), in, flags) != IDOK) + if (DocumentProperties( + NULL, printer, const_cast<wchar_t*>(L""), out.get(), in, flags) != + IDOK) { return scoped_ptr<DEVMODE, base::FreeDeleter>(); + } CHECK_GE(buffer_size, out.get()->dmSize + out.get()->dmDriverExtra); return out.Pass(); } |
