Skip to content

Commit f20152f

Browse files
committed
build: support -Wshadow
1 parent 067ce92 commit f20152f

File tree

6 files changed

+28
-29
lines changed

6 files changed

+28
-29
lines changed

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ FIND_PACKAGE (benchmark QUIET)
1111

1212
SET(CMAKE_CXX_STANDARD 17)
1313
SET(CMAKE_C_STANDARD 11)
14-
ADD_COMPILE_OPTIONS(-Wall -Wextra -Werror)
14+
ADD_COMPILE_OPTIONS(-Wall -Wextra -Werror -Wshadow)
1515

1616
ADD_LIBRARY(tntcxx INTERFACE)
1717
ADD_LIBRARY(tntcxx::tntcxx ALIAS tntcxx)

examples/Simple.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ main()
155155
uint32_t limit = 1;
156156
uint32_t offset = 0;
157157
IteratorType iter = IteratorType::EQ;
158-
auto i = conn.space[space_id].index[index_id];
159-
rid_t select = i.select(std::make_tuple(pk_value), limit, offset, iter);
158+
auto index = conn.space[space_id].index[index_id];
159+
rid_t select = index.select(std::make_tuple(pk_value), limit, offset, iter);
160160
//doclabel09-2
161161
/*
162162
* Now let's send our requests to the server. There are two options

examples/Sql.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,7 @@ main()
226226
client.waitAll(conn, prepared_select_futures);
227227
for (size_t i = 0; i < prepared_select_futures.size(); ++i) {
228228
assert(conn.futureIsReady(prepared_select_futures[i]));
229-
Response<Buf_t> response =
230-
conn.getResponse(prepared_select_futures[i]);
229+
response = conn.getResponse(prepared_select_futures[i]);
231230
printResponse<Buf_t>(response);
232231
}
233232

test/BufferUnitTest.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -541,8 +541,8 @@ buffer_release()
541541
* should remain unchanged.
542542
*/
543543
int i = 0;
544-
for (auto tmp = buf.begin(); tmp < mid_itr; ++tmp) {
545-
tmp.get(res);
544+
for (auto tmp_it = buf.begin(); tmp_it < mid_itr; ++tmp_it) {
545+
tmp_it.get(res);
546546
fail_unless(res == char_samples[i++ % SAMPLES_CNT]);
547547
}
548548
}

test/ClientTest.cpp

+21-21
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
#include "../src/Client/Connector.hpp"
3737

3838
const char *localhost = "127.0.0.1";
39-
unsigned port = 3301;
39+
unsigned tarantool_port = 3301;
4040
unsigned dummy_server_port = 3302;
4141
const char *unixsocket = "./tnt.sock";
4242
int WAIT_TIMEOUT = 1000; //milliseconds
@@ -154,16 +154,16 @@ trivial(Connector<BUFFER, NetProvider> &client)
154154
fail_unless(rc != 0);
155155
/* Connect to the wrong address. */
156156
TEST_CASE("Bad address");
157-
rc = test_connect(client, conn, "asdasd", port);
157+
rc = test_connect(client, conn, "asdasd", tarantool_port);
158158
fail_unless(rc != 0);
159159
TEST_CASE("Unreachable address");
160-
rc = test_connect(client, conn, "101.101.101", port);
160+
rc = test_connect(client, conn, "101.101.101", tarantool_port);
161161
fail_unless(rc != 0);
162162
TEST_CASE("Wrong port");
163163
rc = test_connect(client, conn, localhost, static_cast<uint>(-666));
164164
fail_unless(rc != 0);
165165
TEST_CASE("Connect timeout");
166-
rc = test_connect(client, conn, "8.8.8.8", port);
166+
rc = test_connect(client, conn, "8.8.8.8", tarantool_port);
167167
fail_unless(rc != 0);
168168
}
169169

