Skip to content

Commit 5e2f7fa

Browse files
committed
Fix uninitialized variable warnings in sync queue tests.
1 parent a080cb5 commit 5e2f7fa

6 files changed

Lines changed: 45 additions & 46 deletions

File tree

test/sync/mutual_exclusion/sync_bounded_queue/single_thread_pass.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ int main()
162162
// 1-element queue pull succeed
163163
boost::sync_bounded_queue<int> q(2);
164164
q.push(1);
165-
int i;
165+
int i = -1;
166166
q.pull(i);
167167
BOOST_TEST_EQ(i, 1);
168168
BOOST_TEST(q.empty());
@@ -198,7 +198,7 @@ int main()
198198
// 1-element queue try_pull succeed
199199
boost::sync_bounded_queue<int> q(2);
200200
q.push(1);
201-
int i;
201+
int i = -1;
202202
BOOST_TEST(q.try_pull(i));
203203
BOOST_TEST_EQ(i, 1);
204204
BOOST_TEST(q.empty());
@@ -210,7 +210,7 @@ int main()
210210
// 1-element queue try_pull succeed
211211
boost::sync_bounded_queue<int> q(2);
212212
q.push(1);
213-
int i;
213+
int i = -1;
214214
BOOST_TEST(q.try_pull(boost::no_block, i));
215215
BOOST_TEST_EQ(i, 1);
216216
BOOST_TEST(q.empty());
@@ -280,7 +280,7 @@ int main()
280280
boost::sync_bounded_queue<int> q(2);
281281
q.push(1);
282282
q.close();
283-
int i;
283+
int i = -1;
284284
q.pull(i);
285285
BOOST_TEST_EQ(i, 1);
286286
BOOST_TEST(q.empty());
@@ -292,7 +292,7 @@ int main()
292292
{
293293
// empty queue try_pull fails
294294
boost::sync_bounded_queue<int> q(2);
295-
int i;
295+
int i = -1;
296296
BOOST_TEST( boost::queue_op_status::empty == q.try_pull_front(i));
297297
BOOST_TEST(q.empty());
298298
BOOST_TEST(! q.full());
@@ -422,7 +422,7 @@ int main()
422422
// 1-element queue pull succeed
423423
boost::sync_bounded_queue<int> q(2);
424424
q.push_back(1);
425-
int i;
425+
int i = -1;
426426
q.pull_front(i);
427427
BOOST_TEST_EQ(i, 1);
428428
BOOST_TEST(q.empty());
@@ -458,7 +458,7 @@ int main()
458458
// 1-element queue try_pull succeed
459459
boost::sync_bounded_queue<int> q(2);
460460
q.push_back(1);
461-
int i;
461+
int i = -1;
462462
BOOST_TEST(boost::queue_op_status::success == q.try_pull_front(i));
463463
BOOST_TEST_EQ(i, 1);
464464
BOOST_TEST(q.empty());
@@ -470,7 +470,7 @@ int main()
470470
// 1-element queue nonblocking_pull_front succeed
471471
boost::sync_bounded_queue<int> q(2);
472472
q.push_back(1);
473-
int i;
473+
int i = -1;
474474
BOOST_TEST(boost::queue_op_status::success == q.nonblocking_pull_front(i));
475475
BOOST_TEST_EQ(i, 1);
476476
BOOST_TEST(q.empty());
@@ -482,7 +482,7 @@ int main()
482482
// 1-element queue wait_pull_front succeed
483483
boost::sync_bounded_queue<int> q(2);
484484
q.push_back(1);
485-
int i;
485+
int i = -1;
486486
BOOST_TEST(boost::queue_op_status::success == q.wait_pull_front(i));
487487
BOOST_TEST_EQ(i, 1);
488488
BOOST_TEST(q.empty());
@@ -529,7 +529,7 @@ int main()
529529
// closed empty queue try_pull_front closed
530530
boost::sync_bounded_queue<int> q(2);
531531
q.close();
532-
int i;
532+
int i = -1;
533533
BOOST_TEST(boost::queue_op_status::closed == q.try_pull_front(i));
534534
BOOST_TEST(q.empty());
535535
BOOST_TEST(! q.full());
@@ -540,7 +540,7 @@ int main()
540540
// closed empty queue nonblocking_pull_front closed
541541
boost::sync_bounded_queue<int> q(2);
542542
q.close();
543-
int i;
543+
int i = -1;
544544
BOOST_TEST(boost::queue_op_status::closed == q.nonblocking_pull_front(i));
545545
BOOST_TEST(q.empty());
546546
BOOST_TEST(! q.full());
@@ -552,7 +552,7 @@ int main()
552552
boost::sync_bounded_queue<int> q(2);
553553
q.push_back(1);
554554
q.close();
555-
int i;
555+
int i = -1;
556556
q.pull_front(i);
557557
BOOST_TEST_EQ(i, 1);
558558
BOOST_TEST(q.empty());
@@ -565,7 +565,7 @@ int main()
565565
boost::sync_bounded_queue<int> q(2);
566566
q.push_back(1);
567567
q.close();
568-
int i;
568+
int i = -1;
569569
BOOST_TEST(boost::queue_op_status::success == q.wait_pull_front(i));
570570
BOOST_TEST_EQ(i, 1);
571571
BOOST_TEST(q.empty());
@@ -579,7 +579,7 @@ int main()
579579
q.close();
580580
BOOST_TEST(q.empty());
581581
BOOST_TEST(q.closed());
582-
int i;
582+
int i = -1;
583583
BOOST_TEST(boost::queue_op_status::closed == q.wait_pull_front(i));
584584
BOOST_TEST(q.empty());
585585
BOOST_TEST(q.closed());
@@ -595,6 +595,6 @@ int main()
595595
BOOST_TEST(q.empty());
596596
BOOST_TEST(q.closed());
597597
}
598+
598599
return boost::report_errors();
599600
}
600-

