Skip to content

Commit

Permalink
Fix -WConversion warninigs in bmqtool storage inspector
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitrii Petukhov <[email protected]>
  • Loading branch information
bbpetukhov committed Sep 4, 2024
1 parent bd72cb4 commit 1dd5d08
Showing 1 changed file with 47 additions and 35 deletions.
82 changes: 47 additions & 35 deletions src/applications/bmqtool/m_bmqtool_storageinspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,42 +128,52 @@ bool resetIterator(mqbs::MappedFileDescriptor* mfd,
/// opened by the iterator. Verify that the file and iterator are in a
/// valid state; reset them if this is not the case. Pass parameters to
/// indicate how many records to skip and whether that is forward
/// or backwards. Return true on success and false on error.
/// or backwards.
template <typename CHOICE, typename ITER>
void iterateNextPosition(CHOICE& choice,
mqbs::MappedFileDescriptor* mfd,
ITER* iter,
const char* filename)
mqbs::MappedFileDescriptor *mfd,
ITER *iter,
const char *filename)
{
int skip = -1;
bool reverse = false;
bool verbose = false;
bsls::Types::Uint64 skip = 0;
bool reverse = false;
bool verbose = false;

switch (choice.selectionId()) {
case CHOICE::SELECTION_ID_N: {
case CHOICE::SELECTION_ID_N: {
reverse = false;
skip = choice.n();
} break;
case CHOICE::SELECTION_ID_NEXT: {
} break;
case CHOICE::SELECTION_ID_NEXT: {
reverse = false;
skip = choice.next();
} break;
case CHOICE::SELECTION_ID_P: {
} break;
case CHOICE::SELECTION_ID_P: {
reverse = true;
skip = choice.p();
} break;
case CHOICE::SELECTION_ID_PREV: {
} break;
case CHOICE::SELECTION_ID_PREV: {
reverse = true;
skip = choice.prev();
} break;
case CHOICE::SELECTION_ID_RECORD: {
} break;
case CHOICE::SELECTION_ID_RECORD: {
skip = choice.record();
} break;
case CHOICE::SELECTION_ID_R: {
if (skip == -1) {
skip = choice.r();

if (skip >= iter->recordIndex()) {
// If the skip is greater than our current index, than we are
// iterating forward to reach the specified index.
skip -= iter->recordIndex();
reverse = false;
}
if (skip >= static_cast<int>(iter->recordIndex())) {
else {
skip = iter->recordIndex() - skip;
reverse = true;
}
} break;
case CHOICE::SELECTION_ID_R: {
skip = choice.r();

if (skip >= iter->recordIndex()) {
// If the skip is greater than our current index, than we are
// iterating forward to reach the specified index.
skip -= iter->recordIndex();
Expand All @@ -173,30 +183,32 @@ void iterateNextPosition(CHOICE& choice,
skip = iter->recordIndex() - skip;
reverse = true;
}
} break;
case CHOICE::SELECTION_ID_LIST: {
skip = choice.list();
verbose = true;
if (skip >= 0) {
} break;
case CHOICE::SELECTION_ID_LIST: {
int list = choice.list();
verbose = true;
if (list >= 0) {
reverse = false;
}
else {
reverse = true;
skip *= -1;
list *= -1;
}
} break;
case CHOICE::SELECTION_ID_L: {
skip = choice.l();
verbose = true;
if (skip >= 0) {
skip = list;
} break;
case CHOICE::SELECTION_ID_L: {
int list = choice.l();
verbose = true;
if (list >= 0) {
reverse = false;
}
else {
reverse = true;
skip *= -1;
list *= -1;
}
} break;
default:
skip = list;
} break;
default:
BALL_LOG_ERROR << "Unsupported choice: " << choice.selectionId();
return; // RETURN
}
Expand Down

0 comments on commit 1dd5d08

Please sign in to comment.