Commit 1337d80c authored by pkasting@chromium.org's avatar pkasting@chromium.org

Fixes for re-enabling more MSVC level 4 warnings: ppapi/ edition

This contains fixes for the following sorts of issues:
* Assignment inside conditional
* Possibly-uninitialized local variable
* Signedness mismatch

This also contains a small number of other cleanups/simplifications to nearby
code.

BUG=81439
TEST=none
R=teravest@chromium.org

Review URL: https://codereview.chromium.org/375133003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@282133 0039d316-1c4b-4281-b951-d872f2087c98
parent ae79184f
...@@ -59,11 +59,13 @@ Buffer_Dev& Buffer_Dev::operator=(const Buffer_Dev& rhs) { ...@@ -59,11 +59,13 @@ Buffer_Dev& Buffer_Dev::operator=(const Buffer_Dev& rhs) {
} }
void Buffer_Dev::Init() { void Buffer_Dev::Init() {
if (!get_interface<PPB_Buffer_Dev>()->Describe(pp_resource(), &size_) || if (get_interface<PPB_Buffer_Dev>()->Describe(pp_resource(), &size_)) {
!(data_ = get_interface<PPB_Buffer_Dev>()->Map(pp_resource()))) { data_ = get_interface<PPB_Buffer_Dev>()->Map(pp_resource());
data_ = NULL; if (data_)
size_ = 0; return;
} }
data_ = NULL;
size_ = 0;
} }
} // namespace pp } // namespace pp
...@@ -92,9 +92,12 @@ PP_ImageDataFormat ImageData::GetNativeImageDataFormat() { ...@@ -92,9 +92,12 @@ PP_ImageDataFormat ImageData::GetNativeImageDataFormat() {
void ImageData::InitData() { void ImageData::InitData() {
if (!has_interface<PPB_ImageData_1_0>()) if (!has_interface<PPB_ImageData_1_0>())
return; return;
if (!get_interface<PPB_ImageData_1_0>()->Describe(pp_resource(), &desc_) || if (get_interface<PPB_ImageData_1_0>()->Describe(pp_resource(), &desc_)) {
!(data_ = get_interface<PPB_ImageData_1_0>()->Map(pp_resource()))) data_ = get_interface<PPB_ImageData_1_0>()->Map(pp_resource());
*this = ImageData(); if (data_)
return;
}
*this = ImageData();
} }
} // namespace pp } // namespace pp
...@@ -85,11 +85,12 @@ class GLES2DemoInstance : public pp::Instance, ...@@ -85,11 +85,12 @@ class GLES2DemoInstance : public pp::Instance,
GLES2DemoInstance::GLES2DemoInstance(PP_Instance instance, pp::Module* module) GLES2DemoInstance::GLES2DemoInstance(PP_Instance instance, pp::Module* module)
: pp::Instance(instance), pp::Graphics3DClient(this), : pp::Instance(instance), pp::Graphics3DClient(this),
callback_factory_(this), callback_factory_(this),
gles2_if_(static_cast<const PPB_OpenGLES2*>(
module->GetBrowserInterface(PPB_OPENGLES2_INTERFACE))),
module_(module), module_(module),
context_(NULL), context_(NULL),
fullscreen_(false) { fullscreen_(false) {
assert((gles2_if_ = static_cast<const PPB_OpenGLES2*>( assert(gles2_if_);
module->GetBrowserInterface(PPB_OPENGLES2_INTERFACE))));
RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE); RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE);
} }
......
...@@ -226,13 +226,16 @@ VideoDecodeDemoInstance::VideoDecodeDemoInstance(PP_Instance instance, ...@@ -226,13 +226,16 @@ VideoDecodeDemoInstance::VideoDecodeDemoInstance(PP_Instance instance,
first_frame_delivered_ticks_(-1), first_frame_delivered_ticks_(-1),
swap_ticks_(0), swap_ticks_(0),
callback_factory_(this), callback_factory_(this),
console_if_(static_cast<const PPB_Console*>(
module->GetBrowserInterface(PPB_CONSOLE_INTERFACE))),
core_if_(static_cast<const PPB_Core*>(
module->GetBrowserInterface(PPB_CORE_INTERFACE))),
gles2_if_(static_cast<const PPB_OpenGLES2*>(
module->GetBrowserInterface(PPB_OPENGLES2_INTERFACE))),
context_(NULL) { context_(NULL) {
assert((console_if_ = static_cast<const PPB_Console*>( assert(console_if_);
module->GetBrowserInterface(PPB_CONSOLE_INTERFACE)))); assert(core_if_);
assert((core_if_ = static_cast<const PPB_Core*>( assert(gles2_if_);
module->GetBrowserInterface(PPB_CORE_INTERFACE))));
assert((gles2_if_ = static_cast<const PPB_OpenGLES2*>(
module->GetBrowserInterface(PPB_OPENGLES2_INTERFACE))));
} }
VideoDecodeDemoInstance::~VideoDecodeDemoInstance() { VideoDecodeDemoInstance::~VideoDecodeDemoInstance() {
......
...@@ -57,7 +57,7 @@ void PpapiCommandBufferProxy::WaitForTokenInRange(int32 start, int32 end) { ...@@ -57,7 +57,7 @@ void PpapiCommandBufferProxy::WaitForTokenInRange(int32 start, int32 end) {
if (last_state_.error != gpu::error::kNoError) if (last_state_.error != gpu::error::kNoError)
return; return;
bool success; bool success = false;
gpu::CommandBuffer::State state; gpu::CommandBuffer::State state;
if (Send(new PpapiHostMsg_PPBGraphics3D_WaitForTokenInRange( if (Send(new PpapiHostMsg_PPBGraphics3D_WaitForTokenInRange(
ppapi::API_ID_PPB_GRAPHICS_3D, ppapi::API_ID_PPB_GRAPHICS_3D,
...@@ -73,7 +73,7 @@ void PpapiCommandBufferProxy::WaitForGetOffsetInRange(int32 start, int32 end) { ...@@ -73,7 +73,7 @@ void PpapiCommandBufferProxy::WaitForGetOffsetInRange(int32 start, int32 end) {
if (last_state_.error != gpu::error::kNoError) if (last_state_.error != gpu::error::kNoError)
return; return;
bool success; bool success = false;
gpu::CommandBuffer::State state; gpu::CommandBuffer::State state;
if (Send(new PpapiHostMsg_PPBGraphics3D_WaitForGetOffsetInRange( if (Send(new PpapiHostMsg_PPBGraphics3D_WaitForGetOffsetInRange(
ppapi::API_ID_PPB_GRAPHICS_3D, ppapi::API_ID_PPB_GRAPHICS_3D,
......
...@@ -498,7 +498,7 @@ void PPB_Instance_Proxy::ZoomLimitsChanged(PP_Instance instance, ...@@ -498,7 +498,7 @@ void PPB_Instance_Proxy::ZoomLimitsChanged(PP_Instance instance,
PP_Var PPB_Instance_Proxy::GetDocumentURL(PP_Instance instance, PP_Var PPB_Instance_Proxy::GetDocumentURL(PP_Instance instance,
PP_URLComponents_Dev* components) { PP_URLComponents_Dev* components) {
ReceiveSerializedVarReturnValue result; ReceiveSerializedVarReturnValue result;
PP_URLComponents_Dev url_components; PP_URLComponents_Dev url_components = {{0}};
dispatcher()->Send(new PpapiHostMsg_PPBInstance_GetDocumentURL( dispatcher()->Send(new PpapiHostMsg_PPBInstance_GetDocumentURL(
API_ID_PPB_INSTANCE, instance, &url_components, &result)); API_ID_PPB_INSTANCE, instance, &url_components, &result));
if (components) if (components)
......
...@@ -303,7 +303,7 @@ std::string TestFileMapping::TestBadParameters() { ...@@ -303,7 +303,7 @@ std::string TestFileMapping::TestBadParameters() {
instance_->pp_instance(), instance_->pp_instance(),
file_io.pp_resource(), file_io.pp_resource(),
page_size, page_size,
~PP_FILEMAPPROTECTION_READ, ~static_cast<uint32_t>(PP_FILEMAPPROTECTION_READ),
PP_FILEMAPFLAG_PRIVATE, PP_FILEMAPFLAG_PRIVATE,
0, 0,
&address, &address,
...@@ -349,7 +349,7 @@ std::string TestFileMapping::TestBadParameters() { ...@@ -349,7 +349,7 @@ std::string TestFileMapping::TestBadParameters() {
file_io.pp_resource(), file_io.pp_resource(),
page_size, page_size,
PP_FILEMAPPROTECTION_READ, PP_FILEMAPPROTECTION_READ,
~PP_FILEMAPFLAG_SHARED, ~static_cast<uint32_t>(PP_FILEMAPFLAG_SHARED),
0, 0,
&address, &address,
callback.GetCallback().pp_completion_callback())); callback.GetCallback().pp_completion_callback()));
...@@ -364,7 +364,7 @@ std::string TestFileMapping::TestBadParameters() { ...@@ -364,7 +364,7 @@ std::string TestFileMapping::TestBadParameters() {
file_io.pp_resource(), file_io.pp_resource(),
page_size, page_size,
PP_FILEMAPPROTECTION_READ, PP_FILEMAPPROTECTION_READ,
~PP_FILEMAPFLAG_SHARED, ~static_cast<uint32_t>(PP_FILEMAPFLAG_SHARED),
1, 1,
&address, &address,
callback.GetCallback().pp_completion_callback())); callback.GetCallback().pp_completion_callback()));
......
...@@ -566,7 +566,7 @@ std::string TestGraphics2D::TestReplace() { ...@@ -566,7 +566,7 @@ std::string TestGraphics2D::TestReplace() {
dc.ReplaceContents(&weird_size); dc.ReplaceContents(&weird_size);
// Fill the background with blue but don't flush yet. // Fill the background with blue but don't flush yet.
const int32_t background_color = 0xFF0000FF; const uint32_t background_color = 0xFF0000FF;
pp::ImageData background(instance_, PP_IMAGEDATAFORMAT_BGRA_PREMUL, pp::ImageData background(instance_, PP_IMAGEDATAFORMAT_BGRA_PREMUL,
pp::Size(w, h), true); pp::Size(w, h), true);
ASSERT_FALSE(background.is_null()); ASSERT_FALSE(background.is_null());
......
...@@ -17,17 +17,15 @@ typedef EnterResource<PPB_BrowserFont_Trusted_API> EnterBrowserFont; ...@@ -17,17 +17,15 @@ typedef EnterResource<PPB_BrowserFont_Trusted_API> EnterBrowserFont;
PP_Var GetFontFamilies(PP_Instance instance) { PP_Var GetFontFamilies(PP_Instance instance) {
EnterInstanceAPI<PPB_BrowserFont_Singleton_API> enter(instance); EnterInstanceAPI<PPB_BrowserFont_Singleton_API> enter(instance);
if (enter.failed()) return enter.succeeded() ?
return PP_MakeUndefined(); enter.functions()->GetFontFamilies(instance) : PP_MakeUndefined();
return enter.functions()->GetFontFamilies(instance);
} }
PP_Resource Create(PP_Instance instance, PP_Resource Create(PP_Instance instance,
const PP_BrowserFont_Trusted_Description* description) { const PP_BrowserFont_Trusted_Description* description) {
EnterResourceCreation enter(instance); EnterResourceCreation enter(instance);
if (enter.failed()) return enter.succeeded() ?
return 0; enter.functions()->CreateBrowserFont(instance, description) : 0;
return enter.functions()->CreateBrowserFont(instance, description);
} }
PP_Bool IsBrowserFont(PP_Resource resource) { PP_Bool IsBrowserFont(PP_Resource resource) {
...@@ -39,9 +37,8 @@ PP_Bool Describe(PP_Resource font_id, ...@@ -39,9 +37,8 @@ PP_Bool Describe(PP_Resource font_id,
PP_BrowserFont_Trusted_Description* description, PP_BrowserFont_Trusted_Description* description,
PP_BrowserFont_Trusted_Metrics* metrics) { PP_BrowserFont_Trusted_Metrics* metrics) {
EnterBrowserFont enter(font_id, true); EnterBrowserFont enter(font_id, true);
if (enter.failed()) return enter.succeeded() ?
return PP_FALSE; enter.object()->Describe(description, metrics) : PP_FALSE;
return enter.object()->Describe(description, metrics);
} }
PP_Bool DrawTextAt(PP_Resource font_id, PP_Bool DrawTextAt(PP_Resource font_id,
...@@ -52,36 +49,33 @@ PP_Bool DrawTextAt(PP_Resource font_id, ...@@ -52,36 +49,33 @@ PP_Bool DrawTextAt(PP_Resource font_id,
const PP_Rect* clip, const PP_Rect* clip,
PP_Bool image_data_is_opaque) { PP_Bool image_data_is_opaque) {
EnterBrowserFont enter(font_id, true); EnterBrowserFont enter(font_id, true);
if (enter.failed()) return enter.succeeded() ?
return PP_FALSE; enter.object()->DrawTextAt(image_data, text, position, color, clip,
return enter.object()->DrawTextAt(image_data, text, position, color, clip, image_data_is_opaque) :
image_data_is_opaque); PP_FALSE;
} }
int32_t MeasureText(PP_Resource font_id, int32_t MeasureText(PP_Resource font_id,
const PP_BrowserFont_Trusted_TextRun* text) { const PP_BrowserFont_Trusted_TextRun* text) {
EnterBrowserFont enter(font_id, true); EnterBrowserFont enter(font_id, true);
if (enter.failed()) return enter.succeeded() ? enter.object()->MeasureText(text) : -1;
return -1;
return enter.object()->MeasureText(text);
} }
uint32_t CharacterOffsetForPixel(PP_Resource font_id, uint32_t CharacterOffsetForPixel(PP_Resource font_id,
const PP_BrowserFont_Trusted_TextRun* text, const PP_BrowserFont_Trusted_TextRun* text,
int32_t pixel_position) { int32_t pixel_position) {
EnterBrowserFont enter(font_id, true); EnterBrowserFont enter(font_id, true);
if (enter.failed()) return enter.succeeded() ?
return -1; enter.object()->CharacterOffsetForPixel(text, pixel_position) :
return enter.object()->CharacterOffsetForPixel(text, pixel_position); 0xFFFFFFFF;
} }
int32_t PixelOffsetForCharacter(PP_Resource font_id, int32_t PixelOffsetForCharacter(PP_Resource font_id,
const PP_BrowserFont_Trusted_TextRun* text, const PP_BrowserFont_Trusted_TextRun* text,
uint32_t char_offset) { uint32_t char_offset) {
EnterBrowserFont enter(font_id, true); EnterBrowserFont enter(font_id, true);
if (enter.failed()) return enter.succeeded() ?
return -1; enter.object()->PixelOffsetForCharacter(text, char_offset) : -1;
return enter.object()->PixelOffsetForCharacter(text, char_offset);
} }
const PPB_BrowserFont_Trusted_1_0 g_ppb_browser_font_trusted_thunk = { const PPB_BrowserFont_Trusted_1_0 g_ppb_browser_font_trusted_thunk = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment