Skip to content

Commit

Permalink
reduce warnings (#4828)
Browse files Browse the repository at this point in the history
* reduce warnings

* revert bdlmt_multiprioritythreadpool.t.cpp
  • Loading branch information
Jeffrey Mendelsohn authored and GitHub Enterprise committed Jul 15, 2024
1 parent 7d2e565 commit 29a5226
Show file tree
Hide file tree
Showing 14 changed files with 147 additions and 53 deletions.
4 changes: 2 additions & 2 deletions groups/bdl/bdlb/bdlb_bitutil.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ int main(int argc, char *argv[])
unsigned int value32 = 1U << 31;
unsigned long long value64 = 1ULL << 63;
unsigned long value32or64 =
1ULL << (Util::sizeInBits<unsigned long>() - 1);
1UL << (Util::sizeInBits<unsigned long>() - 1);

ASSERT( 31 == Util::log2(value32 - 1U));
ASSERT( 63 == Util::log2(value64 - 1U));
Expand Down Expand Up @@ -1273,7 +1273,7 @@ int main(int argc, char *argv[])
}
}
for (int i = 0; i < Util::sizeInBits<unsigned long>(); ++i) {
unsigned long value32or64 = 1ULL << i;
unsigned long value32or64 = 1UL << i;
for (int index = 0;
index < Util::sizeInBits<unsigned long>();
++index) {
Expand Down
8 changes: 4 additions & 4 deletions groups/bdl/bdlb/bdlb_nullablevalue.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6226,14 +6226,14 @@ void runTestCase18()
default: { ASSERT(0 == "Unexpected argument count"); } break;
}

ASSERTV(numParams, !"expected exception missing");
ASSERTV(numParams, 0 == "expected exception missing");

} catch (const bsl::exception&) {
if (veryVeryVerbose) {
P_(numParams) Q(Caught expected exception)
}
} catch (...) {
ASSERTV(numParams, !"unexpected exception type");
ASSERTV(numParams, 0 == "unexpected exception type");
}

ASSERTV(numParams, numParams == ThrowingHelper::ctorCalled());
Expand Down Expand Up @@ -6322,14 +6322,14 @@ void runTestCase18()
ASSERT(0 == "Too many parameters.");
}

ASSERTV(numParams, !"Expected exception missing");
ASSERTV(numParams, 0 == "Expected exception missing");

} catch (const bsl::exception&) {
if (veryVeryVerbose) {
P_(numParams) Q(Caught expected exception)
}
} catch (...) {
ASSERTV(numParams, !"Unexpected exception type");
ASSERTV(numParams, 0 == "Unexpected exception type");
}

