Skip to content

Commit 7455578

Browse files
committed
Fix -Wparentheses in ExtDS
+ add noexcept
1 parent a9a3373 commit 7455578

File tree

2 files changed

+58
-59
lines changed

2 files changed

+58
-59
lines changed

src/jrd/extds/ExtDS.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,7 @@ int Manager::shutdown()
297297

298298
Provider::Provider(const char* prvName) :
299299
m_name(getPool()),
300-
m_connections(getPool()),
301-
m_flags(0)
300+
m_connections(getPool())
302301
{
303302
m_name = prvName;
304303
}
@@ -342,7 +341,7 @@ void Provider::generateDPB(thread_db* tdbb, ClumpletWriter& dpb,
342341
attachment->att_user->populateDpb(dpb, false);
343342
}
344343

345-
CharSet* const cs = INTL_charset_lookup(tdbb, attachment->att_charset);
344+
const CharSet* const cs = INTL_charset_lookup(tdbb, attachment->att_charset);
346345
if (cs) {
347346
dpb.insertString(isc_dpb_lc_ctype, cs->getName());
348347
}
@@ -842,7 +841,7 @@ void Connection::raise(const FbStatusVector* status, thread_db* /*tdbb*/, const
842841
}
843842

844843

845-
bool Connection::getWrapErrors(const ISC_STATUS* status)
844+
bool Connection::getWrapErrors(const ISC_STATUS* status) noexcept
846845
{
847846
// Detect if connection is broken
848847
switch (status[1])
@@ -1989,7 +1988,7 @@ void Statement::deallocate(thread_db* tdbb)
19891988

19901989
enum TokenType {ttNone, ttWhite, ttComment, ttBrokenComment, ttString, ttParamMark, ttIdent, ttOther};
19911990

1992-
static TokenType getToken(const char** begin, const char* end)
1991+
static TokenType getToken(const char** begin, const char* end) noexcept
19931992
{
19941993
TokenType ret = ttNone;
19951994
const char* p = *begin;
@@ -2239,7 +2238,7 @@ void Statement::setInParams(thread_db* tdbb, const MetaName* const* names,
22392238
const FB_SIZE_T excCount = in_excess ? in_excess->getCount() : 0;
22402239
const FB_SIZE_T sqlCount = m_sqlParamNames.getCount();
22412240

2242-
if (m_error = (!names && sqlCount))
2241+
if ((m_error = (!names && sqlCount)))
22432242
{
22442243
// Parameter name expected
22452244
ERR_post(Arg::Gds(isc_eds_prm_name_expected));

src/jrd/extds/ExtDS.h

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class CryptHash
7373

7474
void assign(Firebird::ICryptKeyCallback* callback);
7575

76-
bool isValid() const
76+
bool isValid() const noexcept
7777
{
7878
return m_valid;
7979
}
@@ -85,7 +85,7 @@ class CryptHash
8585
return m_value.begin();
8686
}
8787

88-
int getLength() const
88+
int getLength() const noexcept
8989
{
9090
return isValid() ? m_value.getCount() : -1;
9191
}
@@ -108,7 +108,7 @@ class CryptCallbackRedirector :
108108
void resetRedirect(Firebird::ICryptKeyCallback* newCallback);
109109
bool operator==(const CryptHash& h) const;
110110

111-
bool isValid() const
111+
bool isValid() const noexcept
112112
{
113113
return m_hash.isValid();
114114
}
@@ -203,17 +203,17 @@ class Provider : public Firebird::GlobalStorage
203203
// cancel execution of every connection
204204
void cancelConnections();
205205

206-
const Firebird::string& getName() const { return m_name; }
206+
const Firebird::string& getName() const noexcept { return m_name; }
207207

208208
virtual void initialize() = 0;
209209

210210
// Provider properties
211-
int getFlags() const { return m_flags; }
211+
int getFlags() const noexcept { return m_flags; }
212212

213213
// Interprete status and put error description into passed string
214214
virtual void getRemoteError(const Jrd::FbStatusVector* status, Firebird::string& err) const = 0;
215215

216-
static const Firebird::string* generate(const Provider* item)
216+
static const Firebird::string* generate(const Provider* item) noexcept
217217
{
218218
return &item->m_name;
219219
}
@@ -228,34 +228,34 @@ class Provider : public Firebird::GlobalStorage
228228
const Firebird::string& role) const;
229229

230230
// Protection against simultaneous attach database calls. Not sure we still
231-
// need it, but i believe it will not harm
232-
Firebird::Mutex m_mutex;
231+
// need it, but I believe it will not harm
232+
mutable Firebird::Mutex m_mutex;
233233

234234
Firebird::string m_name;
235-
Provider* m_next;
235+
Provider* m_next = nullptr;
236236

237237
class AttToConn
238238
{
239239
public:
240240
Jrd::Attachment* m_att;
241241
Connection* m_conn;
242242

243-
AttToConn()
243+
AttToConn() noexcept
244244
: m_att(NULL),
245245
m_conn(NULL)
246246
{}
247247

248-
AttToConn(Jrd::Attachment* att, Connection* conn)
248+
AttToConn(Jrd::Attachment* att, Connection* conn) noexcept
249249
: m_att(att),
250250
m_conn(conn)
251251
{}
252252

253-
static const AttToConn& generate(const void*, const AttToConn& item)
253+
static const AttToConn& generate(const void*, const AttToConn& item) noexcept
254254
{
255255
return item;
256256
}
257257

258-
static bool greaterThan(const AttToConn& i1, const AttToConn& i2)
258+
static bool greaterThan(const AttToConn& i1, const AttToConn& i2) noexcept
259259
{
260260
return (i1.m_att > i2.m_att) ||
261261
(i1.m_att == i2.m_att && i1.m_conn > i2.m_conn);
@@ -266,7 +266,7 @@ class Provider : public Firebird::GlobalStorage
266266
AttToConnMap;
267267

268268
AttToConnMap m_connections;
269-
int m_flags;
269+
int m_flags = 0;
270270
};
271271

272272
// Provider flags
@@ -292,13 +292,13 @@ class ConnectionsPool
292292
// clear connection relation with pool
293293
void delConnection(Jrd::thread_db* tdbb, Connection* conn, bool destroy);
294294

295-
ULONG getIdleCount() const { return m_idleArray.getCount(); }
296-
ULONG getAllCount() const { return m_allCount; } ;
295+
ULONG getIdleCount() const noexcept { return m_idleArray.getCount(); }
296+
ULONG getAllCount() const noexcept { return m_allCount; }
297297

298-
ULONG getMaxCount() const { return m_maxCount; }
298+
ULONG getMaxCount() const noexcept { return m_maxCount; }
299299
void setMaxCount(ULONG val);
300300

301-
ULONG getLifeTime() const { return m_lifeTime; }
301+
ULONG getLifeTime() const noexcept { return m_lifeTime; }
302302
void setLifeTime(ULONG val);
303303

304304
// delete idle connections: all or older than lifetime
@@ -319,20 +319,23 @@ class ConnectionsPool
319319
{
320320
public:
321321
// constructor for embedded into Connection instance
322-
explicit Data(Connection* conn)
322+
explicit Data(Connection* conn) noexcept
323323
{
324324
clear();
325325
m_conn = conn;
326326
}
327327

328-
ConnectionsPool* getConnPool() const { return m_connPool; }
328+
Data(const Data&) = delete;
329+
Data& operator=(const Data&) = delete;
330+
331+
ConnectionsPool* getConnPool() const noexcept { return m_connPool; }
329332

330-
static const Data& generate(const Data* item)
333+
static const Data& generate(const Data* item) noexcept
331334
{
332335
return *item;
333336
}
334337

335-
static bool greaterThan(const Data& i1, const Data& i2)
338+
static bool greaterThan(const Data& i1, const Data& i2) noexcept
336339
{
337340
if (i1.m_hash == i2.m_hash)
338341
{
@@ -357,19 +360,16 @@ class ConnectionsPool
357360
Data* m_next;
358361
Data* m_prev;
359362

360-
Data(const Data&);
361-
Data& operator=(const Data&);
362-
363363
// create instance used to search for recently used connection by hash
364-
explicit Data(ULONG hash)
364+
explicit Data(ULONG hash) noexcept
365365
{
366366
clear();
367367
m_conn = NULL;
368368
m_hash = hash;
369369
m_lastUsed = MAX_SINT64;
370370
}
371371

372-
void clear()
372+
void clear() noexcept
373373
{
374374
m_connPool = NULL;
375375
// m_conn = NULL;
@@ -497,15 +497,15 @@ class Connection : public Firebird::PermanentStorage
497497
m_cryptCallbackRedir.setRedirect(attCallback);
498498
}
499499

500-
void setBoundAtt(Jrd::Attachment* att) { m_boundAtt = att; }
500+
void setBoundAtt(Jrd::Attachment* att) noexcept { m_boundAtt = att; }
501501

502502
public:
503-
Provider* getProvider() { return &m_provider; }
503+
Provider* getProvider() noexcept { return &m_provider; }
504504

505-
Jrd::Attachment* getBoundAtt() const { return m_boundAtt; }
505+
Jrd::Attachment* getBoundAtt() const noexcept { return m_boundAtt; }
506506

507-
ConnectionsPool* getConnPool() { return m_poolData.getConnPool(); }
508-
ConnectionsPool::Data* getPoolData() { return &m_poolData; }
507+
ConnectionsPool* getConnPool() noexcept { return m_poolData.getConnPool(); }
508+
ConnectionsPool::Data* getPoolData() noexcept { return &m_poolData; }
509509

510510
virtual void attach(Jrd::thread_db* tdbb) = 0;
511511
virtual void detach(Jrd::thread_db* tdbb);
@@ -515,7 +515,7 @@ class Connection : public Firebird::PermanentStorage
515515
// Try to reset connection, return true if it can be pooled
516516
virtual bool resetSession(Jrd::thread_db* tdbb) = 0;
517517

518-
int getSqlDialect() const { return m_sqlDialect; }
518+
int getSqlDialect() const noexcept { return m_sqlDialect; }
519519

520520
// Is this connections can be used by current needs ? Not every DBMS
521521
// allows to use same connection in more than one transaction and\or
@@ -532,7 +532,7 @@ class Connection : public Firebird::PermanentStorage
532532
// only Internal provider is able to create "current" connections
533533
virtual bool isCurrent() const { return false; }
534534

535-
bool isBroken() const
535+
bool isBroken() const noexcept
536536
{
537537
return m_broken;
538538
}
@@ -550,8 +550,8 @@ class Connection : public Firebird::PermanentStorage
550550
void raise(const Jrd::FbStatusVector* status, Jrd::thread_db* tdbb, const char* sWhere);
551551

552552
// will we wrap external errors into our ones (isc_eds_xxx) or pass them as is
553-
bool getWrapErrors(const ISC_STATUS* status);
554-
void setWrapErrors(bool val) { m_wrapErrors = val; }
553+
bool getWrapErrors(const ISC_STATUS* status) noexcept;
554+
void setWrapErrors(bool val) noexcept { m_wrapErrors = val; }
555555

556556
// Transactions management within connection scope : put newly created
557557
// transaction into m_transactions array and delete not needed transaction
@@ -569,18 +569,18 @@ class Connection : public Firebird::PermanentStorage
569569
virtual Blob* createBlob() = 0;
570570

571571
// Test specified feature flag
572-
bool testFeature(info_features value) const { return m_features[value]; }
572+
bool testFeature(info_features value) const noexcept { return m_features[value]; }
573573
// Set specified flag
574-
void setFeature(info_features value) { m_features[value] = true; }
574+
void setFeature(info_features value) noexcept { m_features[value] = true; }
575575
// Clear specified flag
576-
void clearFeature(info_features value) { m_features[value] = false; }
576+
void clearFeature(info_features value) noexcept { m_features[value] = false; }
577577

578578
void resetRedirect(Firebird::ICryptKeyCallback* originalCallback)
579579
{
580580
m_cryptCallbackRedir.resetRedirect(originalCallback);
581581
}
582582

583-
bool hasValidCryptCallback() const
583+
bool hasValidCryptCallback() const noexcept
584584
{
585585
return m_cryptCallbackRedir.isValid();
586586
}
@@ -631,11 +631,11 @@ class Transaction : public Firebird::PermanentStorage
631631

632632
public:
633633

634-
Provider* getProvider() { return &m_provider; }
634+
Provider* getProvider() noexcept { return &m_provider; }
635635

636-
Connection* getConnection() { return &m_connection; }
636+
Connection* getConnection() noexcept { return &m_connection; }
637637

638-
TraScope getScope() const { return m_scope; }
638+
TraScope getScope() const noexcept { return m_scope; }
639639

640640
virtual void start(Jrd::thread_db* tdbb, TraScope traScope, TraModes traMode,
641641
bool readOnly, bool wait, int lockTimeout);
@@ -684,11 +684,11 @@ class Statement : public Firebird::PermanentStorage
684684
public:
685685
static void deleteStatement(Jrd::thread_db* tdbb, Statement* stmt);
686686

687-
Provider* getProvider() { return &m_provider; }
687+
Provider* getProvider() noexcept { return &m_provider; }
688688

689-
Connection* getConnection() { return &m_connection; }
689+
Connection* getConnection() noexcept { return &m_connection; }
690690

691-
Transaction* getTransaction() { return m_transaction; }
691+
Transaction* getTransaction() noexcept { return m_transaction; }
692692

693693
void prepare(Jrd::thread_db* tdbb, Transaction* tran, const Firebird::string& sql, bool named);
694694
void setTimeout(Jrd::thread_db* tdbb, unsigned int timeout);
@@ -702,19 +702,19 @@ class Statement : public Firebird::PermanentStorage
702702
void close(Jrd::thread_db* tdbb, bool invalidTran = false);
703703
void deallocate(Jrd::thread_db* tdbb);
704704

705-
const Firebird::string& getSql() const { return m_sql; }
705+
const Firebird::string& getSql() const noexcept { return m_sql; }
706706

707-
void setCallerPrivileges(bool use) { m_callerPrivileges = use; }
707+
void setCallerPrivileges(bool use) noexcept { m_callerPrivileges = use; }
708708

709-
bool isActive() const { return m_active; }
709+
bool isActive() const noexcept { return m_active; }
710710

711-
bool isAllocated() const { return m_allocated; }
711+
bool isAllocated() const noexcept { return m_allocated; }
712712

713-
bool isSelectable() const { return m_stmt_selectable; }
713+
bool isSelectable() const noexcept { return m_stmt_selectable; }
714714

715-
unsigned int getInputs() const { return m_inputs; }
715+
unsigned int getInputs() const noexcept { return m_inputs; }
716716

717-
unsigned int getOutputs() const { return m_outputs; }
717+
unsigned int getOutputs() const noexcept { return m_outputs; }
718718

719719
// Get error description from provider and put it with additional contex
720720
// info into locally raised exception

0 commit comments

Comments
 (0)