Skip to content

Commit

Permalink
reduce warnings (#5168)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeffrey Mendelsohn authored and GitHub Enterprise committed Jan 17, 2025
1 parent 9498c63 commit 86f88ed
Show file tree
Hide file tree
Showing 15 changed files with 50 additions and 22 deletions.
2 changes: 1 addition & 1 deletion groups/bdl/bdlc/bdlc_packedintarray.h
Original file line number Diff line number Diff line change
Expand Up @@ -1539,7 +1539,7 @@ STREAM& PackedIntArrayImp<STORAGE>::bdexStreamIn(STREAM& stream, int version)
else {
bsl::size_t tmpLength;
{
int v;
int v = 0;
stream.getLength(v);
tmpLength = static_cast<bsl::size_t>(v);
}
Expand Down
2 changes: 1 addition & 1 deletion groups/bdl/bdlf/bdlf_overloaded.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ int main(int argc, char *argv[])
int someValue = 3;

checkEm(bdlf::Overloaded{
[&someValue](void) {return kVoid;}
[&someValue](void) { (void)someValue; return kVoid; }
, FloatingPoint{}
, FreeFN::HandleShort
, FreeFN::HandleUnsignedShort
Expand Down
4 changes: 2 additions & 2 deletions groups/bdl/bdljsn/bdljsn_error.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1927,8 +1927,8 @@ int main(int argc, char *argv[])

bsls::Types::Int64 s1Alloc = s1.numBytesInUse();

Obj *objPtr = 0;
bsls::Types::Int64 objAlloc;
Obj *objPtr = 0;
bsls::Types::Int64 objAlloc = 0;
bslma::TestAllocator *objAllocatorPtr = 0;

switch (CONFIG) {
Expand Down
2 changes: 1 addition & 1 deletion groups/bdl/bdljsn/bdljsn_jsonnumber.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3245,7 +3245,7 @@ int main(int argc, char *argv[])
bsls::Types::Int64 s1Alloc = s1.numBytesInUse();

Obj *objPtr = 0;
bsls::Types::Int64 objAlloc;
bsls::Types::Int64 objAlloc = 0;
bslma::TestAllocator *objAllocatorPtr = 0;

switch (CONFIG) {
Expand Down
5 changes: 1 addition & 4 deletions groups/bsl/bslalg/bslalg_rbtreenode.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,7 @@ void debugprint(const Obj& val) {
/// `left`, and `right`.
static Obj& gg(Obj *result, Color color, Obj *parent, Obj *left, Obj *right)
{
result->setColor(color);
result->setParent(parent);
result->setLeftChild(left);
result->setRightChild(right);
result->reset(parent, left, right, color);
return *result;
}

Expand Down
4 changes: 2 additions & 2 deletions groups/bsl/bslh/bslh_hash.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -757,9 +757,9 @@ class MockHashingAlgorithm {
public:
/// Create a new `MockHashingAlgorithm`
MockHashingAlgorithm()
: d_length(0)
: d_data(0)
, d_length(0)
{
d_data = new char[0];
}

/// Destroy this object
Expand Down
2 changes: 1 addition & 1 deletion groups/bsl/bslh/bslh_seededhash.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ bool HashTable<TYPE, HASHER>::lookup(size_t *idx,
const TYPE *ptr;
for (*idx = hashValue & d_bucketArrayMask; (ptr = d_bucketArray[*idx]);
*idx = (*idx + 1) & d_bucketArrayMask) {
if (value == *ptr) {
if (value == +*ptr) {
return true; // RETURN
}
}
Expand Down
2 changes: 1 addition & 1 deletion groups/bsl/bslim/bslim_printer.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ struct TestEnumWithStreaming {
bsl::ostream& operator<<(bsl::ostream& stream,
TestEnumWithStreaming::Enum value)
{
const char *ascii;
const char *ascii = 0;
switch (value) {
case TestEnumWithStreaming::VALUE_A:
ascii = "VALUE_A";
Expand Down
2 changes: 1 addition & 1 deletion groups/bsl/bslma/bslma_polymorphicallocator.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ int main(int argc, char *argv[])

alloc.construct(&buf2.object());
ASSERT(alloc == buf2.object().get_allocator());
ASSERTV(0, buf2.object().value(), 0 == buf1.object().value());
ASSERTV(buf2.object().value(), 0 == buf2.object().value());
runDestroy(alloc, &buf2.object());
ASSERTV(AATT::lastDestroyed() == buf2.address());
}
Expand Down
12 changes: 11 additions & 1 deletion groups/bsl/bsls/bsls_alignment.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <bsls_alignment.h>

#include <bsls_bsltestutil.h> // for testing only
#include <bsls_platform.h>

#include <stdio.h>
#include <stdlib.h>
Expand Down Expand Up @@ -285,6 +286,11 @@ int main(int argc, char *argv[])
if (verbose) printf("\nTesting `enum` and `toAscii`"
"\n============================\n");

#ifdef BSLS_PLATFORM_HAS_PRAGMA_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif

static const struct {
int d_lineNum; // source line number
Enum d_value; // enumerator value
Expand All @@ -295,14 +301,18 @@ int main(int argc, char *argv[])
{ L_, Obj::BSLS_MAXIMUM, "MAXIMUM" },
{ L_, Obj::BSLS_NATURAL, "NATURAL" },
{ L_, Obj::BSLS_BYTEALIGNED, "BYTEALIGNED" },

#ifndef BDE_BUILD_TARGET_UBSAN
{ L_, (Enum)NUM_ENUMERATORS, UNKNOWN_FORMAT },
{ L_, (Enum)-1, UNKNOWN_FORMAT },
{ L_, (Enum)-5, UNKNOWN_FORMAT },
{ L_, (Enum)99, UNKNOWN_FORMAT }
#endif
};

#ifdef BSLS_PLATFORM_HAS_PRAGMA_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif

const int NUM_DATA = sizeof DATA / sizeof *DATA;

if (verbose) printf("\nVerify enumerator values are sequential.\n");
Expand Down
12 changes: 12 additions & 0 deletions groups/bsl/bsls/bsls_blockgrowth.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include <bsls_blockgrowth.h>

#include <bsls_platform.h>

#include <iostream>

#include <cstdlib>
Expand Down Expand Up @@ -240,6 +242,11 @@ int main(int argc, char *argv[])
if (verbose) cout << "\nTesting enumerator value and `toAscii`."
<< endl;

#ifdef BSLS_PLATFORM_HAS_PRAGMA_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif

static const struct {
int d_line; // line number
Enum d_enum; // enumerator
Expand All @@ -256,6 +263,11 @@ int main(int argc, char *argv[])
{ L_, (Enum)10 , "(* UNKNOWN *)", -1 },
#endif
};

#ifdef BSLS_PLATFORM_HAS_PRAGMA_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif

const int NUM_DATA = sizeof DATA / sizeof *DATA;

for (int ti = 0; ti < NUM_DATA; ++ti) {
Expand Down
4 changes: 2 additions & 2 deletions groups/bsl/bsls/bsls_timeinterval.h
Original file line number Diff line number Diff line change
Expand Up @@ -1245,8 +1245,8 @@ STREAM& TimeInterval::bdexStreamIn(STREAM& stream, int version)
if (stream) {
switch (version) { // switch on the schema version
case 1: {
bsls::Types::Int64 seconds;
int nanoseconds;
bsls::Types::Int64 seconds = 0;
int nanoseconds = 0;
stream.getInt64(seconds);
stream.getInt32(nanoseconds);

Expand Down
6 changes: 3 additions & 3 deletions groups/bsl/bslstl/bslstl_map_test3.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4086,7 +4086,7 @@ void TestDriver<KEY, VALUE, COMP, ALLOC>::testCase32()
};
const int NUM_DATA = static_cast<int>(sizeof DATA / sizeof *DATA);

const int MAX_LENGTH = 10;
const int MAX_LENGTH = 32;

if (verbose) printf("\nTesting `emplace` with hint.\n");
{
Expand Down Expand Up @@ -4771,7 +4771,7 @@ void TestDriver<KEY, VALUE, COMP, ALLOC>::testCase31()
};
const int NUM_DATA = static_cast<int>(sizeof DATA / sizeof *DATA);

const int MAX_LENGTH = 10;
const int MAX_LENGTH = 32;

if (verbose) printf("\nTesting `emplace` without exceptions.\n");
{
Expand Down Expand Up @@ -5451,7 +5451,7 @@ void TestDriver<KEY, VALUE, COMP, ALLOC>::testCase29()
};
const int NUM_DATA = static_cast<int>(sizeof DATA / sizeof *DATA);

const int MAX_LENGTH = 10;
const int MAX_LENGTH = 32;

if (verbose) printf("\nTesting `insert` without exceptions.\n");
{
Expand Down
9 changes: 9 additions & 0 deletions groups/bsl/bslstl/bslstl_variant.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1021,6 +1021,8 @@ struct MyClassDef {
int *d_data_p;
bslma::Allocator *d_allocator_p;

MyClassDef();

// In optimized builds, some compilers will elide some of the operations in
// the destructors of the test classes defined below. In order to force
// the compiler to retain all of the code in the destructors, we provide
Expand All @@ -1036,6 +1038,13 @@ struct MyClassDef {

bool MyClassDef::s_forceDestructorCall = false;

MyClassDef::MyClassDef()
: d_value(0)
, d_data_p(0)
, d_allocator_p(0)
{
}

void MyClassDef::dumpState()
{
if (s_forceDestructorCall) {
Expand Down
4 changes: 2 additions & 2 deletions groups/bsl/bslx/bslx_genericinstream.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1540,7 +1540,7 @@ if (veryVerbose) {
if (verbose)
cout << "\nNegative Testing." << endl;
{
double DATA[5];
double DATA[5] = { 0.0, 0.0, 0.0, 0.0, 0.0 };

Buf b;

Expand Down Expand Up @@ -1693,7 +1693,7 @@ if (veryVerbose) {
if (verbose)
cout << "\nNegative Testing." << endl;
{
float DATA[5];
float DATA[5] = { 0.0, 0.0, 0.0, 0.0, 0.0 };

Buf b;

Expand Down

0 comments on commit 86f88ed

Please sign in to comment.