test/sync/mutual_exclusion/sync_deque/single_thread_pass.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ int main()
4949
{
5050
// empty queue try_pull fails
5151
boost::sync_deque<int> q;
52-
int i;
52+
int i = -1;
5353
BOOST_TEST( boost::queue_op_status::empty == q.try_pull_front(i));
5454
BOOST_TEST(q.empty());
5555
BOOST_TEST(! q.full());
@@ -204,7 +204,7 @@ int main()
204204
// 1-element queue pull_front succeed
205205
boost::sync_deque<int> q;
206206
q.push_back(1);
207-
int i;
207+
int i = -1;
208208
q.pull_front(i);
209209
BOOST_TEST_EQ(i, 1);
210210
BOOST_TEST(q.empty());
@@ -252,7 +252,7 @@ int main()
252252
// 1-element queue try_pull_front succeed
253253
boost::sync_deque<int> q;
254254
q.push_back(1);
255-
int i;
255+
int i = -1;
256256
BOOST_TEST(boost::queue_op_status::success == q.try_pull_front(i));
257257
BOOST_TEST_EQ(i, 1);
258258
BOOST_TEST(q.empty());
@@ -277,7 +277,7 @@ int main()
277277
// 1-element queue nonblocking_pull_front succeed
278278
boost::sync_deque<int> q;
279279
q.push_back(1);
280-
int i;
280+
int i = -1;
281281
BOOST_TEST(boost::queue_op_status::success == q.nonblocking_pull_front(i));
282282
BOOST_TEST_EQ(i, 1);
283283
BOOST_TEST(q.empty());
@@ -315,7 +315,7 @@ int main()
315315
// 1-element queue wait_pull_front succeed
316316
boost::sync_deque<int> q;
317317
q.push_back(1);
318-
int i;
318+
int i = -1;
319319
BOOST_TEST(boost::queue_op_status::success == q.wait_pull_front(i));
320320
BOOST_TEST_EQ(i, 1);
321321
BOOST_TEST(q.empty());
@@ -365,7 +365,7 @@ int main()
365365
boost::sync_deque<int> q;
366366
q.push_back(1);
367367
q.close();
368-
int i;
368+
int i = -1;
369369
q.pull_front(i);
370370
BOOST_TEST_EQ(i, 1);
371371
BOOST_TEST(q.empty());
@@ -378,7 +378,7 @@ int main()
378378
boost::sync_deque<int> q;
379379
q.push_back(1);
380380
q.close();
381-
int i;
381+
int i = -1;
382382
BOOST_TEST(boost::queue_op_status::success == q.wait_pull_front(i));
383383
BOOST_TEST_EQ(i, 1);
384384
BOOST_TEST(q.empty());
@@ -392,12 +392,11 @@ int main()
392392
q.close();
393393
BOOST_TEST(q.empty());
394394
BOOST_TEST(q.closed());
395-
int i;
395+
int i = -1;
396396
BOOST_TEST(boost::queue_op_status::closed == q.wait_pull_front(i));
397397
BOOST_TEST(q.empty());
398398
BOOST_TEST(q.closed());
399399
}
400400