@@ -174,7 +174,7 @@ single_conn_ping(Connector<BUFFER, NetProvider> &client)
174174
{
175175
TEST_INIT(0);
176176
Connection<Buf_t, NetProvider> conn(client);
177-
int rc = test_connect(client, conn, localhost, port);
177+
int rc = test_connect(client, conn, localhost, tarantool_port);
178178
fail_unless(rc == 0);
179179
rid_t f = conn.ping();
180180
fail_unless(!conn.futureIsReady(f));
@@ -228,13 +228,13 @@ auto_close(Connector<BUFFER, NetProvider> &client)
228228
{
229229
TEST_CASE("Without requests");
230230
Connection<Buf_t, NetProvider> conn(client);
231-
int rc = test_connect(client, conn, localhost, port);
231+
int rc = test_connect(client, conn, localhost, tarantool_port);
232232
fail_unless(rc == 0);
233233
}
234234
{
235235
TEST_CASE("With requests");
236236
Connection<Buf_t, NetProvider> conn(client);
237-
int rc = test_connect(client, conn, localhost, port);
237+
int rc = test_connect(client, conn, localhost, tarantool_port);
238238
fail_unless(rc == 0);
239239

240240
rid_t f = conn.ping();
@@ -255,18 +255,18 @@ many_conn_ping(Connector<BUFFER, NetProvider> &client)
255255
Connection<Buf_t, NetProvider> conn1(client);
256256
Connection<Buf_t, NetProvider> conn2(client);
257257
Connection<Buf_t, NetProvider> conn3(client);
258-
int rc = test_connect(client, conn1, localhost, port);
258+
int rc = test_connect(client, conn1, localhost, tarantool_port);
259259
fail_unless(rc == 0);
260260
/* Try to connect to the same port */
261-
rc = test_connect(client, conn2, localhost, port);
261+
rc = test_connect(client, conn2, localhost, tarantool_port);
262262
fail_unless(rc == 0);
263263
/*
264264
* Try to re-connect to another address whithout closing
265265
* current connection.
266266
*/
267-
//rc = test_connect(client, conn2, localhost, port + 2);
267+
//rc = test_connect(client, conn2, localhost, tarantool_port + 2);
268268
//fail_unless(rc != 0);
269-
rc = test_connect(client, conn3, localhost, port);
269+
rc = test_connect(client, conn3, localhost, tarantool_port);
270270
fail_unless(rc == 0);
271271
rid_t f1 = conn1.ping();
272272
rid_t f2 = conn2.ping();
@@ -287,7 +287,7 @@ single_conn_error(Connector<BUFFER, NetProvider> &client)
287287
{
288288
TEST_INIT(0);
289289
Connection<Buf_t, NetProvider> conn(client);
290-
int rc = test_connect(client, conn, localhost, port);
290+
int rc = test_connect(client, conn, localhost, tarantool_port);
291291
fail_unless(rc == 0);
292292
/* Fake space id. */
293293
uint32_t space_id = static_cast<uint32_t>(-111);
@@ -324,7 +324,7 @@ single_conn_replace(Connector<BUFFER, NetProvider> &client)
324324
{
325325
TEST_INIT(0);
326326
Connection<Buf_t, NetProvider> conn(client);
327-
int rc = test_connect(client, conn, localhost, port);
327+
int rc = test_connect(client, conn, localhost, tarantool_port);
328328
fail_unless(rc == 0);
329329
uint32_t space_id = 512;
330330
std::tuple data = std::make_tuple(666, "111", 1.01);
@@ -358,7 +358,7 @@ single_conn_insert(Connector<BUFFER, NetProvider> &client)
358358
{
359359
TEST_INIT(0);
360360
Connection<Buf_t, NetProvider> conn(client);
361-
int rc = test_connect(client, conn, localhost, port);
361+
int rc = test_connect(client, conn, localhost, tarantool_port);
362362
fail_unless(rc == 0);
363363
TEST_CASE("Successful inserts");
364364
uint32_t space_id = 512;
@@ -402,7 +402,7 @@ single_conn_update(Connector<BUFFER, NetProvider> &client)
402402
{
403403
TEST_INIT(0);
404404
Connection<Buf_t, NetProvider> conn(client);
405-
int rc = test_connect(client, conn, localhost, port);
405+
int rc = test_connect(client, conn, localhost, tarantool_port);
406406
fail_unless(rc == 0);
407407
TEST_CASE("Successful update");
408408
uint32_t space_id = 512;
@@ -437,7 +437,7 @@ single_conn_delete(Connector<BUFFER, NetProvider> &client)
437437
{
438438
TEST_INIT(0);
439439
Connection<Buf_t, NetProvider> conn(client);
440-
int rc = test_connect(client, conn, localhost, port);
440+
int rc = test_connect(client, conn, localhost, tarantool_port);
441441
fail_unless(rc == 0);
442442
TEST_CASE("Successful deletes");
443443
uint32_t space_id = 512;
@@ -481,7 +481,7 @@ single_conn_upsert(Connector<BUFFER, NetProvider> &client)
481481
{
482482
TEST_INIT(0);
483483
Connection<Buf_t, NetProvider> conn(client);
484-
int rc = test_connect(client, conn, localhost, port);
484+
int rc = test_connect(client, conn, localhost, tarantool_port);
485485
fail_unless(rc == 0);
486486
TEST_CASE("upsert-insert");
487487
uint32_t space_id = 512;
@@ -512,7 +512,7 @@ single_conn_select(Connector<BUFFER, NetProvider> &client)
512512
{
513513
TEST_INIT(0);
514514
Connection<Buf_t, NetProvider> conn(client);
515-
int rc = test_connect(client, conn, localhost, port);
515+
int rc = test_connect(client, conn, localhost, tarantool_port);
516516
fail_unless(rc == 0);
517517
uint32_t space_id = 512;
518518
uint32_t index_id = 0;
@@ -575,7 +575,7 @@ single_conn_call(Connector<BUFFER, NetProvider> &client)
575575
const static char *return_map = "remote_map";
576576

577577
Connection<Buf_t, NetProvider> conn(client);
578-
int rc = test_connect(client, conn, localhost, port);
578+
int rc = test_connect(client, conn, localhost, tarantool_port);
579579
fail_unless(rc == 0);
580580

581581
TEST_CASE("call remote_replace");
@@ -746,7 +746,7 @@ single_conn_sql(Connector<BUFFER, NetProvider> &client)
746746
using Body_t = Body<BUFFER>;
747747

748748
Connection<Buf_t, NetProvider> conn(client);
749-
int rc = test_connect(client, conn, localhost, port);
749+
int rc = test_connect(client, conn, localhost, tarantool_port);
750750
fail_unless(rc == 0);
751751

752752
TEST_CASE("CREATE TABLE");
@@ -990,7 +990,7 @@ test_auth(Connector<BUFFER, NetProvider> &client)
990990
const char *passwd = "megapassword";
991991

992992
Connection<Buf_t, NetProvider> conn(client);
993-
int rc = test_connect(client, conn, localhost, port, user, passwd);
993+
int rc = test_connect(client, conn, localhost, tarantool_port, user, passwd);
994994
fail_unless(rc == 0);
995995

996996
uint32_t space_id = 513;

test/ListUnitTest.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ void check(const ObjectList& list, std::vector<int> arr,
246246

247247
if (failed) {
248248
std::cerr << "Check failed: list {";
249-
bool first = true;
249+
first = true;
250250
for (const Object& sObj : list) {
251251
if (!first)
252252
std::cerr << ", " << sObj.m_Data;

0 commit comments

Comments
 (0)