Skip to content

Commit 80a3f27

Browse files
committed
fixed/adjed to comply with -Wextra by clang-10
1 parent c55b5d7 commit 80a3f27

File tree

10 files changed

+38
-29
lines changed

10 files changed

+38
-29
lines changed

src/c/lib/swcdb/pam/pam_swcdb_max_retries.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ bool swcdb_pam_confirm_state(swc_pam_cfg* cfg, const char* pam_rhost) {
181181
bool adj = tries < 0;
182182
allowed = tries == 0 || !adj || tries <= cfg->maxtries;
183183

184-
gchar* update;
184+
gchar* update = NULL;
185185
len = g_snprintf(update, 1024,
186186
"update cell(INSERT,'%s', %s, '', '%s%d')",
187187
cfg->column,
@@ -190,7 +190,7 @@ bool swcdb_pam_confirm_state(swc_pam_cfg* cfg, const char* pam_rhost) {
190190
adj ? cfg->maxtries : 1
191191
);
192192
g_free(key);
193-
if(!len) {
193+
if(!len || !update) {
194194
swcdb_pam_disconnect(&client, cfg);
195195
return allowed;
196196
}
@@ -234,10 +234,10 @@ void swcdb_pam_reduce_attempt(swc_pam_cfg* cfg, const char* pam_rhost) {
234234
return;
235235
}
236236

237-
gchar* update;
237+
gchar* update = NULL;
238238
len = g_snprintf(update, 1024,
239239
"update cell(INSERT,'%s', %s, '', '=0'", cfg->column, key);
240-
if(!len) {
240+
if(!len || !update) {
241241
g_free(key);
242242
swcdb_pam_disconnect(&client, cfg);
243243
return;

src/cc/include/swcdb/core/config/Properties.h

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ namespace SWC {
2020
class Properties {
2121

2222
typedef std::map<std::string, Property::Value::Ptr> Map;
23-
typedef std::pair<std::string, Property::Value::Ptr> MapPair;
2423
typedef std::map<std::string, std::string> AliasMap;
2524
typedef std::pair<Map::iterator, bool> InsRet;
2625

src/cc/include/swcdb/core/config/PropertiesParser.h

-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ class ParserConfig final {
7070
};
7171

7272
typedef std::map<std::string, ParserOpt> Map;
73-
typedef std::pair<std::string, ParserOpt> MapPair;
7473
typedef std::vector<std::pair<int, std::string>> Positions;
7574

7675
public:

src/cc/include/swcdb/thrift/broker/AppContext.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class AppContext final : virtual public BrokerIfFactory {
5252
m_cv.wait(lock_wait, [this]{return !m_run;});
5353
}
5454

55-
BrokerIf* getHandler(const thrift::TConnectionInfo&) { //connInfo
55+
BrokerIf* getHandler(const thrift::TConnectionInfo&) override { //connInfo
5656
return new AppHandler;
5757
}
5858

src/cc/lib/swcdb/core/config/PropertiesParser.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ std::string ParserConfig::position_name(int n) {
212212
}
213213

214214
bool ParserConfig::has(const std::string& name) const {
215-
for(const MapPair& info : options) {
215+
for(const auto& info : options) {
216216
if(name.compare(info.first) == 0)
217217
return true;
218218
for(const std::string& alias : info.second.aliases)
@@ -223,7 +223,7 @@ bool ParserConfig::has(const std::string& name) const {
223223
}
224224

225225
bool ParserConfig::has(const std::string& name, std::string& alias_to) const {
226-
for(const MapPair& info : options) {
226+
for(const auto& info : options) {
227227
if(name.compare(info.first) == 0)
228228
return true;
229229
for(const std::string& alias : info.second.aliases)
@@ -236,7 +236,7 @@ bool ParserConfig::has(const std::string& name, std::string& alias_to) const {
236236
}
237237

238238
Property::Value::Ptr ParserConfig::get_default(const std::string& name){
239-
for(const MapPair& info : options) {
239+
for(const auto& info : options) {
240240
if(name.compare(info.first) == 0)
241241
return info.second.value;
242242
for(const std::string& alias : info.second.aliases)

src/cc/lib/swcdb/db/Cells/Mutable.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ void Mutable::scan_test_use(const Specs::Interval& specs,
516516
cell.write(result);
517517
if(++count == specs.flags.limit)
518518
// specs.flags.limit_by && specs.flags.max_versions
519-
break;
519+
break;
520520
} else
521521
++skips;
522522
}

tests/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ include_directories(
1616

1717
set(TEST_DIFF ${CMAKE_CURRENT_SOURCE_DIR}/testutils/testdiff)
1818

19+
get_property(SWC_VERSION_SRC GLOBAL PROPERTY SWC_VERSION_SRC)
1920
get_property(SWC_LIB_CORE_SHARED GLOBAL PROPERTY SWC_LIB_CORE_SHARED)
2021
get_property(SWC_LIB_CORE_STATIC GLOBAL PROPERTY SWC_LIB_CORE_STATIC)
2122

tests/libswcdb/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ ADD_TEST_TARGET(
4242
ADD_TEST_TARGET(
4343
NAME key_comparator_impl_src
4444
SRCS test_key_comparator.cc
45+
${SWC_VERSION_SRC}
4546
SHARED ${SWC_LIB_CORE_SHARED}
4647
STATIC ${SWC_LIB_CORE_STATIC}
4748
FLAGS "-DSWC_IMPL_SOURCE"

tests/libswcdb/test_cell_key.cc

+9-9
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ void load_check_key(int chks, int num_fractions, int chk_count) {
213213

214214
auto ts = std::chrono::system_clock::now();
215215
for(auto b=0;b<num_fractions;++b)
216-
key.add(std::to_string(b+(2^60)));
216+
key.add(std::to_string(b+(1LL << 60)));
217217
took_add += std::chrono::duration_cast<std::chrono::nanoseconds>(
218218
std::chrono::system_clock::now() - ts).count();
219219

@@ -231,7 +231,7 @@ void load_check_key(int chks, int num_fractions, int chk_count) {
231231

232232
ts = std::chrono::system_clock::now();
233233
for(auto b=0;b<num_fractions;++b)
234-
key.insert(0, std::to_string(b+(2^60)));
234+
key.insert(0, std::to_string(b+(1LL << 60)));
235235
took_insert += std::chrono::duration_cast<std::chrono::nanoseconds>(
236236
std::chrono::system_clock::now() - ts).count();
237237
}
@@ -240,7 +240,7 @@ void load_check_key(int chks, int num_fractions, int chk_count) {
240240

241241
DB::Cell::Key key;
242242
for(auto b=0; b<num_fractions; ++b)
243-
key.add(std::to_string(b+(2^60)));
243+
key.add(std::to_string(b+(1LL << 60)));
244244

245245
size_t sz = sizeof(key)+key.size;
246246

@@ -270,7 +270,7 @@ void load_check_key_vec(int chks, int num_fractions, int chk_count) {
270270

271271
auto ts = std::chrono::system_clock::now();
272272
for(auto b=0;b<num_fractions;++b)
273-
key.add(std::to_string(b+(2^60)));
273+
key.add(std::to_string(b+(1LL << 60)));
274274
took_add += std::chrono::duration_cast<std::chrono::nanoseconds>(
275275
std::chrono::system_clock::now() - ts).count();
276276

@@ -288,7 +288,7 @@ void load_check_key_vec(int chks, int num_fractions, int chk_count) {
288288

289289
ts = std::chrono::system_clock::now();
290290
for(auto b=0;b<num_fractions;++b)
291-
key.insert(0, std::to_string(b+(2^60)));
291+
key.insert(0, std::to_string(b+(1LL << 60)));
292292
took_insert += std::chrono::duration_cast<std::chrono::nanoseconds>(
293293
std::chrono::system_clock::now() - ts).count();
294294
}
@@ -298,7 +298,7 @@ void load_check_key_vec(int chks, int num_fractions, int chk_count) {
298298
DB::Cell::KeyVec key;
299299
size_t sz = sizeof(key);
300300
for(auto b=0; b<num_fractions; ++b) {
301-
key.add(std::to_string(b+(2^60)));
301+
key.add(std::to_string(b+(1LL << 60)));
302302
sz += sizeof(key.back()) + key.back().length();
303303
}
304304

@@ -327,7 +327,7 @@ void load_check_vec(int chks, int num_fractions, int chk_count) {
327327

328328
auto ts = std::chrono::system_clock::now();
329329
for(auto b=0;b<num_fractions;++b)
330-
key.push_back(std::to_string(b+(2^60)));
330+
key.push_back(std::to_string(b+(1LL << 60)));
331331
took_add += std::chrono::duration_cast<std::chrono::nanoseconds>(
332332
std::chrono::system_clock::now() - ts).count();
333333

@@ -346,7 +346,7 @@ void load_check_vec(int chks, int num_fractions, int chk_count) {
346346

347347
ts = std::chrono::system_clock::now();
348348
for(auto b=0;b<num_fractions;++b)
349-
key.insert(key.begin(), std::to_string(b+(2^60)));
349+
key.insert(key.begin(), std::to_string(b+(1LL << 60)));
350350
took_insert += std::chrono::duration_cast<std::chrono::nanoseconds>(
351351
std::chrono::system_clock::now() - ts).count();
352352
}
@@ -355,7 +355,7 @@ void load_check_vec(int chks, int num_fractions, int chk_count) {
355355
std::vector<std::string> key;
356356
size_t sz = 0;
357357
for(auto b=0; b<num_fractions; ++b) {
358-
key.push_back(std::to_string(b+(2^60)));
358+
key.push_back(std::to_string(b+(1LL << 60)));
359359
sz += sizeof(key.back()) + key.back().length();
360360
}
361361
sz += sizeof(key);

tests/libswcdb_core/sertest.cc

+18-9
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ void test_i16() {
6565
SWC_ASSERT(len == 0));
6666
}
6767
ns = Time::now_ns() - ns;
68-
std::cout << "i16 took=" << ns << " avg=" << (double)ns / UINT16_MAX << "\n";
68+
std::cout << "i16 took=" << ns
69+
<< " avg=" << (double)ns / UINT16_MAX << "\n";
6970
}
7071

7172
void test_i24() {
@@ -90,7 +91,8 @@ void test_i24() {
9091
SWC_ASSERT(len == 0));
9192
}
9293
ns = Time::now_ns() - ns;
93-
std::cout << "i24 took=" << ns << " avg=" << (double)ns / UINT24_MAX << "\n";
94+
std::cout << "i24 took=" << ns
95+
<< " avg=" << (double)ns / UINT24_MAX << "\n";
9496
}
9597

9698
void test_i32() {
@@ -115,7 +117,8 @@ void test_i32() {
115117
SWC_ASSERT(len == 0));
116118
}
117119
ns = Time::now_ns() - ns;
118-
std::cout << "i32 took=" << ns << " avg=" << (double)ns / UINT32_MAX << "\n";
120+
std::cout << "i32 took=" << ns
121+
<< " avg=" << (double)ns / UINT32_MAX << "\n";
119122
}
120123

121124
void test_i64() {
@@ -140,7 +143,8 @@ void test_i64() {
140143
SWC_ASSERT(len == 0));
141144
}
142145
ns = Time::now_ns() - ns;
143-
std::cout << "i64 took=" << ns << " avg=" << (double)ns / UINT64_MAX << "\n";
146+
std::cout << "i64 took=" << ns .
147+
<< " avg=" << double(ns) / double(UINT64_MAX) << "\n";
144148
}
145149

146150
void chk_vi24(uint24_t n) {
@@ -175,7 +179,8 @@ void test_vi24() {
175179
++c;
176180
}
177181
ns = Time::now_ns() - ns;
178-
std::cout << "vi24 took=" << ns << " avg=" << (double)ns / c << " c=" << c << "\n";
182+
std::cout << "vi24 took=" << ns
183+
<< " avg=" << (double)ns / c << " c=" << c << "\n";
179184
}
180185

181186
void chk_vi32(uint32_t n) {
@@ -209,7 +214,8 @@ void test_vi32() {
209214
++c;
210215
}
211216
ns = Time::now_ns() - ns;
212-
std::cout << "vi32 lower took=" << ns << " avg=" << (double)ns / c << " c=" << c << "\n";
217+
std::cout << "vi32 lower took=" << ns
218+
<< " avg=" << (double)ns / c << " c=" << c << "\n";
213219
c = 0;
214220
ns = Time::now_ns();
215221
for(uint32_t p=0; p<PROBES;++p)
@@ -220,7 +226,8 @@ void test_vi32() {
220226
break;
221227
}
222228
ns = Time::now_ns() - ns;
223-
std::cout << "vi32 upper took=" << ns << " avg=" << (double)ns / c << " c=" << c << "\n";
229+
std::cout << "vi32 upper took=" << ns
230+
<< " avg=" << (double)ns / c << " c=" << c << "\n";
224231
}
225232

226233
void chk_vi64(uint64_t n) {
@@ -254,7 +261,8 @@ void test_vi64() {
254261
++c;
255262
}
256263
ns = Time::now_ns() - ns;
257-
std::cout << "vi64 lower took=" << ns << " avg=" << (double)ns / c << " c=" << c << "\n";
264+
std::cout << "vi64 lower took=" << ns
265+
<< " avg=" << (double)ns / c << " c=" << c << "\n";
258266
c = 0;
259267
ns = Time::now_ns();
260268
for(uint32_t p=0; p<PROBES;++p)
@@ -265,7 +273,8 @@ void test_vi64() {
265273
break;
266274
}
267275
ns = Time::now_ns() - ns;
268-
std::cout << "vi64 upper took=" << ns << " avg=" << (double)ns / c << " c=" << c << "\n";
276+
std::cout << "vi64 upper took=" << ns
277+
<< " avg=" << (double)ns / c << " c=" << c << "\n";
269278
}
270279

271280
void test_str16() {

0 commit comments

Comments
 (0)