401401
return boost::report_errors();
402402
}
403-

test/sync/mutual_exclusion/sync_pq/pq_single_thread_pass.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ void test_pull_for()
5555
{
5656
sync_pq pq;
5757
steady_clock::time_point start = steady_clock::now();
58-
int val;
58+
int val = -1;
5959
boost::queue_op_status st = pq.pull_for(milliseconds(500), val);
6060
ns d = steady_clock::now() - start - milliseconds(500);
6161
BOOST_THREAD_TEST_IT(d, ns(max_diff));
@@ -66,7 +66,7 @@ void test_pull_until()
6666
{
6767
sync_pq pq;
6868
steady_clock::time_point start = steady_clock::now();
69-
int val;
69+
int val = -1;
7070
boost::queue_op_status st = pq.pull_until(start + milliseconds(500), val);
7171
ns d = steady_clock::now() - start - milliseconds(500);
7272
BOOST_THREAD_TEST_IT(d, ns(max_diff));
@@ -77,7 +77,7 @@ void test_nonblocking_pull()
7777
{
7878
sync_pq pq;
7979
steady_clock::time_point start = steady_clock::now();
80-
int val;
80+
int val = -1;
8181
boost::queue_op_status st = pq.nonblocking_pull(val);
8282
ns d = steady_clock::now() - start;
8383
BOOST_THREAD_TEST_IT(d, ns(max_diff));
@@ -89,7 +89,7 @@ void test_pull_for_when_not_empty()
8989
sync_pq pq;
9090
pq.push(1);
9191
steady_clock::time_point start = steady_clock::now();
92-
int val;
92+
int val = -1;
9393
boost::queue_op_status st = pq.pull_for(milliseconds(500), val);
9494
ns d = steady_clock::now() - start;
9595
BOOST_THREAD_TEST_IT(d, ns(max_diff));
@@ -102,7 +102,7 @@ void test_pull_until_when_not_empty()
102102
sync_pq pq;
103103
pq.push(1);
104104
steady_clock::time_point start = steady_clock::now();
105-
int val;
105+
int val = -1;
106106
boost::queue_op_status st = pq.pull_until(start + milliseconds(500), val);
107107
ns d = steady_clock::now() - start;
108108
BOOST_THREAD_TEST_IT(d, ns(max_diff));
@@ -274,7 +274,7 @@ int main()
274274
// 1-element queue try_pull succeed
275275
boost::concurrent::sync_priority_queue<int> q;
276276
q.push(1);
277-
int i;
277+
int i = -1;
278278
BOOST_TEST(boost::queue_op_status::success == q.try_pull(i));
279279
BOOST_TEST_EQ(i, 1);
280280
BOOST_TEST(q.empty());
@@ -301,7 +301,7 @@ int main()
301301
// 1-element queue nonblocking_pull succeed
302302
boost::concurrent::sync_priority_queue<int> q;
303303
q.push(1);
304-
int i;
304+
int i = -1;
305305
BOOST_TEST(boost::queue_op_status::success == q.nonblocking_pull(i));
306306
BOOST_TEST_EQ(i, 1);
307307
BOOST_TEST(q.empty());
@@ -341,7 +341,7 @@ int main()
341341
// 1-element queue wait_pull succeed
342342
boost::concurrent::sync_priority_queue<int> q;
343343
q.push(1);
344-
int i;
344+
int i = -1;
345345
BOOST_TEST(boost::queue_op_status::success == q.wait_pull(i));
346346
BOOST_TEST_EQ(i, 1);
347347
BOOST_TEST(q.empty());
@@ -406,7 +406,7 @@ int main()
406406
boost::concurrent::sync_priority_queue<int> q;
407407
q.push(1);
408408
q.close();
409-
int i;
409+
int i = -1;
410410
BOOST_TEST(boost::queue_op_status::success == q.wait_pull(i));
411411
BOOST_TEST_EQ(i, 1);
412412
BOOST_TEST(q.empty());
@@ -420,7 +420,7 @@ int main()
420420
q.close();
421421
BOOST_TEST(q.empty());
422422
BOOST_TEST(q.closed());
423-
int i;
423+
int i = -1;
424424
BOOST_TEST(boost::queue_op_status::closed == q.wait_pull(i));
425425
BOOST_TEST(q.empty());
426426
BOOST_TEST(q.closed());

test/sync/mutual_exclusion/sync_pq/tq_multi_thread_pass.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void call_pull(sync_tq* q, const steady_clock::time_point start)
4343
// pull elements off of the queue (earliest element first)
4444
for (int i = cnt - 1; i >= 0; --i)
4545
{
46-
int j;
46+
int j = -1;
4747
q->pull(j);
4848
BOOST_TEST_EQ(i, j);
4949
const steady_clock::time_point expected = start + milliseconds(i * 500) + seconds(cnt - i);
@@ -57,7 +57,7 @@ void call_pull_until(sync_tq* q, const steady_clock::time_point start)
5757
// pull elements off of the queue (earliest element first)
5858
for (int i = cnt - 1; i >= 0; --i)
5959
{
60-
int j;
60+
int j = -1;
6161
q->pull_until(steady_clock::now() + hours(1), j);
6262
BOOST_TEST_EQ(i, j);
6363
const steady_clock::time_point expected = start + milliseconds(i * 500) + seconds(cnt - i);
@@ -71,7 +71,7 @@ void call_pull_for(sync_tq* q, const steady_clock::time_point start)
7171
// pull elements off of the queue (earliest element first)
7272
for (int i = cnt - 1; i >= 0; --i)
7373
{
74-
int j;
74+
int j = -1;
7575
q->pull_for(hours(1), j);
7676
BOOST_TEST_EQ(i, j);
7777
const steady_clock::time_point expected = start + milliseconds(i * 500) + seconds(cnt - i);

test/sync/mutual_exclusion/sync_pq/tq_single_thread_pass.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void test_all()
5050
BOOST_TEST_EQ(val, i);
5151
}
5252

53-
int val;
53+
int val = -1;
5454
boost::queue_op_status st = pq.nonblocking_pull(val);
5555
BOOST_TEST(boost::queue_op_status::empty == st);
5656

@@ -87,7 +87,7 @@ void test_all_with_try()
8787
BOOST_TEST_EQ(val, i);
8888
}
8989

90-
int val;
90+
int val = -1;
9191
boost::queue_op_status st = pq.nonblocking_pull(val);
9292
BOOST_TEST(st == boost::queue_op_status::empty );
9393

0 commit comments

Comments
 (0)