Remove no-op function pointer null checks, NFC

Null-checking functions which aren't marked weak_import is a no-op
(the compiler rewrites the check to 'true'), regardless of whether a
library providing its definition is weak-linked. If the deployment
target is greater than the minimum requirement, the availability markup
on APIs does not lower to weak_import.

Remove no-op null checks to clean up the code and silence warnings.

Differential Revision: https://reviews.llvm.org/D40812

llvm-svn: 319936
This commit is contained in:
Vedant Kumar 2017-12-06 19:21:10 +00:00
parent 8465c38b1e
commit 606908aab5
4 changed files with 29 additions and 50 deletions

View File

@ -600,10 +600,9 @@ bool GDBRemoteCommunication::DecompressPacket() {
#if defined(HAVE_LIBCOMPRESSION) #if defined(HAVE_LIBCOMPRESSION)
// libcompression is weak linked so check that compression_decode_buffer() is // libcompression is weak linked so check that compression_decode_buffer() is
// available // available
if (compression_decode_buffer != NULL && if (m_compression_type == CompressionType::ZlibDeflate ||
(m_compression_type == CompressionType::ZlibDeflate || m_compression_type == CompressionType::LZFSE ||
m_compression_type == CompressionType::LZFSE || m_compression_type == CompressionType::LZ4) {
m_compression_type == CompressionType::LZ4)) {
compression_algorithm compression_type; compression_algorithm compression_type;
if (m_compression_type == CompressionType::LZFSE) if (m_compression_type == CompressionType::LZFSE)
compression_type = COMPRESSION_LZFSE; compression_type = COMPRESSION_LZFSE;

View File

@ -1022,10 +1022,7 @@ void GDBRemoteCommunicationClient::MaybeEnableCompression(
std::string avail_name; std::string avail_name;
#if defined(HAVE_LIBCOMPRESSION) #if defined(HAVE_LIBCOMPRESSION)
// libcompression is weak linked so test if compression_decode_buffer() is if (avail_type == CompressionType::None) {
// available
if (compression_decode_buffer != NULL &&
avail_type == CompressionType::None) {
for (auto compression : supported_compressions) { for (auto compression : supported_compressions) {
if (compression == "lzfse") { if (compression == "lzfse") {
avail_type = CompressionType::LZFSE; avail_type = CompressionType::LZFSE;
@ -1037,10 +1034,7 @@ void GDBRemoteCommunicationClient::MaybeEnableCompression(
#endif #endif
#if defined(HAVE_LIBCOMPRESSION) #if defined(HAVE_LIBCOMPRESSION)
// libcompression is weak linked so test if compression_decode_buffer() is if (avail_type == CompressionType::None) {
// available
if (compression_decode_buffer != NULL &&
avail_type == CompressionType::None) {
for (auto compression : supported_compressions) { for (auto compression : supported_compressions) {
if (compression == "zlib-deflate") { if (compression == "zlib-deflate") {
avail_type = CompressionType::ZlibDeflate; avail_type = CompressionType::ZlibDeflate;
@ -1064,10 +1058,7 @@ void GDBRemoteCommunicationClient::MaybeEnableCompression(
#endif #endif
#if defined(HAVE_LIBCOMPRESSION) #if defined(HAVE_LIBCOMPRESSION)
// libcompression is weak linked so test if compression_decode_buffer() is if (avail_type == CompressionType::None) {
// available
if (compression_decode_buffer != NULL &&
avail_type == CompressionType::None) {
for (auto compression : supported_compressions) { for (auto compression : supported_compressions) {
if (compression == "lz4") { if (compression == "lz4") {
avail_type = CompressionType::LZ4; avail_type = CompressionType::LZ4;
@ -1079,10 +1070,7 @@ void GDBRemoteCommunicationClient::MaybeEnableCompression(
#endif #endif
#if defined(HAVE_LIBCOMPRESSION) #if defined(HAVE_LIBCOMPRESSION)
// libcompression is weak linked so test if compression_decode_buffer() is if (avail_type == CompressionType::None) {
// available
if (compression_decode_buffer != NULL &&
avail_type == CompressionType::None) {
for (auto compression : supported_compressions) { for (auto compression : supported_compressions) {
if (compression == "lzma") { if (compression == "lzma") {
avail_type = CompressionType::LZMA; avail_type = CompressionType::LZMA;

View File

@ -56,9 +56,7 @@ void DarwinLogCallback(void *baton, uint32_t flags, const char *format,
} }
} }
DNBCallbackLog OsLogger::GetLogFunction() { DNBCallbackLog OsLogger::GetLogFunction() { return DarwinLogCallback; }
return _os_log_impl ? DarwinLogCallback : nullptr;
}
#else #else

View File

@ -710,26 +710,22 @@ std::string RNBRemote::CompressString(const std::string &orig) {
size_t compressed_size = 0; size_t compressed_size = 0;
#if defined(HAVE_LIBCOMPRESSION) #if defined(HAVE_LIBCOMPRESSION)
if (compression_decode_buffer && if (compression_type == compression_types::lz4) {
compression_type == compression_types::lz4) {
compressed_size = compression_encode_buffer( compressed_size = compression_encode_buffer(
encoded_data.data(), encoded_data_buf_size, (uint8_t *)orig.c_str(), encoded_data.data(), encoded_data_buf_size, (uint8_t *)orig.c_str(),
orig.size(), nullptr, COMPRESSION_LZ4_RAW); orig.size(), nullptr, COMPRESSION_LZ4_RAW);
} }
if (compression_decode_buffer && if (compression_type == compression_types::zlib_deflate) {
compression_type == compression_types::zlib_deflate) {
compressed_size = compression_encode_buffer( compressed_size = compression_encode_buffer(
encoded_data.data(), encoded_data_buf_size, (uint8_t *)orig.c_str(), encoded_data.data(), encoded_data_buf_size, (uint8_t *)orig.c_str(),
orig.size(), nullptr, COMPRESSION_ZLIB); orig.size(), nullptr, COMPRESSION_ZLIB);
} }
if (compression_decode_buffer && if (compression_type == compression_types::lzma) {
compression_type == compression_types::lzma) {
compressed_size = compression_encode_buffer( compressed_size = compression_encode_buffer(
encoded_data.data(), encoded_data_buf_size, (uint8_t *)orig.c_str(), encoded_data.data(), encoded_data_buf_size, (uint8_t *)orig.c_str(),
orig.size(), nullptr, COMPRESSION_LZMA); orig.size(), nullptr, COMPRESSION_LZMA);
} }
if (compression_decode_buffer && if (compression_type == compression_types::lzfse) {
compression_type == compression_types::lzfse) {
compressed_size = compression_encode_buffer( compressed_size = compression_encode_buffer(
encoded_data.data(), encoded_data_buf_size, (uint8_t *)orig.c_str(), encoded_data.data(), encoded_data_buf_size, (uint8_t *)orig.c_str(),
orig.size(), nullptr, COMPRESSION_LZFSE); orig.size(), nullptr, COMPRESSION_LZFSE);
@ -3621,7 +3617,7 @@ rnb_err_t RNBRemote::HandlePacket_qSupported(const char *p) {
#if defined(HAVE_LIBCOMPRESSION) #if defined(HAVE_LIBCOMPRESSION)
// libcompression is weak linked so test if compression_decode_buffer() is // libcompression is weak linked so test if compression_decode_buffer() is
// available // available
if (enable_compression && compression_decode_buffer != NULL) { if (enable_compression) {
strcat(buf, ";SupportedCompressions=lzfse,zlib-deflate,lz4,lzma;" strcat(buf, ";SupportedCompressions=lzfse,zlib-deflate,lz4,lzma;"
"DefaultCompressionMinSize="); "DefaultCompressionMinSize=");
char numbuf[16]; char numbuf[16];
@ -4307,24 +4303,22 @@ rnb_err_t RNBRemote::HandlePacket_QEnableCompression(const char *p) {
} }
#if defined(HAVE_LIBCOMPRESSION) #if defined(HAVE_LIBCOMPRESSION)
if (compression_decode_buffer != NULL) { if (strstr(p, "type:zlib-deflate;") != nullptr) {
if (strstr(p, "type:zlib-deflate;") != nullptr) { EnableCompressionNextSendPacket(compression_types::zlib_deflate);
EnableCompressionNextSendPacket(compression_types::zlib_deflate); m_compression_minsize = new_compression_minsize;
m_compression_minsize = new_compression_minsize; return SendPacket("OK");
return SendPacket("OK"); } else if (strstr(p, "type:lz4;") != nullptr) {
} else if (strstr(p, "type:lz4;") != nullptr) { EnableCompressionNextSendPacket(compression_types::lz4);
EnableCompressionNextSendPacket(compression_types::lz4); m_compression_minsize = new_compression_minsize;
m_compression_minsize = new_compression_minsize; return SendPacket("OK");
return SendPacket("OK"); } else if (strstr(p, "type:lzma;") != nullptr) {
} else if (strstr(p, "type:lzma;") != nullptr) { EnableCompressionNextSendPacket(compression_types::lzma);
EnableCompressionNextSendPacket(compression_types::lzma); m_compression_minsize = new_compression_minsize;
m_compression_minsize = new_compression_minsize; return SendPacket("OK");
return SendPacket("OK"); } else if (strstr(p, "type:lzfse;") != nullptr) {
} else if (strstr(p, "type:lzfse;") != nullptr) { EnableCompressionNextSendPacket(compression_types::lzfse);
EnableCompressionNextSendPacket(compression_types::lzfse); m_compression_minsize = new_compression_minsize;
m_compression_minsize = new_compression_minsize; return SendPacket("OK");
return SendPacket("OK");
}
} }
#endif #endif