clang-tidy: modernize-use-nullptr (NFC)

This commit is contained in:
Peter Johnson
2020-12-28 10:52:52 -08:00
parent aee4603269
commit 32fa97d68d
10 changed files with 23 additions and 23 deletions

View File

@@ -79,7 +79,7 @@ static void ListenerOnExit() {
/// throw java exception
static void ThrowJavaException(JNIEnv* env, const std::exception* e) {
wpi::SmallString<128> what;
jclass je = 0;
jclass je = nullptr;
if (e) {
const char* exception_type = "std::exception";
@@ -1198,7 +1198,7 @@ Java_edu_wpi_cscore_CameraServerCvJNI_putSourceFrame
} catch (const std::exception& e) {
ThrowJavaException(env, &e);
} catch (...) {
ThrowJavaException(env, 0);
ThrowJavaException(env, nullptr);
}
}
@@ -1673,7 +1673,7 @@ Java_edu_wpi_cscore_CameraServerCvJNI_grabSinkFrame
ThrowJavaException(env, &e);
return 0;
} catch (...) {
ThrowJavaException(env, 0);
ThrowJavaException(env, nullptr);
return 0;
}
}
@@ -1697,7 +1697,7 @@ Java_edu_wpi_cscore_CameraServerCvJNI_grabSinkFrameTimeout
ThrowJavaException(env, &e);
return 0;
} catch (...) {
ThrowJavaException(env, 0);
ThrowJavaException(env, nullptr);
return 0;
}
}

View File

@@ -42,7 +42,7 @@ Java_edu_wpi_first_hal_I2CJNI_i2CTransaction
jbyte sendSize, jobject dataReceived, jbyte receiveSize)
{
uint8_t* dataToSendPtr = nullptr;
if (dataToSend != 0) {
if (dataToSend != nullptr) {
dataToSendPtr =
reinterpret_cast<uint8_t*>(env->GetDirectBufferAddress(dataToSend));
}
@@ -88,7 +88,7 @@ Java_edu_wpi_first_hal_I2CJNI_i2CWrite
{
uint8_t* dataToSendPtr = nullptr;
if (dataToSend != 0) {
if (dataToSend != nullptr) {
dataToSendPtr =
reinterpret_cast<uint8_t*>(env->GetDirectBufferAddress(dataToSend));
}

View File

@@ -271,12 +271,12 @@ Java_edu_wpi_first_hal_InterruptJNI_attachInterruptHandler
(JNIEnv* env, jclass, jint interruptHandle, jobject handler, jobject param)
{
jclass cls = env->GetObjectClass(handler);
if (cls == 0) {
if (cls == nullptr) {
assert(false);
return;
}
jmethodID mid = env->GetMethodID(cls, "apply", "(ILjava/lang/Object;)V");
if (mid == 0) {
if (mid == nullptr) {
assert(false);
return;
}

View File

@@ -42,7 +42,7 @@ Java_edu_wpi_first_hal_SPIJNI_spiTransaction
jbyte size)
{
uint8_t* dataToSendPtr = nullptr;
if (dataToSend != 0) {
if (dataToSend != nullptr) {
dataToSendPtr =
reinterpret_cast<uint8_t*>(env->GetDirectBufferAddress(dataToSend));
}
@@ -85,7 +85,7 @@ Java_edu_wpi_first_hal_SPIJNI_spiWrite
(JNIEnv* env, jclass, jint port, jobject dataToSend, jbyte size)
{
uint8_t* dataToSendPtr = nullptr;
if (dataToSend != 0) {
if (dataToSend != nullptr) {
dataToSendPtr =
reinterpret_cast<uint8_t*>(env->GetDirectBufferAddress(dataToSend));
}

View File

@@ -128,12 +128,12 @@ void HAL_SetAnalogTriggerLimitsRaw(HAL_AnalogTriggerHandle analogTriggerHandle,
double trigLower =
GetAnalogValueToVoltage(trigger->analogHandle, lower, status);
if (status != 0) {
if (status != nullptr) {
return;
}
double trigUpper =
GetAnalogValueToVoltage(trigger->analogHandle, upper, status);
if (status != 0) {
if (status != nullptr) {
return;
}

View File

@@ -39,14 +39,14 @@ bool HALSimWS::Initialize() {
}
const char* host = std::getenv("HALSIMWS_HOST");
if (host != NULL) {
if (host != nullptr) {
m_host = host;
} else {
m_host = "localhost";
}
const char* port = std::getenv("HALSIMWS_PORT");
if (port != NULL) {
if (port != nullptr) {
try {
m_port = std::stoi(port);
} catch (const std::invalid_argument& err) {
@@ -58,7 +58,7 @@ bool HALSimWS::Initialize() {
}
const char* uri = std::getenv("HALSIMWS_URI");
if (uri != NULL) {
if (uri != nullptr) {
m_uri = uri;
} else {
m_uri = "/wpilibws";

View File

@@ -46,7 +46,7 @@ bool HALSimWeb::Initialize() {
wpi::SmallString<64> tmp;
const char* webroot_sys = std::getenv("HALSIMWS_SYSROOT");
if (webroot_sys != NULL) {
if (webroot_sys != nullptr) {
wpi::StringRef tstr(webroot_sys);
tmp.append(tstr);
} else {
@@ -58,7 +58,7 @@ bool HALSimWeb::Initialize() {
tmp.clear();
const char* webroot_user = std::getenv("HALSIMWS_USERROOT");
if (webroot_user != NULL) {
if (webroot_user != nullptr) {
wpi::StringRef tstr(webroot_user);
tmp.append(tstr);
} else {
@@ -69,14 +69,14 @@ bool HALSimWeb::Initialize() {
m_webroot_user = wpi::Twine(tmp).str();
const char* uri = std::getenv("HALSIMWS_URI");
if (uri != NULL) {
if (uri != nullptr) {
m_uri = uri;
} else {
m_uri = "/wpilibws";
}
const char* port = std::getenv("HALSIMWS_PORT");
if (port != NULL) {
if (port != nullptr) {
try {
m_port = std::stoi(port);
} catch (const std::invalid_argument& err) {

View File

@@ -266,7 +266,7 @@ class Texture {
m_format{oth.m_format},
m_width{oth.m_width},
m_height{oth.m_height} {
oth.m_texture = 0;
oth.m_texture = 0; // NOLINT
}
Texture& operator=(const Texture&) = delete;
@@ -275,7 +275,7 @@ class Texture {
DeleteTexture(m_texture);
}
m_texture = oth.m_texture;
oth.m_texture = 0;
oth.m_texture = 0; // NOLINT
m_format = oth.m_format;
m_width = oth.m_width;
m_height = oth.m_height;

View File

@@ -77,5 +77,5 @@ TEST_F(CommandRequirementsTest, DefaultCommandRequirementErrorTest) {
requirement1.SetDefaultCommand(std::move(command1));
EXPECT_TRUE(requirement1.GetDefaultCommand() == NULL);
EXPECT_TRUE(requirement1.GetDefaultCommand() == nullptr);
}

View File

@@ -223,7 +223,7 @@ bool TCPStream::WaitForReadEvent(int timeout) {
tv.tv_usec = 0;
FD_ZERO(&sdset);
FD_SET(m_sd, &sdset);
if (select(m_sd + 1, &sdset, NULL, NULL, &tv) > 0) {
if (select(m_sd + 1, &sdset, nullptr, nullptr, &tv) > 0) {
return true;
}
return false;