Skip to content
Permalink
Browse files
GEODE-5839: Fixes misc clang-tidy warnings.
* Fixes clang-analyzer-core.CallAndMessage warning
* Fixes clang-diagnostic-return-std-move-in-c++11 warning.
* Cleanup NOLINT with specific warning it suppresses.
* Fixes clang-analyzer-core.CallAndMessage warning
* Updates to Boost 1.68 to fix uninitilalized variable.
* Fixes clang-analyzer-unix.* warnings.
* Fixes clang-analyzer-unix.* warnings.
* Fixes clang-analyzer-cplusplus.NewDeleteLeaks warnings.
* Fixes clang-analyzer-security.insecureAPI.rand warnings.
* Fixes remaining clang-diagnostic-* warnings.
* Fixes clang-analyzer-deadcode.DeadStores warnings.
* Fixes clang-analyzer-security.insecureAPI.strcpy warning
* Fixes clang-analyzer-cplusplus.NewDelete warning
* Cleanup clang-tidy configs
  • Loading branch information
pivotal-jbarrett committed Oct 10, 2018
1 parent 9ed0ced commit ecc62a61c93d72c759a3139ce4620eb335f89a15
Showing 137 changed files with 987 additions and 1,261 deletions.
@@ -1,55 +1,18 @@
---
Checks: '-*,clang-diagnostic-*,clang-analyzer-*,-clang-analyzer-alpha*,google-*,-google-readability-todo,-google-runtime-references,-google-default-arguments'
WarningsAsErrors: 'clang-analyzer-optin.performance.Padding,google-*'
Checks: '-*,clang-diagnostic-*,clang-analyzer-*,-clang-analyzer-alpha*,google-*,-google-readability-todo,-google-runtime-references,-google-default-arguments,-clang-analyzer-core.uninitialized.UndefReturn,-clang-analyzer-core.UndefinedBinaryOperatorResult,-clang-analyzer-optin.cplusplus.VirtualCall'
WarningsAsErrors: 'clang-analyzer-optin.performance.*,clang-analyzer-core.*,clang-analyzer-unix.*,clang-diagnostic-*,google-*,clang-analyzer-cplusplus.*,clang-analyzer-security.insecureAPI.*,clang-analyzer-deadcode.*'
HeaderFilterRegex: '.*'
AnalyzeTemporaryDtors: false
FormatStyle: file
CheckOptions:
- key: google-build-namespaces.HeaderFileExtensions
value: h,hh,hpp,hxx
- key: google-global-names-in-headers.HeaderFileExtensions
value: h
- key: google-readability-braces-around-statements.ShortStatementLines
value: '1'
- key: google-readability-function-size.BranchThreshold
value: '4294967295'
- key: google-readability-function-size.LineThreshold
value: '4294967295'
- key: google-readability-function-size.NestingThreshold
value: '4294967295'
- key: google-readability-function-size.ParameterThreshold
value: '4294967295'
- key: google-readability-function-size.StatementThreshold
value: '800'
- key: google-readability-namespace-comments.ShortNamespaceLines
value: '0'
- key: google-readability-namespace-comments.SpacesBeforeComments
value: '2'
- key: google-runtime-int.SignedTypePrefix
value: int
- key: google-runtime-int.TypeSuffix
value: ''
- key: google-runtime-int.UnsignedTypePrefix
value: uint
- key: google-runtime-references.WhiteListTypes
value: ''
- key: modernize-loop-convert.MaxCopySize
value: '16'
- key: modernize-loop-convert.MinConfidence
value: reasonable
- key: modernize-loop-convert.NamingStyle
value: CamelCase
- key: modernize-pass-by-value.IncludeStyle
value: llvm
- key: modernize-replace-auto-ptr.IncludeStyle
value: llvm
- key: modernize-use-nullptr.NullMacros
value: 'NULL'
...

# Disable Checks
# google-runtime-references - We have diverged from this rule due to both legacy and disagreement with the rule.
# google-readability-todo - Adds current user name when fix applied.

# TODO - Fix these checks
# google-default-arguments'
# google-default-arguments
# clang-analyzer-core.uninitialized.UndefReturn - Generates errors in ACE, how do we ignore?
# clang-analyzer-core.UndefinedBinaryOperatorResult - Generates errors in ACE, how do we ignore?

