Skip to content

Commit e7764dc

Browse files
committed
Silence unused warning in ExtDS
+ constexpr + misc other changes
1 parent 2af5dca commit e7764dc

File tree

2 files changed

+21
-19
lines changed

2 files changed

+21
-19
lines changed

src/jrd/extds/ExtDS.cpp

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ Mutex Manager::m_mutex;
8383
Provider* Manager::m_providers = NULL;
8484
ConnectionsPool* Manager::m_connPool = NULL;
8585

86-
const ULONG MIN_CONNPOOL_SIZE = 0;
87-
const ULONG MAX_CONNPOOL_SIZE = 1000;
86+
inline constexpr ULONG MIN_CONNPOOL_SIZE = 0;
87+
inline constexpr ULONG MAX_CONNPOOL_SIZE = 1000;
8888

89-
const ULONG MIN_LIFE_TIME = 1;
90-
const ULONG MAX_LIFE_TIME = 60 * 60 * 24; // one day
89+
inline constexpr ULONG MIN_LIFE_TIME = 1;
90+
inline constexpr ULONG MAX_LIFE_TIME = 60 * 60 * 24; // one day
9191

9292
Manager::Manager(MemoryPool& pool) :
9393
PermanentStorage(pool)
@@ -387,7 +387,7 @@ void Provider::bindConnection(thread_db* tdbb, Connection* conn)
387387
m_connections.fastRemove();
388388

389389
conn->setBoundAtt(attachment);
390-
bool ret = m_connections.add(AttToConn(attachment, conn));
390+
const bool ret = m_connections.add(AttToConn(attachment, conn));
391391
fb_assert(ret);
392392
}
393393

@@ -851,16 +851,17 @@ bool Connection::getWrapErrors(const ISC_STATUS* status)
851851
case isc_net_read_err:
852852
case isc_net_write_err:
853853
m_broken = true;
854-
break;
854+
return m_wrapErrors;
855855

856856
// Always wrap shutdown errors, else user application will disconnect
857857
case isc_att_shutdown:
858858
case isc_shutdown:
859859
m_broken = true;
860860
return true;
861-
}
862861

863-
return m_wrapErrors;
862+
default:
863+
return m_wrapErrors;
864+
}
864865
}
865866

866867

@@ -933,7 +934,7 @@ Connection* ConnectionsPool::getConnection(thread_db* tdbb, Provider* prv, ULONG
933934
{
934935
MutexLockGuard guard(m_mutex, FB_FUNCTION);
935936

936-
Data data(hash);
937+
const Data data(hash);
937938

938939
FB_SIZE_T pos;
939940
m_idleArray.find(data, pos);
@@ -1010,6 +1011,7 @@ void ConnectionsPool::putConnection(thread_db* tdbb, Connection* conn)
10101011
{
10111012
FB_SIZE_T pos;
10121013
fb_assert(m_idleArray.find(*item, pos));
1014+
FB_UNUSED_VAR(pos); // Silence compiler warning
10131015

10141016
#ifdef EDS_DEBUG
10151017
const bool ok = verifyPool();
@@ -1176,7 +1178,7 @@ void ConnectionsPool::clearIdle(thread_db* tdbb, bool all)
11761178
{
11771179
while (!m_idleArray.isEmpty())
11781180
{
1179-
FB_SIZE_T pos = m_idleArray.getCount() - 1;
1181+
const FB_SIZE_T pos = m_idleArray.getCount() - 1;
11801182
Data* item = m_idleArray[pos];
11811183
removeFromPool(item, pos);
11821184

@@ -1243,7 +1245,7 @@ void ConnectionsPool::clear(thread_db* tdbb)
12431245

12441246
while (m_idleArray.getCount())
12451247
{
1246-
FB_SIZE_T i = m_idleArray.getCount() - 1;
1248+
const FB_SIZE_T i = m_idleArray.getCount() - 1;
12471249
Data* data = m_idleArray[i];
12481250
Connection* conn = data->m_conn;
12491251

@@ -1992,7 +1994,7 @@ static TokenType getToken(const char** begin, const char* end)
19921994
TokenType ret = ttNone;
19931995
const char* p = *begin;
19941996

1995-
char c = *p++;
1997+
const char c = *p++;
19961998
switch (c)
19971999
{
19982000
case ':':
@@ -2174,7 +2176,7 @@ void Statement::preprocess(const string& sql, string& ret)
21742176
}
21752177

21762178
FB_SIZE_T n = 0;
2177-
MetaString name(ident);
2179+
const MetaString name(ident);
21782180
if (!m_sqlParamNames.find(name, n))
21792181
n = m_sqlParamNames.add(name);
21802182

@@ -2201,7 +2203,7 @@ void Statement::preprocess(const string& sql, string& ret)
22012203
return;
22022204
}
22032205
}
2204-
// fall thru
2206+
[[fallthrough]];
22052207

22062208
case ttWhite:
22072209
case ttComment:
@@ -2436,7 +2438,7 @@ void Statement::getExtBlob(thread_db* tdbb, const dsc& src, dsc& dst)
24362438
destBlob->blb_charset = src.getCharSet();
24372439

24382440
Array<UCHAR> buffer;
2439-
const int bufSize = 32 * 1024 - 2/*input->getMaxSegment()*/;
2441+
constexpr int bufSize = 32 * 1024 - 2/*input->getMaxSegment()*/;
24402442
UCHAR* buff = buffer.getBuffer(bufSize);
24412443

24422444
while (true)
@@ -2483,7 +2485,7 @@ void Statement::putExtBlob(thread_db* tdbb, dsc& src, dsc& dst)
24832485

24842486
while (true)
24852487
{
2486-
USHORT length = srcBlob->BLB_get_segment(tdbb, buff, srcBlob->getMaxSegment());
2488+
const USHORT length = srcBlob->BLB_get_segment(tdbb, buff, srcBlob->getMaxSegment());
24872489
if (srcBlob->blb_flags & BLB_eof) {
24882490
break;
24892491
}
@@ -2663,7 +2665,7 @@ void CryptHash::assign(ICryptKeyCallback* callback)
26632665

26642666
FbLocalStatus status;
26652667

2666-
int len = callback->getHashLength(&status);
2668+
const int len = callback->getHashLength(&status);
26672669
if (len > 0 && status.isSuccess())
26682670
callback->getHashData(&status, m_value.getBuffer(len));
26692671

src/jrd/extds/ExtDS.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ class Provider : public Firebird::GlobalStorage
270270
};
271271

272272
// Provider flags
273-
const int prvTrustedAuth = 0x0001; // supports trusted authentication
273+
inline constexpr int prvTrustedAuth = 0x0001; // supports trusted authentication
274274

275275

276276
class ConnectionsPool
@@ -608,7 +608,7 @@ class Connection : public Firebird::PermanentStorage
608608

609609
ConnectionsPool::Data m_poolData;
610610

611-
static const int MAX_CACHED_STMTS = 16;
611+
static inline constexpr int MAX_CACHED_STMTS = 16;
612612
int m_used_stmts;
613613
int m_free_stmts;
614614
bool m_deleting;

0 commit comments

Comments
 (0)