[cmds] Modernize codebase by replacing NULL with nullptr
Fixes -Wzero-as-null-pointer-constant warning.
Test: m
Bug: 68236239
Change-Id: I73a0a82e3e32001f8ffb0880250c7023dd8290d3
diff --git a/cmds/flatland/GLHelper.cpp b/cmds/flatland/GLHelper.cpp
index d5b3372..62d2fa1 100644
--- a/cmds/flatland/GLHelper.cpp
+++ b/cmds/flatland/GLHelper.cpp
@@ -29,7 +29,7 @@
mContext(EGL_NO_CONTEXT),
mDummySurface(EGL_NO_SURFACE),
mConfig(0),
- mShaderPrograms(NULL),
+ mShaderPrograms(nullptr),
mDitherTexture(0) {
}
@@ -101,12 +101,12 @@
}
void GLHelper::tearDown() {
- if (mShaderPrograms != NULL) {
+ if (mShaderPrograms != nullptr) {
delete[] mShaderPrograms;
- mShaderPrograms = NULL;
+ mShaderPrograms = nullptr;
}
- if (mSurfaceComposerClient != NULL) {
+ if (mSurfaceComposerClient != nullptr) {
mSurfaceComposerClient->dispose();
mSurfaceComposerClient.clear();
}
@@ -210,7 +210,7 @@
glc->setConsumerUsageBits(GRALLOC_USAGE_HW_COMPOSER);
sp<ANativeWindow> anw = new Surface(producer);
- EGLSurface s = eglCreateWindowSurface(mDisplay, mConfig, anw.get(), NULL);
+ EGLSurface s = eglCreateWindowSurface(mDisplay, mConfig, anw.get(), nullptr);
if (s == EGL_NO_SURFACE) {
fprintf(stderr, "eglCreateWindowSurface error: %#x\n", eglGetError());
return false;
@@ -223,7 +223,7 @@
bool GLHelper::computeWindowScale(uint32_t w, uint32_t h, float* scale) {
sp<IBinder> dpy = mSurfaceComposerClient->getBuiltInDisplay(0);
- if (dpy == NULL) {
+ if (dpy == nullptr) {
fprintf(stderr, "SurfaceComposer::getBuiltInDisplay failed.\n");
return false;
}
@@ -247,7 +247,7 @@
bool result;
status_t err;
- if (mSurfaceComposerClient == NULL) {
+ if (mSurfaceComposerClient == nullptr) {
mSurfaceComposerClient = new SurfaceComposerClient;
}
err = mSurfaceComposerClient->initCheck();
@@ -258,7 +258,7 @@
sp<SurfaceControl> sc = mSurfaceComposerClient->createSurface(
String8("Benchmark"), w, h, PIXEL_FORMAT_RGBA_8888, 0);
- if (sc == NULL || !sc->isValid()) {
+ if (sc == nullptr || !sc->isValid()) {
fprintf(stderr, "Failed to create SurfaceControl.\n");
return false;
}
@@ -275,7 +275,7 @@
.apply();
sp<ANativeWindow> anw = sc->getSurface();
- EGLSurface s = eglCreateWindowSurface(mDisplay, mConfig, anw.get(), NULL);
+ EGLSurface s = eglCreateWindowSurface(mDisplay, mConfig, anw.get(), nullptr);
if (s == EGL_NO_SURFACE) {
fprintf(stderr, "eglCreateWindowSurface error: %#x\n", eglGetError());
return false;
@@ -294,7 +294,7 @@
return false;
}
- glShaderSource(shader, 1, &src, NULL);
+ glShaderSource(shader, 1, &src, nullptr);
glCompileShader(shader);
GLint compiled = 0;
@@ -305,7 +305,7 @@
if (infoLen) {
char* buf = new char[infoLen];
if (buf) {
- glGetShaderInfoLog(shader, infoLen, NULL, buf);
+ glGetShaderInfoLog(shader, infoLen, nullptr, buf);
fprintf(stderr, "Shader compile log:\n%s\n", buf);
delete[] buf;
}
@@ -318,21 +318,21 @@
}
static void printShaderSource(const char* const* src) {
- for (size_t i = 0; i < MAX_SHADER_LINES && src[i] != NULL; i++) {
+ for (size_t i = 0; i < MAX_SHADER_LINES && src[i] != nullptr; i++) {
fprintf(stderr, "%3zu: %s\n", i+1, src[i]);
}
}
static const char* makeShaderString(const char* const* src) {
size_t len = 0;
- for (size_t i = 0; i < MAX_SHADER_LINES && src[i] != NULL; i++) {
+ for (size_t i = 0; i < MAX_SHADER_LINES && src[i] != nullptr; i++) {
// The +1 is for the '\n' that will be added.
len += strlen(src[i]) + 1;
}
char* result = new char[len+1];
char* end = result;
- for (size_t i = 0; i < MAX_SHADER_LINES && src[i] != NULL; i++) {
+ for (size_t i = 0; i < MAX_SHADER_LINES && src[i] != nullptr; i++) {
strcpy(end, src[i]);
end += strlen(src[i]);
*end = '\n';
@@ -376,7 +376,7 @@
if (bufLength) {
char* buf = new char[bufLength];
if (buf) {
- glGetProgramInfoLog(program, bufLength, NULL, buf);
+ glGetProgramInfoLog(program, bufLength, nullptr, buf);
fprintf(stderr, "Program link log:\n%s\n", buf);
delete[] buf;
}