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) {
}
void Buffer_Dev::Init() {
if (!get_interface<PPB_Buffer_Dev>()->Describe(pp_resource(), &size_) ||
!(data_ = get_interface<PPB_Buffer_Dev>()->Map(pp_resource()))) {
data_ = NULL;
size_ = 0;
if (get_interface<PPB_Buffer_Dev>()->Describe(pp_resource(), &size_)) {
data_ = get_interface<PPB_Buffer_Dev>()->Map(pp_resource());
if (data_)
return;
}
data_ = NULL;
size_ = 0;
}
} // namespace pp
......@@ -92,9 +92,12 @@ PP_ImageDataFormat ImageData::GetNativeImageDataFormat() {
void ImageData::InitData() {
if (!has_interface<PPB_ImageData_1_0>())
return;
if (!get_interface<PPB_ImageData_1_0>()->Describe(pp_resource(), &desc_) ||
!(data_ = get_interface<PPB_ImageData_1_0>()->Map(pp_resource())))
*this = ImageData();
if (get_interface<PPB_ImageData_1_0>()->Describe(pp_resource(), &desc_)) {
data_ = get_interface<PPB_ImageData_1_0>()->Map(pp_resource());
if (data_)
return;
}
*this = ImageData();
}
} // namespace pp
......@@ -85,11 +85,12 @@ class GLES2DemoInstance : public pp::Instance,
GLES2DemoInstance::GLES2DemoInstance(PP_Instance instance, pp::Module* module)
: pp::Instance(instance), pp::Graphics3DClient(this),
callback_factory_(this),
gles2_if_(static_cast<const PPB_OpenGLES2*>(
module->GetBrowserInterface(PPB_OPENGLES2_INTERFACE))),
module_(module),
context_(NULL),
fullscreen_(false) {
assert((gles2_if_ = static_cast<const PPB_OpenGLES2*>(
module->GetBrowserInterface(PPB_OPENGLES2_INTERFACE))));
assert(gles2_if_);
RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE);
}
......
......@@ -226,13 +226,16 @@ VideoDecodeDemoInstance::VideoDecodeDemoInstance(PP_Instance instance,
first_frame_delivered_ticks_(-1),
swap_ticks_(0),
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) {
assert((console_if_ = static_cast<const PPB_Console*>(
module->GetBrowserInterface(PPB_CONSOLE_INTERFACE))));
assert((core_if_ = static_cast<const PPB_Core*>(
module->GetBrowserInterface(PPB_CORE_INTERFACE))));
assert((gles2_if_ = static_cast<const PPB_OpenGLES2*>(
module->GetBrowserInterface(PPB_OPENGLES2_INTERFACE))));
assert(console_if_);
assert(core_if_);
assert(gles2_if_);
}
VideoDecodeDemoInstance::~VideoDecodeDemoInstance() {
......
......@@ -57,7 +57,7 @@ void PpapiCommandBufferProxy::WaitForTokenInRange(int32 start, int32 end) {
if (last_state_.error != gpu::error::kNoError)
return;
bool success;
bool success = false;
gpu::CommandBuffer::State state;
if (Send(new PpapiHostMsg_PPBGraphics3D_WaitForTokenInRange(
ppapi::API_ID_PPB_GRAPHICS_3D,
......@@ -73,7 +73,7 @@ void PpapiCommandBufferProxy::WaitForGetOffsetInRange(int32 start, int32 end) {
if (last_state_.error != gpu::error::kNoError)
return;
bool success;
bool success = false;
gpu::CommandBuffer::State state;
if (Send(new PpapiHostMsg_PPBGraphics3D_WaitForGetOffsetInRange(
ppapi::API_ID_PPB_GRAPHICS_3D,
......
......@@ -498,7 +498,7 @@ void PPB_Instance_Proxy::ZoomLimitsChanged(PP_Instance instance,
PP_Var PPB_Instance_Proxy::GetDocumentURL(PP_Instance instance,
PP_URLComponents_Dev* components) {
ReceiveSerializedVarReturnValue result;
PP_URLComponents_Dev url_components;
PP_URLComponents_Dev url_components = {{0}};
dispatcher()->Send(new PpapiHostMsg_PPBInstance_GetDocumentURL(
API_ID_PPB_INSTANCE, instance, &url_components, &result));
if (components)
......
......@@ -303,7 +303,7 @@ std::string TestFileMapping::TestBadParameters() {
instance_->pp_instance(),
file_io.pp_resource(),
page_size,
~PP_FILEMAPPROTECTION_READ,
~static_cast<uint32_t>(PP_FILEMAPPROTECTION_READ),
PP_FILEMAPFLAG_PRIVATE,
0,
&address,
......@@ -349,7 +349,7 @@ std::string TestFileMapping::TestBadParameters() {
file_io.pp_resource(),
page_size,
PP_FILEMAPPROTECTION_READ,
~PP_FILEMAPFLAG_SHARED,
~static_cast<uint32_t>(PP_FILEMAPFLAG_SHARED),
0,
&address,
callback.GetCallback().pp_completion_callback()));
......@@ -364,7 +364,7 @@ std::string TestFileMapping::TestBadParameters() {
file_io.pp_resource(),
page_size,
PP_FILEMAPPROTECTION_READ,
~PP_FILEMAPFLAG_SHARED,
~static_cast<uint32_t>(PP_FILEMAPFLAG_SHARED),
1,
&address,
callback.GetCallback().pp_completion_callback()));
......
......@@ -566,7 +566,7 @@ std::string TestGraphics2D::TestReplace() {
dc.ReplaceContents(&weird_size);
// 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::Size(w, h), true);
ASSERT_FALSE(background.is_null());
......
......@@ -17,17 +17,15 @@ typedef EnterResource<PPB_BrowserFont_Trusted_API> EnterBrowserFont;
PP_Var GetFontFamilies(PP_Instance instance) {
EnterInstanceAPI<PPB_BrowserFont_Singleton_API> enter(instance);
if (enter.failed())
return PP_MakeUndefined();
return enter.functions()->GetFontFamilies(instance);
return enter.succeeded() ?
enter.functions()->GetFontFamilies(instance) : PP_MakeUndefined();
}
PP_Resource Create(PP_Instance instance,
const PP_BrowserFont_Trusted_Description* description) {
EnterResourceCreation enter(instance);
if (enter.failed())
return 0;
return enter.functions()->CreateBrowserFont(instance, description);
return enter.succeeded() ?
enter.functions()->CreateBrowserFont(instance, description) : 0;
}
PP_Bool IsBrowserFont(PP_Resource resource) {
......@@ -39,9 +37,8 @@ PP_Bool Describe(PP_Resource font_id,
PP_BrowserFont_Trusted_Description* description,
PP_BrowserFont_Trusted_Metrics* metrics) {
EnterBrowserFont enter(font_id, true);
if (enter.failed())
return PP_FALSE;
return enter.object()->Describe(description, metrics);
return enter.succeeded() ?
enter.object()->Describe(description, metrics) : PP_FALSE;
}
PP_Bool DrawTextAt(PP_Resource font_id,
......@@ -52,36 +49,33 @@ PP_Bool DrawTextAt(PP_Resource font_id,
const PP_Rect* clip,
PP_Bool image_data_is_opaque) {
EnterBrowserFont enter(font_id, true);
if (enter.failed())
return PP_FALSE;
return enter.object()->DrawTextAt(image_data, text, position, color, clip,
image_data_is_opaque);
return enter.succeeded() ?
enter.object()->DrawTextAt(image_data, text, position, color, clip,
image_data_is_opaque) :
PP_FALSE;
}
int32_t MeasureText(PP_Resource font_id,
const PP_BrowserFont_Trusted_TextRun* text) {
EnterBrowserFont enter(font_id, true);
if (enter.failed())
return -1;
return enter.object()->MeasureText(text);
return enter.succeeded() ? enter.object()->MeasureText(text) : -1;
}
uint32_t CharacterOffsetForPixel(PP_Resource font_id,
const PP_BrowserFont_Trusted_TextRun* text,
int32_t pixel_position) {
EnterBrowserFont enter(font_id, true);
if (enter.failed())
return -1;
return enter.object()->CharacterOffsetForPixel(text, pixel_position);
return enter.succeeded() ?
enter.object()->CharacterOffsetForPixel(text, pixel_position) :
0xFFFFFFFF;
}
int32_t PixelOffsetForCharacter(PP_Resource font_id,
const PP_BrowserFont_Trusted_TextRun* text,
uint32_t char_offset) {
EnterBrowserFont enter(font_id, true);
if (enter.failed())
return -1;
return enter.object()->PixelOffsetForCharacter(text, char_offset);
return enter.succeeded() ?
enter.object()->PixelOffsetForCharacter(text, char_offset) : -1;
}
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