Skip to content

Commit 1dd5d08

Browse files
committed
Fix -WConversion warninigs in bmqtool storage inspector
Signed-off-by: Dmitrii Petukhov <[email protected]>
1 parent bd72cb4 commit 1dd5d08

File tree

1 file changed

+47
-35
lines changed

1 file changed

+47
-35
lines changed

src/applications/bmqtool/m_bmqtool_storageinspector.cpp

Lines changed: 47 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -128,42 +128,52 @@ 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,
134-
mqbs::MappedFileDescriptor* mfd,
135-
ITER* iter,
136-
const char* filename)
134+
mqbs::MappedFileDescriptor *mfd,
135+
ITER *iter,
136+
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()) {
143-
case CHOICE::SELECTION_ID_N: {
143+
case CHOICE::SELECTION_ID_N: {
144144
reverse = false;
145145
skip = choice.n();
146-
} break;
147-
case CHOICE::SELECTION_ID_NEXT: {
146+
} break;
147+
case CHOICE::SELECTION_ID_NEXT: {
148148
reverse = false;
149149
skip = choice.next();
150-
} break;
151-
case CHOICE::SELECTION_ID_P: {
150+
} break;
151+
case CHOICE::SELECTION_ID_P: {
152152
reverse = true;
153153
skip = choice.p();
154-
} break;
155-
case CHOICE::SELECTION_ID_PREV: {
154+
} break;
155+
case CHOICE::SELECTION_ID_PREV: {
156156
reverse = true;
157157
skip = choice.prev();
158-
} break;
159-
case CHOICE::SELECTION_ID_RECORD: {
158+
} break;
159+
case CHOICE::SELECTION_ID_RECORD: {
160160
skip = choice.record();
161-
} break;
162-
case CHOICE::SELECTION_ID_R: {
163-
if (skip == -1) {
164-
skip = choice.r();
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;
165167
}
166-
if (skip >= static_cast<int>(iter->recordIndex())) {
168+
else {
169+
skip = iter->recordIndex() - skip;
170+
reverse = true;
171+
}
172+
} break;
173+
case CHOICE::SELECTION_ID_R: {
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();
@@ -173,30 +183,32 @@ void iterateNextPosition(CHOICE& choice,
173183
skip = iter->recordIndex() - skip;
174184
reverse = true;
175185
}
176-
} break;
177-
case CHOICE::SELECTION_ID_LIST: {
178-
skip = choice.list();
179-
verbose = true;
180-
if (skip >= 0) {
186+
} break;
187+
case CHOICE::SELECTION_ID_LIST: {
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
}
187-
} break;
188-
case CHOICE::SELECTION_ID_L: {
189-
skip = choice.l();
190-
verbose = true;
191-
if (skip >= 0) {
197+
skip = list;
198+
} break;
199+
case CHOICE::SELECTION_ID_L: {
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
}
198-
} break;
199-
default:
209+
skip = list;
210+
} break;
211+
default:
200212
BALL_LOG_ERROR << "Unsupported choice: " << choice.selectionId();
201213
return; // RETURN
202214
}

0 commit comments

Comments
 (0)