Commit 2fcaf0a1 authored by Raul Tambre's avatar Raul Tambre Committed by Commit Bot

Fix null pointer arithmetic, re-enable -Wnull-pointer-arithmetic

Bug: 766891
Change-Id: Ib8cf38fb63d9494f21462ab55ce361775b107322
Reviewed-on: https://chromium-review.googlesource.com/c/1390003Reviewed-by: default avatarAntoine Labour <piman@chromium.org>
Reviewed-by: default avatarBill Budge <bbudge@chromium.org>
Reviewed-by: default avatarLambros Lambrou <lambroslambrou@chromium.org>
Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Commit-Queue: Nico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#619731}
parent cfd17b53
......@@ -1483,9 +1483,6 @@ config("default_warnings") {
cflags += [
# TODO(thakis): https://crbug.com/604888
"-Wno-undefined-var-template",
# TODO(hans): https://crbug.com/766891
"-Wno-null-pointer-arithmetic",
]
if (is_win) {
......
......@@ -531,9 +531,7 @@ class GLES2DecoderTestBase : public ::testing::TestWithParam<bool>,
void DoLockDiscardableTextureCHROMIUM(GLuint texture_id);
bool IsDiscardableTextureUnlocked(GLuint texture_id);
GLvoid* BufferOffset(unsigned i) {
return static_cast<int8_t*>(nullptr) + (i);
}
GLvoid* BufferOffset(unsigned i) { return reinterpret_cast<GLvoid*>(i); }
template <typename Command, typename Result>
bool IsObjectHelper(GLuint client_id) {
......
......@@ -212,9 +212,7 @@ class RasterDecoderTestBase : public ::testing::TestWithParam<bool>,
GLsizei height,
GLuint bound_pixel_unpack_buffer);
GLvoid* BufferOffset(unsigned i) {
return static_cast<int8_t*>(nullptr) + (i);
}
GLvoid* BufferOffset(unsigned i) { return reinterpret_cast<GLvoid*>(i); }
protected:
static const GLint kMaxTextureSize = 2048;
......
......@@ -244,8 +244,10 @@ void MediaStreamVideoDemoInstance::DrawYUV() {
glEnableVertexAttribArray(pos_location);
glVertexAttribPointer(pos_location, 2, GL_FLOAT, GL_FALSE, 0, 0);
glEnableVertexAttribArray(tc_location);
glVertexAttribPointer(tc_location, 2, GL_FLOAT, GL_FALSE, 0,
static_cast<float*>(0) + 16); // Skip position coordinates.
glVertexAttribPointer(
tc_location, 2, GL_FLOAT, GL_FALSE, 0,
reinterpret_cast<void*>(16 *
sizeof(GLfloat))); // Skip position coordinates.
AssertNoGLError();
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
......@@ -263,8 +265,10 @@ void MediaStreamVideoDemoInstance::DrawRGB() {
glEnableVertexAttribArray(pos_location);
glVertexAttribPointer(pos_location, 2, GL_FLOAT, GL_FALSE, 0, 0);
glEnableVertexAttribArray(tc_location);
glVertexAttribPointer(tc_location, 2, GL_FLOAT, GL_FALSE, 0,
static_cast<float*>(0) + 16); // Skip position coordinates.
glVertexAttribPointer(
tc_location, 2, GL_FLOAT, GL_FALSE, 0,
reinterpret_cast<void*>(16 *
sizeof(GLfloat))); // Skip position coordinates.
AssertNoGLError();
glDrawArrays(GL_TRIANGLE_STRIP, 4, 4);
......
......@@ -401,7 +401,8 @@ void VCDemoInstance::CreateGLObjects() {
gles2_if_->EnableVertexAttribArray(context, tc_location);
gles2_if_->VertexAttribPointer(
context, tc_location, 2, GL_FLOAT, GL_FALSE, 0,
static_cast<float*>(0) + 8); // Skip position coordinates.
reinterpret_cast<void*>(8 *
sizeof(GLfloat))); // Skip position coordinates.
AssertNoGLError();
}
......
......@@ -694,13 +694,9 @@ Shader MyInstance::CreateProgram(const char* vertex_shader,
context_->pp_resource(), pos_location, 2, GL_FLOAT, GL_FALSE, 0, 0);
gles2_if_->EnableVertexAttribArray(context_->pp_resource(), tc_location);
gles2_if_->VertexAttribPointer(
context_->pp_resource(),
tc_location,
2,
GL_FLOAT,
GL_FALSE,
0,
static_cast<float*>(0) + 8); // Skip position coordinates.
context_->pp_resource(), tc_location, 2, GL_FLOAT, GL_FALSE, 0,
reinterpret_cast<void*>(8 *
sizeof(GLfloat))); // Skip position coordinates.
gles2_if_->UseProgram(context_->pp_resource(), 0);
assertNoGLError();
......
......@@ -666,7 +666,8 @@ Shader VideoDecodeDemoInstance::CreateProgram(const char* vertex_shader,
gles2_if_->EnableVertexAttribArray(context_->pp_resource(), tc_location);
gles2_if_->VertexAttribPointer(
context_->pp_resource(), tc_location, 2, GL_FLOAT, GL_FALSE, 0,
static_cast<float*>(0) + 8); // Skip position coordinates.
reinterpret_cast<void*>(8 *
sizeof(GLfloat))); // Skip position coordinates.
gles2_if_->UseProgram(context_->pp_resource(), 0);
assertNoGLError();
......
......@@ -140,8 +140,9 @@ void GlCanvas::DrawTexture(int texture_id,
glVertexAttribPointer(position_location_, kVertexSize, GL_FLOAT, GL_FALSE, 0,
0);
glVertexAttribPointer(tex_cord_location_, kVertexSize, GL_FLOAT, GL_FALSE, 0,
static_cast<float*>(0) + kVertexSize * kVertexCount);
glVertexAttribPointer(
tex_cord_location_, kVertexSize, GL_FLOAT, GL_FALSE, 0,
reinterpret_cast<void*>(kVertexSize * kVertexCount * sizeof(GLfloat)));
glDrawArrays(GL_TRIANGLE_STRIP, 0, kVertexCount);
glBindBuffer(GL_ARRAY_BUFFER, 0);
......
......@@ -566,7 +566,8 @@ void PepperVideoRenderer3D::CreateProgram(const char* vertex_shader,
gles2_if_->EnableVertexAttribArray(graphics_3d, tc_location);
gles2_if_->VertexAttribPointer(
graphics_3d, tc_location, 2, GL_FLOAT, GL_FALSE, 0,
static_cast<float*>(0) + 8); // Skip position coordinates.
reinterpret_cast<void*>(8 *
sizeof(GLfloat))); // Skip position coordinates.
gles2_if_->UseProgram(graphics_3d, 0);
......
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