Skip to content

Commit 34be90f

Browse files
authored
Fix -WConversion warnings in bmqtool storage inspector (#415)
Signed-off-by: Dmitrii Petukhov <[email protected]>
1 parent 429f272 commit 34be90f

File tree

1 file changed

+28
-16
lines changed

1 file changed

+28
-16
lines changed

src/applications/bmqtool/m_bmqtool_storageinspector.cpp

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -128,16 +128,16 @@ bool resetIterator(mqbs::MappedFileDescriptor* mfd,
128128
/// opened by the iterator. Verify that the file and iterator are in a
129129
/// valid state; reset them if this is not the case. Pass parameters to
130130
/// indicate how many records to skip and whether that is forward
131-
/// or backwards. Return true on success and false on error.
131+
/// or backwards.
132132
template <typename CHOICE, typename ITER>
133133
void iterateNextPosition(CHOICE& choice,
134134
mqbs::MappedFileDescriptor* mfd,
135135
ITER* iter,
136136
const char* filename)
137137
{
138-
int skip = -1;
139-
bool reverse = false;
140-
bool verbose = false;
138+
bsls::Types::Uint64 skip = 0;
139+
bool reverse = false;
140+
bool verbose = false;
141141

142142
switch (choice.selectionId()) {
143143
case CHOICE::SELECTION_ID_N: {
@@ -158,12 +158,22 @@ void iterateNextPosition(CHOICE& choice,
158158
} break;
159159
case CHOICE::SELECTION_ID_RECORD: {
160160
skip = choice.record();
161+
162+
if (skip >= iter->recordIndex()) {
163+
// If the skip is greater than our current index, than we are
164+
// iterating forward to reach the specified index.
165+
skip -= iter->recordIndex();
166+
reverse = false;
167+
}
168+
else {
169+
skip = iter->recordIndex() - skip;
170+
reverse = true;
171+
}
161172
} break;
162173
case CHOICE::SELECTION_ID_R: {
163-
if (skip == -1) {
164-
skip = choice.r();
165-
}
166-
if (skip >= static_cast<int>(iter->recordIndex())) {
174+
skip = choice.r();
175+
176+
if (skip >= iter->recordIndex()) {
167177
// If the skip is greater than our current index, than we are
168178
// iterating forward to reach the specified index.
169179
skip -= iter->recordIndex();
@@ -175,26 +185,28 @@ void iterateNextPosition(CHOICE& choice,
175185
}
176186
} break;
177187
case CHOICE::SELECTION_ID_LIST: {
178-
skip = choice.list();
179-
verbose = true;
180-
if (skip >= 0) {
188+
int list = choice.list();
189+
verbose = true;
190+
if (list >= 0) {
181191
reverse = false;
182192
}
183193
else {
184194
reverse = true;
185-
skip *= -1;
195+
list *= -1;
186196
}
197+
skip = list;
187198
} break;
188199
case CHOICE::SELECTION_ID_L: {
189-
skip = choice.l();
190-
verbose = true;
191-
if (skip >= 0) {
200+
int list = choice.l();
201+
verbose = true;
202+
if (list >= 0) {
192203
reverse = false;
193204
}
194205
else {
195206
reverse = true;
196-
skip *= -1;
207+
list *= -1;
197208
}
209+
skip = list;
198210
} break;
199211
default:
200212
BALL_LOG_ERROR << "Unsupported choice: " << choice.selectionId();

0 commit comments

Comments
 (0)