# TEMP
# clang-analyzer-optin.cplusplus.VirtualCall
@@ -498,7 +498,7 @@ class APACHE_GEODE_EXPORT DataOutput {
static void releaseLock();

// memory m_buffer to encode to.
std::unique_ptr<uint8_t> m_bytes;
std::unique_ptr<uint8_t[]> m_bytes;
// cursor.
uint8_t* m_buf;
// size of m_bytes.
@@ -338,7 +338,7 @@ class APACHE_GEODE_EXPORT RegionAttributesFactory {
* @return a reference to <code>this</code>
* @throws IllegalArgumentException if initialCapacity is negative.
*/
RegionAttributesFactory& setInitialCapacity(int initialCapacity);
RegionAttributesFactory& setInitialCapacity(int32_t initialCapacity);

/**
* Sets the entry load factor for the next <code>RegionAttributes</code>
@@ -0,0 +1,12 @@
---
Checks: '-*,clang-diagnostic-*,clang-analyzer-*,-clang-analyzer-alpha*,google-*,-google-readability-todo,-google-runtime-references,-clang-analyzer-unix.cstring.NullArg'
WarningsAsErrors: '*,-google-default-arguments'
HeaderFilterRegex: '.*'
FormatStyle: file

# Disable Checks
# google-runtime-references - We have diverged from this rule due to both legacy and disagreement with the rule.
# google-readability-todo - Adds current user name when fix applied.

# TODO - Fix these checks
# clang-analyzer-unix.cstring.NullArg - Generates errors in Boost, how do we ignore?
@@ -58,6 +58,7 @@ static int getRandomNum() {
// Whilst this approach is pessimal, it can not be
// remedied as the test depend upon it.
ACE_OS::srand(seed);
// NOLINTNEXTLINE(clang-analyzer-security.insecureAPI.rand)
return (ACE_OS::rand() % 49999) + 14000;
}

@@ -191,7 +192,7 @@ int BBNamingContextClientImpl::resolve(const char* key, char* value, char*) {
std::string v = m_bbc->getString(k, k1);
// fprintf(stdout, "resolve: got value %s for key=%s\n", v.c_str(),
// key);fflush(stdout);
ACE_OS::strcpy(value, v.c_str());
ACE_OS::strncpy(value, v.c_str(), sizeof(value));
if (m_errCount > 0) {
m_errCount = 0;
}
@@ -23,6 +23,7 @@
#include <limits.h>
#include <cstdlib>
#include <wchar.h>
#include <random>

#include <ace/Date_Time.h>

@@ -122,9 +123,9 @@ const uint32_t m_crc32Table[] = {
0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d};

inline double random(double maxValue) {
// Random number generator is initialized in registerBuiltins()
return (maxValue * static_cast<double>(rand())) /
(static_cast<double>(RAND_MAX) + 1.0);
static thread_local std::default_random_engine generator(
std::random_device{}());
return std::uniform_real_distribution<double>{0.0, maxValue}(generator);
}

template <typename TPRIM>
@@ -1776,9 +1776,7 @@ int CacheHelper::hashcode(char* str) {
}

int CacheHelper::getRandomNumber() {
// char * testName = ACE_OS::getenv( "TESTNAME" );

// int seed = hashcode(testName);
// NOLINTNEXTLINE(clang-analyzer-security.insecureAPI.rand)
return (ACE_OS::rand() % RANDOM_NUMBER_DIVIDER) + RANDOM_NUMBER_OFFSET;
}

@@ -33,7 +33,7 @@
#define ROOT_SCOPE LOCAL
#endif

namespace { // NOLINT
namespace { // NOLINT(google-build-namespaces)

using apache::geode::client::CacheHelper;
using apache::geode::client::Properties;
@@ -30,7 +30,7 @@

#include "CacheHelper.hpp"

namespace { // NOLINT
namespace { // NOLINT(google-build-namespaces)

using apache::geode::client::DataInput;
using apache::geode::client::DataOutput;
@@ -24,7 +24,7 @@
#define SERVER2 s2p2
#endif

namespace { // NOLINT
namespace { // NOLINT(google-build-namespaces)

using apache::geode::client::CacheHelper;

@@ -51,7 +51,7 @@
#define ROOT_SCOPE LOCAL
#endif

namespace { // NOLINT
namespace { // NOLINT(google-build-namespaces)

using apache::geode::client::CacheableKey;
using apache::geode::client::CacheableStringArray;
@@ -37,7 +37,7 @@
* + callback Argument
*/

namespace { // NOLINT
namespace { // NOLINT(google-build-namespaces)

using apache::geode::client::testing::TallyListener;
using apache::geode::client::testing::TallyWriter;
@@ -39,7 +39,7 @@
#define CREATE_TWICE_KEY "__create_twice_key"
#define CREATE_TWICE_VALUE "__create_twice_value"

namespace { // NOLINT
namespace { // NOLINT(google-build-namespaces)

using apache::geode::client::CacheableInt32;
using apache::geode::client::CacheableInt64;
@@ -36,7 +36,7 @@
#define SERVER1 s2p1
#define SERVER2 s2p2

namespace { // NOLINT
namespace { // NOLINT(google-build-namespaces)

using apache::geode::client::CacheableInt32;
using apache::geode::client::CacheableInt64;
@@ -46,7 +46,7 @@ Client 1 is with R =0 and Client 2 with R = 1
#define SERVER1 s2p1
#define FEEDER s2p2

namespace { // NOLINT
namespace { // NOLINT(google-build-namespaces)

using apache::geode::client::EntryEvent;
using apache::geode::client::Exception;
@@ -45,7 +45,7 @@ Shutdown
#define SERVER1 s2p1
#define FEEDER s2p2

namespace { // NOLINT
namespace { // NOLINT(google-build-namespaces)

using apache::geode::client::EntryEvent;
using apache::geode::client::Exception;
@@ -44,7 +44,7 @@ recieved.
#define SERVER1 s2p1
#define FEEDER s2p2

namespace { // NOLINT
namespace { // NOLINT(google-build-namespaces)

using apache::geode::client::EntryEvent;
using apache::geode::client::HashMapOfCacheable;
@@ -38,7 +38,7 @@
#define SERVER1 s2p1
#define FEEDER s2p2

namespace { // NOLINT
namespace { // NOLINT(google-build-namespaces)

using apache::geode::client::EntryEvent;

@@ -31,7 +31,7 @@

#include "CacheHelper.hpp"

namespace { // NOLINT
namespace { // NOLINT(google-build-namespaces)

using apache::geode::client::CacheableKey;
using apache::geode::client::CacheableString;
@@ -31,7 +31,7 @@

#include "CacheHelper.hpp"

namespace { // NOLINT
namespace { // NOLINT(google-build-namespaces)

using apache::geode::client::CacheableKey;
using apache::geode::client::CacheableString;
@@ -31,7 +31,7 @@

#include "CacheHelper.hpp"

namespace { // NOLINT
namespace { // NOLINT(google-build-namespaces)

using apache::geode::client::CacheableKey;
using apache::geode::client::CacheableString;
@@ -30,7 +30,7 @@

#include "CacheHelper.hpp"

namespace { // NOLINT
namespace { // NOLINT(google-build-namespaces)

using apache::geode::client::CacheableKey;
using apache::geode::client::CacheableString;
@@ -30,7 +30,7 @@

#include "CacheHelper.hpp"

namespace { // NOLINT
namespace { // NOLINT(google-build-namespaces)

using apache::geode::client::CacheableKey;
using apache::geode::client::CacheableString;
@@ -29,7 +29,7 @@

#include "CacheHelper.hpp"

namespace { // NOLINT
namespace { // NOLINT(google-build-namespaces)

using apache::geode::client::CacheableKey;
using apache::geode::client::CacheableString;
@@ -30,7 +30,7 @@

#include "CacheHelper.hpp"

namespace { // NOLINT
namespace { // NOLINT(google-build-namespaces)

using apache::geode::client::CacheableKey;
using apache::geode::client::CacheableString;
@@ -33,7 +33,7 @@

#include <string>

namespace { // NOLINT
namespace { // NOLINT(google-build-namespaces)

using apache::geode::client::EntryEvent;
using apache::geode::client::RegionEvent;