From 359132ed5568eee5c7982c217415372738303baa Mon Sep 17 00:00:00 2001 From: jules Date: Tue, 9 Oct 2018 11:42:55 +0100 Subject: [PATCH] More zero -> nullptr fixes --- examples/Assets/Box2DTests/Chain.h | 2 +- examples/Audio/AudioLatencyDemo.h | 6 +++--- examples/GUI/DialogsDemo.h | 3 ++- examples/GUI/OpenGLAppDemo.h | 4 ++-- examples/GUI/OpenGLDemo.h | 4 ++-- examples/GUI/WidgetsDemo.h | 8 ++++---- examples/GUI/WindowsDemo.h | 2 +- examples/Utilities/MultithreadingDemo.h | 2 +- .../juce_blocks_basics/littlefoot/juce_LittleFootRunner.h | 2 +- modules/juce_box2d/juce_box2d.cpp | 3 +++ modules/juce_box2d/juce_box2d.h | 3 +++ modules/juce_opengl/native/juce_OpenGL_osx.h | 2 +- modules/juce_opengl/opengl/juce_OpenGLContext.cpp | 2 +- modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.cpp | 2 +- modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp | 4 ++-- 15 files changed, 28 insertions(+), 21 deletions(-) diff --git a/examples/Assets/Box2DTests/Chain.h b/examples/Assets/Box2DTests/Chain.h index be4d5c9f97..e98390aa90 100644 --- a/examples/Assets/Box2DTests/Chain.h +++ b/examples/Assets/Box2DTests/Chain.h @@ -24,7 +24,7 @@ class Chain : public Test public: Chain() { - b2Body* ground = NULL; + b2Body* ground = {}; { b2BodyDef bd; ground = m_world->CreateBody(&bd); diff --git a/examples/Audio/AudioLatencyDemo.h b/examples/Audio/AudioLatencyDemo.h index 35cf114f3f..45bc329d83 100644 --- a/examples/Audio/AudioLatencyDemo.h +++ b/examples/Audio/AudioLatencyDemo.h @@ -153,7 +153,7 @@ public: auto inputSamp = 0.0f; for (auto j = numInputChannels; --j >= 0;) - if (inputChannelData[j] != 0) + if (inputChannelData[j] != nullptr) inputSamp += inputChannelData[j][i]; recordingBuffer[recordedSampleNum] = inputSamp; @@ -164,7 +164,7 @@ public: auto outputSamp = (playingSampleNum < testSound.getNumSamples()) ? playBuffer[playingSampleNum] : 0.0f; for (auto j = numOutputChannels; --j >= 0;) - if (outputChannelData[j] != 0) + if (outputChannelData[j] != nullptr) outputChannelData[j][i] = outputSamp; ++playingSampleNum; @@ -174,7 +174,7 @@ public: { // We need to clear the output buffers, in case they're full of junk.. for (int i = 0; i < numOutputChannels; ++i) - if (outputChannelData[i] != 0) + if (outputChannelData[i] != nullptr) zeromem (outputChannelData[i], sizeof (float) * (size_t) numSamples); } } diff --git a/examples/GUI/DialogsDemo.h b/examples/GUI/DialogsDemo.h index 67ffdc0bef..a6b1178bfe 100644 --- a/examples/GUI/DialogsDemo.h +++ b/examples/GUI/DialogsDemo.h @@ -235,7 +235,8 @@ private: { AlertWindow::showOkCancelBox (AlertWindow::QuestionIcon, "This is an ok/cancel AlertWindow", "And this is the AlertWindow's message. Blah blah blah blah blah blah blah blah blah blah blah blah blah.", - {}, {}, 0, ModalCallbackFunction::forComponent (alertBoxResultChosen, this)); + {}, {}, {}, + ModalCallbackFunction::forComponent (alertBoxResultChosen, this)); } else if (type == calloutBoxWindow) { diff --git a/examples/GUI/OpenGLAppDemo.h b/examples/GUI/OpenGLAppDemo.h index ce4c503858..e9aa5127c1 100644 --- a/examples/GUI/OpenGLAppDemo.h +++ b/examples/GUI/OpenGLAppDemo.h @@ -236,7 +236,7 @@ private: { if (position.get() != nullptr) { - glContext.extensions.glVertexAttribPointer (position->attributeID, 3, GL_FLOAT, GL_FALSE, sizeof (Vertex), 0); + glContext.extensions.glVertexAttribPointer (position->attributeID, 3, GL_FLOAT, GL_FALSE, sizeof (Vertex), nullptr); glContext.extensions.glEnableVertexAttribArray (position->attributeID); } @@ -325,7 +325,7 @@ private: vertexBuffer->bind(); glAttributes.enable (glContext); - glDrawElements (GL_TRIANGLES, vertexBuffer->numIndices, GL_UNSIGNED_INT, 0); + glDrawElements (GL_TRIANGLES, vertexBuffer->numIndices, GL_UNSIGNED_INT, nullptr); glAttributes.disable (glContext); } } diff --git a/examples/GUI/OpenGLDemo.h b/examples/GUI/OpenGLDemo.h index 1e7f5606b7..d8f3bf5855 100644 --- a/examples/GUI/OpenGLDemo.h +++ b/examples/GUI/OpenGLDemo.h @@ -81,7 +81,7 @@ struct OpenGLDemoClasses { if (position.get() != nullptr) { - openGLContext.extensions.glVertexAttribPointer (position->attributeID, 3, GL_FLOAT, GL_FALSE, sizeof (Vertex), 0); + openGLContext.extensions.glVertexAttribPointer (position->attributeID, 3, GL_FLOAT, GL_FALSE, sizeof (Vertex), nullptr); openGLContext.extensions.glEnableVertexAttribArray (position->attributeID); } @@ -173,7 +173,7 @@ struct OpenGLDemoClasses vertexBuffer->bind(); attributes.enable (openGLContext); - glDrawElements (GL_TRIANGLES, vertexBuffer->numIndices, GL_UNSIGNED_INT, 0); + glDrawElements (GL_TRIANGLES, vertexBuffer->numIndices, GL_UNSIGNED_INT, nullptr); attributes.disable (openGLContext); } } diff --git a/examples/GUI/WidgetsDemo.h b/examples/GUI/WidgetsDemo.h index 6477b194ba..87ab0453b3 100644 --- a/examples/GUI/WidgetsDemo.h +++ b/examples/GUI/WidgetsDemo.h @@ -292,7 +292,7 @@ struct ButtonsPage : public Component over.setStrokeThickness (4.0f); auto* db = addToList (new DrawableButton (String (i + 5) + " points", DrawableButton::ImageAboveTextLabel)); - db->setImages (&normal, &over, 0); + db->setImages (&normal, &over, nullptr); db->setClickingTogglesState (true); db->setRadioGroupId (23456); @@ -391,7 +391,7 @@ struct ButtonsPage : public Component { // create an image-on-button-shape button from the same drawables.. auto db = addToList (new DrawableButton ("Button 3", DrawableButton::ImageOnButtonBackground)); - db->setImages (&normal, 0, 0); + db->setImages (&normal, nullptr, nullptr); db->setBounds (260, 160, 110, 25); db->setTooltip ("This is a DrawableButton on a standard button background"); db->onClick = popupMessageCallback; @@ -636,7 +636,7 @@ private: { auto* drawable = new DrawableImage(); drawable->setImage (getImageFromAssets ("juce_icon.png")); - return new ToolbarButton (itemId, "juce!", drawable, 0); + return new ToolbarButton (itemId, "juce!", drawable, nullptr); } case customComboBox: return new CustomToolbarComboBox (itemId); default: break; @@ -671,7 +671,7 @@ private: } auto* image = iconsFromZipFile[iconNames.indexOf (filename)]->createCopy(); - return new ToolbarButton (itemId, text, image, 0); + return new ToolbarButton (itemId, text, image, nullptr); } // Demonstrates how to put a custom component into a toolbar - this one contains diff --git a/examples/GUI/WindowsDemo.h b/examples/GUI/WindowsDemo.h index 752954eb64..3bd58bf01c 100644 --- a/examples/GUI/WindowsDemo.h +++ b/examples/GUI/WindowsDemo.h @@ -180,7 +180,7 @@ public: void mouseDrag (const MouseEvent& e) override { // as there's no titlebar we have to manage the dragging ourselves - dragger.dragComponent (this, e, 0); + dragger.dragComponent (this, e, nullptr); } void paint (Graphics& g) override diff --git a/examples/Utilities/MultithreadingDemo.h b/examples/Utilities/MultithreadingDemo.h index 4d5c21b66a..3a33500587 100644 --- a/examples/Utilities/MultithreadingDemo.h +++ b/examples/Utilities/MultithreadingDemo.h @@ -122,7 +122,7 @@ private: parentWidth = 50.0f, parentHeight = 50.0f; Colour colour; - Thread::ThreadID threadId = 0; + Thread::ThreadID threadId = {}; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (BouncingBallComp) }; diff --git a/modules/juce_blocks_basics/littlefoot/juce_LittleFootRunner.h b/modules/juce_blocks_basics/littlefoot/juce_LittleFootRunner.h index 8db41557af..1a715808b4 100644 --- a/modules/juce_blocks_basics/littlefoot/juce_LittleFootRunner.h +++ b/modules/juce_blocks_basics/littlefoot/juce_LittleFootRunner.h @@ -382,7 +382,7 @@ struct Program //============================================================================== static constexpr uint32 programHeaderSize = 10; - const uint8* programStart = 0; + const uint8* programStart = nullptr; const uint32 maxProgramSize; private: diff --git a/modules/juce_box2d/juce_box2d.cpp b/modules/juce_box2d/juce_box2d.cpp index fb6acae8a2..a6a948bac8 100644 --- a/modules/juce_box2d/juce_box2d.cpp +++ b/modules/juce_box2d/juce_box2d.cpp @@ -37,6 +37,9 @@ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wsign-conversion" #pragma clang diagnostic ignored "-Wfloat-conversion" + #if __has_warning("-Wzero-as-null-pointer-constant") + #pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant" + #endif #elif defined (__GNUC__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-but-set-variable" diff --git a/modules/juce_box2d/juce_box2d.h b/modules/juce_box2d/juce_box2d.h index d8d477a0cf..ba6cc5e4f9 100644 --- a/modules/juce_box2d/juce_box2d.h +++ b/modules/juce_box2d/juce_box2d.h @@ -57,6 +57,9 @@ #ifdef __GNUC__ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" + #if __has_warning("-Wzero-as-null-pointer-constant") + #pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant" + #endif #endif #include diff --git a/modules/juce_opengl/native/juce_OpenGL_osx.h b/modules/juce_opengl/native/juce_OpenGL_osx.h index e14ccedf64..651b4f88f1 100644 --- a/modules/juce_opengl/native/juce_OpenGL_osx.h +++ b/modules/juce_opengl/native/juce_OpenGL_osx.h @@ -247,7 +247,7 @@ public: //============================================================================== bool OpenGLHelpers::isContextActive() { - return CGLGetCurrentContext() != 0; + return CGLGetCurrentContext() != CGLContextObj(); } } // namespace juce diff --git a/modules/juce_opengl/opengl/juce_OpenGLContext.cpp b/modules/juce_opengl/opengl/juce_OpenGLContext.cpp index ce673092f7..aef2086e1e 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLContext.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLContext.cpp @@ -1196,7 +1196,7 @@ void OpenGLContext::copyTexture (const Rectangle& targetClipArea, extensions.glBufferData (GL_ARRAY_BUFFER, sizeof (vertices), vertices, GL_STATIC_DRAW); auto index = (GLuint) program.params.positionAttribute.attributeID; - extensions.glVertexAttribPointer (index, 2, GL_SHORT, GL_FALSE, 4, 0); + extensions.glVertexAttribPointer (index, 2, GL_SHORT, GL_FALSE, 4, nullptr); extensions.glEnableVertexAttribArray (index); JUCE_CHECK_OPENGL_ERROR diff --git a/modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.cpp b/modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.cpp index 824fbb8189..e92f7a8233 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.cpp @@ -58,7 +58,7 @@ public: glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); JUCE_CHECK_OPENGL_ERROR - glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); + glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); JUCE_CHECK_OPENGL_ERROR context.extensions.glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textureID, 0); diff --git a/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp b/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp index 6ba36a42e9..6731ef9f44 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp @@ -422,7 +422,7 @@ struct ShaderPrograms : public ReferenceCountedObject void bindAttributes (OpenGLContext& context) { - context.extensions.glVertexAttribPointer ((GLuint) positionAttribute.attributeID, 2, GL_SHORT, GL_FALSE, 8, (void*) 0); + context.extensions.glVertexAttribPointer ((GLuint) positionAttribute.attributeID, 2, GL_SHORT, GL_FALSE, 8, nullptr); context.extensions.glVertexAttribPointer ((GLuint) colourAttribute.attributeID, 4, GL_UNSIGNED_BYTE, GL_TRUE, 8, (void*) 4); context.extensions.glEnableVertexAttribArray ((GLuint) positionAttribute.attributeID); context.extensions.glEnableVertexAttribArray ((GLuint) colourAttribute.attributeID); @@ -1279,7 +1279,7 @@ struct StateHelpers context.extensions.glBufferSubData (GL_ARRAY_BUFFER, 0, (GLsizeiptr) ((size_t) numVertices * sizeof (VertexInfo)), vertexData); // NB: If you get a random crash in here and are running in a Parallels VM, it seems to be a bug in // their driver.. Can't find a workaround unfortunately. - glDrawElements (GL_TRIANGLES, (numVertices * 3) / 2, GL_UNSIGNED_SHORT, 0); + glDrawElements (GL_TRIANGLES, (numVertices * 3) / 2, GL_UNSIGNED_SHORT, nullptr); JUCE_CHECK_OPENGL_ERROR numVertices = 0; }