Skip to content

Commit 2fcaf0a

Browse files
tambryCommit Bot
authored and
Commit Bot
committed
Fix null pointer arithmetic, re-enable -Wnull-pointer-arithmetic
Bug: 766891 Change-Id: Ib8cf38fb63d9494f21462ab55ce361775b107322 Reviewed-on: https://chromium-review.googlesource.com/c/1390003 Reviewed-by: Antoine Labour <[email protected]> Reviewed-by: Bill Budge <[email protected]> Reviewed-by: Lambros Lambrou <[email protected]> Reviewed-by: Nico Weber <[email protected]> Commit-Queue: Nico Weber <[email protected]> Cr-Commit-Position: refs/heads/master@{#619731}
1 parent cfd17b5 commit 2fcaf0a

File tree

9 files changed

+22
-25
lines changed

9 files changed

+22
-25
lines changed

build/config/compiler/BUILD.gn

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,9 +1483,6 @@ config("default_warnings") {
14831483
cflags += [
14841484
# TODO(thakis): https://crbug.com/604888
14851485
"-Wno-undefined-var-template",
1486-
1487-
# TODO(hans): https://crbug.com/766891
1488-
"-Wno-null-pointer-arithmetic",
14891486
]
14901487

14911488
if (is_win) {

gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -531,9 +531,7 @@ class GLES2DecoderTestBase : public ::testing::TestWithParam<bool>,
531531
void DoLockDiscardableTextureCHROMIUM(GLuint texture_id);
532532
bool IsDiscardableTextureUnlocked(GLuint texture_id);
533533

534-
GLvoid* BufferOffset(unsigned i) {
535-
return static_cast<int8_t*>(nullptr) + (i);
536-
}
534+
GLvoid* BufferOffset(unsigned i) { return reinterpret_cast<GLvoid*>(i); }
537535

538536
template <typename Command, typename Result>
539537
bool IsObjectHelper(GLuint client_id) {

gpu/command_buffer/service/raster_decoder_unittest_base.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,7 @@ class RasterDecoderTestBase : public ::testing::TestWithParam<bool>,
212212
GLsizei height,
213213
GLuint bound_pixel_unpack_buffer);
214214

215-
GLvoid* BufferOffset(unsigned i) {
216-
return static_cast<int8_t*>(nullptr) + (i);
217-
}
215+
GLvoid* BufferOffset(unsigned i) { return reinterpret_cast<GLvoid*>(i); }
218216

219217
protected:
220218
static const GLint kMaxTextureSize = 2048;

ppapi/examples/media_stream_video/media_stream_video.cc

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,10 @@ void MediaStreamVideoDemoInstance::DrawYUV() {
244244
glEnableVertexAttribArray(pos_location);
245245
glVertexAttribPointer(pos_location, 2, GL_FLOAT, GL_FALSE, 0, 0);
246246
glEnableVertexAttribArray(tc_location);
247-
glVertexAttribPointer(tc_location, 2, GL_FLOAT, GL_FALSE, 0,
248-
static_cast<float*>(0) + 16); // Skip position coordinates.
247+
glVertexAttribPointer(
248+
tc_location, 2, GL_FLOAT, GL_FALSE, 0,
249+
reinterpret_cast<void*>(16 *
250+
sizeof(GLfloat))); // Skip position coordinates.
249251
AssertNoGLError();
250252

251253
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
@@ -263,8 +265,10 @@ void MediaStreamVideoDemoInstance::DrawRGB() {
263265
glEnableVertexAttribArray(pos_location);
264266
glVertexAttribPointer(pos_location, 2, GL_FLOAT, GL_FALSE, 0, 0);
265267
glEnableVertexAttribArray(tc_location);
266-
glVertexAttribPointer(tc_location, 2, GL_FLOAT, GL_FALSE, 0,
267-
static_cast<float*>(0) + 16); // Skip position coordinates.
268+
glVertexAttribPointer(
269+
tc_location, 2, GL_FLOAT, GL_FALSE, 0,
270+
reinterpret_cast<void*>(16 *
271+
sizeof(GLfloat))); // Skip position coordinates.
268272
AssertNoGLError();
269273

270274
glDrawArrays(GL_TRIANGLE_STRIP, 4, 4);

ppapi/examples/video_capture/video_capture.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,8 @@ void VCDemoInstance::CreateGLObjects() {
401401
gles2_if_->EnableVertexAttribArray(context, tc_location);
402402
gles2_if_->VertexAttribPointer(
403403
context, tc_location, 2, GL_FLOAT, GL_FALSE, 0,
404-
static_cast<float*>(0) + 8); // Skip position coordinates.
404+
reinterpret_cast<void*>(8 *
405+
sizeof(GLfloat))); // Skip position coordinates.
405406
AssertNoGLError();
406407
}
407408

ppapi/examples/video_decode/video_decode.cc

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -694,13 +694,9 @@ Shader MyInstance::CreateProgram(const char* vertex_shader,
694694
context_->pp_resource(), pos_location, 2, GL_FLOAT, GL_FALSE, 0, 0);
695695
gles2_if_->EnableVertexAttribArray(context_->pp_resource(), tc_location);
696696
gles2_if_->VertexAttribPointer(
697-
context_->pp_resource(),
698-
tc_location,
699-
2,
700-
GL_FLOAT,
701-
GL_FALSE,
702-
0,
703-
static_cast<float*>(0) + 8); // Skip position coordinates.
697+
context_->pp_resource(), tc_location, 2, GL_FLOAT, GL_FALSE, 0,
698+
reinterpret_cast<void*>(8 *
699+
sizeof(GLfloat))); // Skip position coordinates.
704700

705701
gles2_if_->UseProgram(context_->pp_resource(), 0);
706702
assertNoGLError();

ppapi/examples/video_decode/video_decode_dev.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,8 @@ Shader VideoDecodeDemoInstance::CreateProgram(const char* vertex_shader,
666666
gles2_if_->EnableVertexAttribArray(context_->pp_resource(), tc_location);
667667
gles2_if_->VertexAttribPointer(
668668
context_->pp_resource(), tc_location, 2, GL_FLOAT, GL_FALSE, 0,
669-
static_cast<float*>(0) + 8); // Skip position coordinates.
669+
reinterpret_cast<void*>(8 *
670+
sizeof(GLfloat))); // Skip position coordinates.
670671

671672
gles2_if_->UseProgram(context_->pp_resource(), 0);
672673
assertNoGLError();

remoting/client/display/gl_canvas.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,9 @@ void GlCanvas::DrawTexture(int texture_id,
140140

141141
glVertexAttribPointer(position_location_, kVertexSize, GL_FLOAT, GL_FALSE, 0,
142142
0);
143-
glVertexAttribPointer(tex_cord_location_, kVertexSize, GL_FLOAT, GL_FALSE, 0,
144-
static_cast<float*>(0) + kVertexSize * kVertexCount);
143+
glVertexAttribPointer(
144+
tex_cord_location_, kVertexSize, GL_FLOAT, GL_FALSE, 0,
145+
reinterpret_cast<void*>(kVertexSize * kVertexCount * sizeof(GLfloat)));
145146

146147
glDrawArrays(GL_TRIANGLE_STRIP, 0, kVertexCount);
147148
glBindBuffer(GL_ARRAY_BUFFER, 0);

remoting/client/plugin/pepper_video_renderer_3d.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,8 @@ void PepperVideoRenderer3D::CreateProgram(const char* vertex_shader,
566566
gles2_if_->EnableVertexAttribArray(graphics_3d, tc_location);
567567
gles2_if_->VertexAttribPointer(
568568
graphics_3d, tc_location, 2, GL_FLOAT, GL_FALSE, 0,
569-
static_cast<float*>(0) + 8); // Skip position coordinates.
569+
reinterpret_cast<void*>(8 *
570+
sizeof(GLfloat))); // Skip position coordinates.
570571

571572
gles2_if_->UseProgram(graphics_3d, 0);
572573

0 commit comments

Comments
 (0)