ASSERTV(numParams, true == obj.isNull());
Expand Down
12 changes: 5 additions & 7 deletions groups/bdl/bdlcc/bdlcc_objectpool.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ void executeInParallel(int numThreads,
bslmt::ThreadUtil::create(&threads[i],
attributes,
function,
static_cast<char *>(0) + i);
static_cast<void *>(&i));
}
for (int i = 0; i < numThreads; ++i) {
bslmt::ThreadUtil::join(threads[i]);
Expand Down Expand Up @@ -801,8 +801,7 @@ extern "C"
void *workerThread6(void *arg)
{
my_Class *arr[k_NUM_OBJECTS];
int remainder = static_cast<int>(
reinterpret_cast<bsls::Types::UintPtr>(arg) % 4);
int remainder = static_cast<int>(*static_cast<int *>(arg) % 4);

// 0-order threads
if (remainder == 0) {
Expand Down Expand Up @@ -934,8 +933,7 @@ extern "C"
void *workerThread4(void *arg)
{
my_Class *arr[k_NUM_OBJECTS];
int remainder = static_cast<int>(
reinterpret_cast<bsls::Types::UintPtr>(arg) % 2);
int remainder = static_cast<int>(*static_cast<int *>(arg) % 2);

// even numbered threads
if (remainder == 0) {
Expand All @@ -945,7 +943,7 @@ extern "C"
}

barrier0.wait();
if ((bsls::Types::IntPtr)arg == 0) {
if (*static_cast<int *>(arg) == 0) {
int nC; // number of created objects
int nA; // number of available objects
nC = pool->numObjects();
Expand Down Expand Up @@ -1003,7 +1001,7 @@ extern "C"
}

barrier.wait();
if ((bsls::Types::IntPtr)arg == 0) {
if (*static_cast<int *>(arg) == 0) {
int nC; // number of created objects
int nA; // number of available objects
nC = pool->numObjects();
Expand Down
23 changes: 1 addition & 22 deletions groups/bdl/bdlcc/bdlcc_sharedobjectpool.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -613,29 +613,8 @@ void ConstructorTestHelp1b::resetWithCount(ConstructorTestHelp1b *self,
// ============================================================================
// GLOBAL TYPEDEFS/CONSTANTS/VARIABLES/FUNCTIONS FOR TESTING
// ----------------------------------------------------------------------------
bslmt::ThreadAttributes attributes;
void executeInParallel(int numThreads,
bslmt::ThreadUtil::ThreadFunction function)
// Create the specified 'numThreads', each executing the specified
// 'function'. Number each thread (sequentially from 0 to 'numThreads-1')
// by passing i to i'th thread. Finally join all the threads.
{
bslmt::ThreadUtil::Handle *threads =
new bslmt::ThreadUtil::Handle[numThreads];
ASSERT(threads);

for (int i = 0; i < numThreads; ++i) {
bslmt::ThreadUtil::create(&threads[i],
attributes,
function,
static_cast<char *>(0) + i);
}
for (int i = 0; i < numThreads; ++i) {
bslmt::ThreadUtil::join(threads[i]);
}

delete [] threads;
}
bslmt::ThreadAttributes attributes;

// ============================================================================
// HELPER CLASSES AND FUNCTIONS FOR TESTING
Expand Down
8 changes: 4 additions & 4 deletions groups/bdl/bdljsn/bdljsn_json.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6839,7 +6839,7 @@ int main(int argc, char *argv[])
else if (X.isNumber()) {
ASSERTV(VALUE_CONFIG,
CONFIG,
&oa == X.theNumber().allocator());
&oa == X.theNumber().get_allocator());
}
else if (X.isObject()) {
ASSERTV(VALUE_CONFIG,
Expand Down Expand Up @@ -7175,7 +7175,7 @@ int main(int argc, char *argv[])
else if (X.isNumber()) {
ASSERTV(VALUE_CONFIG,
CONFIG,
&oa == X.theNumber().allocator());
&oa == X.theNumber().get_allocator());
}
else if (X.isObject()) {
ASSERTV(VALUE_CONFIG,
Expand Down Expand Up @@ -8723,8 +8723,8 @@ int main(int argc, char *argv[])
JsonType::e_NUMBER == X.type());
ASSERTV(CONFIG,
&oa,
number.allocator(),
&oa == number.allocator());
number.get_allocator().mechanism(),
&oa == number.get_allocator());
}

{
Expand Down
32 changes: 31 additions & 1 deletion groups/bdl/bdljsn/bdljsn_jsonnumber.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <bsls_compilerfeatures.h>
#include <bsls_log.h>
#include <bsls_nameof.h>
#include <bsls_platform.h>
#include <bsls_review.h>

#include <bsl_cassert.h>
Expand Down Expand Up @@ -218,7 +219,7 @@ void aSsErT(bool condition, const char *message, int line)
// ----------------------------------------------------------------------------

// For use in 'ASSERTV' macro invocations to print allocator.
#define ALLOC_OF(EXPR) (EXPR).allocator()
#define ALLOC_OF(EXPR) (EXPR).get_allocator().mechanism()

// ============================================================================
// EXCEPTION TEST MACRO ABBREVIATIONS
Expand Down Expand Up @@ -2346,6 +2347,9 @@ int main(int argc, char *argv[])
if ('N' == MEMDST2 && 'Y' == MEMSRC1) {
ASSERTV(LINE1, LINE2, 0 < EXCEPTION_COUNT);
}
#else
(void)MEMDST2;
(void)MEMSRC1;
#endif
} BSLMA_TESTALLOCATOR_EXCEPTION_TEST_END

Expand Down Expand Up @@ -4536,9 +4540,22 @@ int main(int argc, char *argv[])
// Also invoke the object's 'get_allocator' and 'allocator'
// accessors.

#ifdef BSLS_PLATFORM_HAS_PRAGMA_GCC_DIAGNOSTIC
#ifdef BSLS_PLATFORM_CMP_CLANG
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
#endif

ASSERTV(CONFIG, &oa, ALLOC_OF(X), &oa == X.get_allocator());
ASSERTV(CONFIG, &oa, ALLOC_OF(X), &oa == X.allocator());

#ifdef BSLS_PLATFORM_HAS_PRAGMA_GCC_DIAGNOSTIC
#ifdef BSLS_PLATFORM_CMP_CLANG
#pragma GCC diagnostic pop
#endif
#endif

ASSERTV(CONFIG, oa.numBlocksTotal(),
0 == oa.numBlocksTotal());

Expand Down Expand Up @@ -4632,9 +4649,22 @@ int main(int argc, char *argv[])
// Also invoke the object's 'get_allocator' and 'allocator'
// accessors.

#ifdef BSLS_PLATFORM_HAS_PRAGMA_GCC_DIAGNOSTIC
#ifdef BSLS_PLATFORM_CMP_CLANG
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
#endif

ASSERTV(CONFIG, &oa, ALLOC_OF(X), &oa == X.get_allocator());
ASSERTV(CONFIG, &oa, ALLOC_OF(X), &oa == X.allocator());

#ifdef BSLS_PLATFORM_HAS_PRAGMA_GCC_DIAGNOSTIC
#ifdef BSLS_PLATFORM_CMP_CLANG
#pragma GCC diagnostic pop
#endif
#endif

switch (MEM) {
case 'Y': {
ASSERTV(CONFIG, oa.numBlocksTotal(),
Expand Down
16 changes: 16 additions & 0 deletions groups/bdl/bdlma/bdlma_concurrentmultipool.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ BSLS_IDENT("$Id: $")
// // 'getMessage' method for clients to retrieve the underlying message.
//
// public:
// // CREATORS
// virtual ~my_Message() {}
// // Destroy this object.
//
// // ACCESSORS
// virtual const char *getMessage() = 0;
// // Return the null-terminated message string.
Expand Down Expand Up @@ -156,6 +160,9 @@ BSLS_IDENT("$Id: $")
// d_buffer[length] = '\0';
// }
//
// virtual ~my_SmallMessage() {}
// // Destroy this object.
//
// // PRIVATE ACCESSORS
// virtual const char *getMessage()
// {
Expand Down Expand Up @@ -186,6 +193,9 @@ BSLS_IDENT("$Id: $")
// d_buffer[length] = '\0';
// }
//
// virtual ~my_MediumMessage() {}
// // Destroy this object.
//
// // PRIVATE ACCESSORS
// virtual const char *getMessage()
// {
Expand Down Expand Up @@ -216,6 +226,9 @@ BSLS_IDENT("$Id: $")
// d_buffer[length] = '\0';
// }
//
// virtual ~my_LargeMessage() {}
// // Destroy this object.
//
// // PRIVATE ACCESSORS
// virtual const char *getMessage()
// {
Expand All @@ -241,6 +254,9 @@ BSLS_IDENT("$Id: $")
// {
// }
//
// virtual ~my_GenericMessage() {}
// // Destroy this object.
//
// // PRIVATE ACCESSORS
// virtual const char *getMessage()
// {
Expand Down
18 changes: 17 additions & 1 deletion groups/bdl/bdlma/bdlma_concurrentmultipool.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ static int recPool(char *address)
{
ASSERT(address);

Header *h = (Header *)address - 1;
Header *h = (Header *)(void *)address - 1;

return h->d_header.d_pool;
}
Expand Down Expand Up @@ -316,6 +316,10 @@ extern "C" void *workerThread(void *arg) {
// 'getMessage' method for clients to retrieve the underlying message.

public:
// CREATORS
virtual ~my_Message() {}
// Destroy this object.

// ACCESSORS
virtual const char *getMessage() = 0;
// Return the null-terminated message string.
Expand Down Expand Up @@ -343,6 +347,9 @@ extern "C" void *workerThread(void *arg) {
d_buffer[length] = '\0';
}

virtual ~my_SmallMessage() {}
// Destroy this object.

// PRIVATE ACCESSORS
virtual const char *getMessage()
{
Expand Down Expand Up @@ -373,6 +380,9 @@ extern "C" void *workerThread(void *arg) {
d_buffer[length] = '\0';
}

virtual ~my_MediumMessage() {}
// Destroy this object.

// PRIVATE ACCESSORS
virtual const char *getMessage()
{
Expand Down Expand Up @@ -403,6 +413,9 @@ extern "C" void *workerThread(void *arg) {
d_buffer[length] = '\0';
}

virtual ~my_LargeMessage() {}
// Destroy this object.

// PRIVATE ACCESSORS
virtual const char *getMessage()
{
Expand All @@ -428,6 +441,9 @@ extern "C" void *workerThread(void *arg) {
{
}

virtual ~my_GenericMessage() {}
// Destroy this object.

// PRIVATE ACCESSORS
virtual const char *getMessage()
{
Expand Down
18 changes: 8 additions & 10 deletions groups/bdl/bdlma/bdlma_concurrentmultipoolallocator.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <bslmf_nestedtraitdeclaration.h>

#include <bsls_alignmentutil.h>
#include <bsls_platform.h>
#include <bsls_stopwatch.h>
#include <bsls_types.h>

Expand All @@ -27,6 +28,12 @@
using namespace BloombergLP;
using namespace bsl; // automatically added by script

#ifdef BSLS_PLATFORM_HAS_PRAGMA_GCC_DIAGNOSTIC
#ifdef BSLS_PLATFORM_CMP_CLANG
#pragma GCC diagnostic ignored "-Wunused-private-field"
#endif
#endif

//=============================================================================
// TEST PLAN
//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -111,8 +118,6 @@ void aSsErT(int c, const char *s, int i)

typedef bdlma::ConcurrentMultipoolAllocator Obj;

const int MAX_ALIGN = bsls::AlignmentUtil::BSLS_MAX_ALIGNMENT;

// Warning: keep this in sync with bdema_Multipool.h!
struct Header {
// Stores pool number of this item.
Expand Down Expand Up @@ -155,7 +160,7 @@ inline static int recPool(char *address)
{
ASSERT(address);

Header *h = (Header *)address - 1;
Header *h = (Header *)(void *)address - 1;

return h->d_header.d_pool;
}
Expand All @@ -169,13 +174,6 @@ inline int delta(char *address1, char *address2)
: address1 - address2);
}

inline static void scribble(char *address, int size)
// Assign a non-zero value to each of the specified 'size' bytes starting
// at the specified 'address'.
{
memset(address, 0xff, size);
}

void stretchRemoveAll(Obj *object, int numElements, int objSize)
// Using only primary manipulators, extend the capacity of the specified
// 'object' to (at least) the specified 'numElements' each of the specified
Expand Down
Loading

0 comments on commit 29a5226

Please sign in to comment.