Skip to content

Commit 558c8a5

Browse files
committed
misc constexpr/noexcept changes
1 parent b0b753b commit 558c8a5

File tree

12 files changed

+106
-119
lines changed

12 files changed

+106
-119
lines changed

src/auth/SecureRemotePassword/client/SrpClient.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ int SrpClient::authenticate(CheckStatusWrapper* status, IClientBlock* cb)
110110
{
111111
Arg::Gds(isc_auth_data).raise();
112112
}
113-
const unsigned expectedLength =
113+
constexpr unsigned expectedLength =
114114
(RemotePassword::SRP_SALT_SIZE + RemotePassword::SRP_KEY_SIZE + 2) * 2;
115115
if (length > expectedLength)
116116
{

src/common/os/win32/isc_ipc.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,14 @@
6767

6868
namespace {
6969

70-
static int process_id = 0;
71-
const int MAX_OPN_EVENTS = 40;
70+
static int process_id = 0;
71+
constexpr int MAX_OPN_EVENTS = 40;
7272

7373
class OpenEvents
7474
{
7575
public:
76-
explicit OpenEvents(Firebird::MemoryPool&)
76+
explicit OpenEvents(Firebird::MemoryPool&) noexcept
7777
{
78-
memset(&m_events, 0, sizeof(m_events));
7978
m_count = 0;
8079
m_clock = 0;
8180
}
@@ -143,7 +142,7 @@ class OpenEvents
143142
FB_UINT64 age;
144143
};
145144

146-
Item m_events[MAX_OPN_EVENTS];
145+
Item m_events[MAX_OPN_EVENTS]{};
147146
int m_count;
148147
FB_UINT64 m_clock;
149148
Firebird::Mutex m_mutex;

src/isql/isql.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ static inline constexpr sqltypes Column_types[] = {
158158

159159
// Integral subtypes
160160

161-
const int MAX_INTSUBTYPES = 2;
161+
inline constexpr int MAX_INTSUBTYPES = 2;
162162

163163
static inline constexpr const SCHAR* Integral_subtypes[] = {
164164
"UNKNOWN", // Defined type, keyword
@@ -315,7 +315,7 @@ struct IsqlVar
315315
class IsqlWireStats
316316
{
317317
public:
318-
explicit IsqlWireStats(Firebird::IAttachment* att) :
318+
explicit IsqlWireStats(Firebird::IAttachment* att) noexcept :
319319
m_att(att)
320320
{}
321321

src/jrd/os/win32/winnt.cpp

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,11 @@ class FileExtendLockGuard
8585
}
8686
}
8787

88-
private:
8988
// copying is prohibited
90-
FileExtendLockGuard(const FileExtendLockGuard&);
91-
FileExtendLockGuard& operator=(const FileExtendLockGuard&);
89+
FileExtendLockGuard(const FileExtendLockGuard&) = delete;
90+
FileExtendLockGuard& operator=(const FileExtendLockGuard&) = delete;
9291

92+
private:
9393
Firebird::RWLock* const m_lock;
9494
const bool m_exclusive;
9595
};
@@ -106,19 +106,18 @@ using namespace Firebird;
106106
#define TEXT SCHAR
107107

108108
static bool maybeCloseFile(HANDLE&);
109-
static bool seek_file(jrd_file*, BufferDesc*, OVERLAPPED*);
109+
static bool seek_file(jrd_file*, const BufferDesc*, OVERLAPPED*);
110110
static jrd_file* setup_file(Database*, const Firebird::PathName&, HANDLE, USHORT);
111111
static bool nt_error(const TEXT*, const jrd_file*, ISC_STATUS, FbStatusVector* const);
112112

113-
inline static DWORD getShareFlags(const bool shared_access, bool temporary = false)
113+
inline static DWORD getShareFlags(const bool shared_access, bool temporary = false) noexcept
114114
{
115115
return FILE_SHARE_READ | ((!temporary && shared_access) ? FILE_SHARE_WRITE : 0);
116116
}
117117

118-
static const DWORD g_dwExtraFlags = FILE_FLAG_OVERLAPPED;
118+
static constexpr DWORD g_dwExtraFlags = FILE_FLAG_OVERLAPPED;
119119

120-
static const DWORD g_dwExtraTempFlags = FILE_ATTRIBUTE_TEMPORARY |
121-
FILE_FLAG_DELETE_ON_CLOSE;
120+
static constexpr DWORD g_dwExtraTempFlags = FILE_ATTRIBUTE_TEMPORARY | FILE_FLAG_DELETE_ON_CLOSE;
122121

123122

124123
void PIO_close(jrd_file* file)
@@ -345,7 +344,7 @@ bool PIO_header(thread_db* tdbb, UCHAR* address, unsigned length)
345344
* callers should not rely on this behavior
346345
*
347346
**************************************/
348-
const auto dbb = tdbb->getDatabase();
347+
const auto* dbb = tdbb->getDatabase();
349348

350349
PageSpace* const pageSpace = dbb->dbb_page_manager.findPageSpace(DB_PAGE_SPACE);
351350
jrd_file* const file = pageSpace->file;
@@ -507,7 +506,7 @@ jrd_file* PIO_open(thread_db* tdbb,
507506
// being opened ReadOnly. This flag will be used later to compare with
508507
// the Header Page flag setting to make sure that the database is set ReadOnly.
509508
readOnly = true;
510-
PageSpace* pageSpace = dbb->dbb_page_manager.findPageSpace(DB_PAGE_SPACE);
509+
const PageSpace* pageSpace = dbb->dbb_page_manager.findPageSpace(DB_PAGE_SPACE);
511510
if (!pageSpace->file)
512511
dbb->dbb_flags |= DBB_being_opened_read_only;
513512
}
@@ -537,7 +536,7 @@ bool PIO_read(thread_db* tdbb, jrd_file* file, BufferDesc* bdb, Ods::pag* page,
537536
* Read a data page.
538537
*
539538
**************************************/
540-
Database* const dbb = tdbb->getDatabase();
539+
const Database* const dbb = tdbb->getDatabase();
541540

542541
const DWORD size = dbb->dbb_page_size;
543542

@@ -696,8 +695,7 @@ bool PIO_write(thread_db* tdbb, jrd_file* file, BufferDesc* bdb, Ods::pag* page,
696695
* Write a data page.
697696
*
698697
**************************************/
699-
700-
Database* const dbb = tdbb->getDatabase();
698+
const Database* const dbb = tdbb->getDatabase();
701699

702700
const DWORD size = dbb->dbb_page_size;
703701

@@ -750,7 +748,7 @@ ULONG PIO_get_number_of_pages(const jrd_file* file, const USHORT pagesize)
750748
}
751749

752750

753-
static bool seek_file(jrd_file* file, BufferDesc* bdb, OVERLAPPED* overlapped)
751+
static bool seek_file(jrd_file* file, const BufferDesc* bdb, OVERLAPPED* overlapped)
754752
{
755753
/**************************************
756754
*
@@ -762,7 +760,7 @@ static bool seek_file(jrd_file* file, BufferDesc* bdb, OVERLAPPED* overlapped)
762760
* Given a buffer descriptor block, seek to the proper page in that file.
763761
*
764762
**************************************/
765-
BufferControl* const bcb = bdb->bdb_bcb;
763+
const BufferControl* const bcb = bdb->bdb_bcb;
766764
const ULONG page = bdb->bdb_page.getPageNum();
767765

768766
LARGE_INTEGER liOffset;
@@ -773,7 +771,7 @@ static bool seek_file(jrd_file* file, BufferDesc* bdb, OVERLAPPED* overlapped)
773771
overlapped->Internal = 0;
774772
overlapped->InternalHigh = 0;
775773

776-
ThreadSync* thd = ThreadSync::getThread(FB_FUNCTION);
774+
const ThreadSync* thd = ThreadSync::getThread(FB_FUNCTION);
777775
overlapped->hEvent = thd->getIOEvent();
778776

779777
return true;
@@ -803,7 +801,7 @@ static jrd_file* setup_file(Database* dbb, const Firebird::PathName& file_name,
803801

804802
// If this isn't the primary file, we're done
805803

806-
const auto pageSpace = dbb->dbb_page_manager.findPageSpace(DB_PAGE_SPACE);
804+
const auto* pageSpace = dbb->dbb_page_manager.findPageSpace(DB_PAGE_SPACE);
807805
if (pageSpace && pageSpace->file)
808806
return file;
809807

src/plugins/profiler/Profiler.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@ SINT64 ticksToNanoseconds(FB_UINT64 ticks)
5858
return CInt128((SINT64) ticks).mul(ONE_SECOND_IN_NS).div(ticksFrequency, 0).toInt64(0);
5959
}
6060

61-
auto& defaultPool()
61+
auto& defaultPool() noexcept
6262
{
6363
return *getDefaultMemoryPool();
6464
}
6565

6666
void quote(string& name)
6767
{
68-
const char QUOTE = '"';
68+
constexpr char QUOTE = '"';
6969

7070
for (unsigned p = 0; p < name.length(); ++p)
7171
{
@@ -82,7 +82,7 @@ void quote(string& name)
8282

8383
struct Stats
8484
{
85-
void hit(FB_UINT64 elapsedTicks)
85+
void hit(FB_UINT64 elapsedTicks) noexcept
8686
{
8787
if (counter == 0 || elapsedTicks < minElapsedTicks)
8888
minElapsedTicks = elapsedTicks;
@@ -103,14 +103,14 @@ struct Stats
103103
struct Cursor
104104
{
105105
MetaString name{defaultPool()};
106-
unsigned line;
107-
unsigned column;
106+
unsigned line = 0;
107+
unsigned column = 0;
108108
};
109109

110110
struct RecordSource
111111
{
112112
std::optional<ULONG> parentId;
113-
unsigned level;
113+
unsigned level = 0;
114114
string accessPath{defaultPool()};
115115
};
116116

@@ -127,7 +127,7 @@ struct Statement
127127
MetaString schemaName{defaultPool()};
128128
MetaString packageName{defaultPool()};
129129
MetaString routineName{defaultPool()};
130-
SINT64 parentStatementId;
130+
SINT64 parentStatementId = 0;
131131
string sqlText{defaultPool()};
132132
};
133133

@@ -138,10 +138,10 @@ struct Request
138138
{
139139
bool dirty = true;
140140
unsigned level = 0;
141-
SINT64 statementId;
141+
SINT64 statementId = 0;
142142
SINT64 callerStatementId = 0;
143143
SINT64 callerRequestId = 0;
144-
ISC_TIMESTAMP_TZ startTimestamp;
144+
ISC_TIMESTAMP_TZ startTimestamp{};
145145
std::optional<ISC_TIMESTAMP_TZ> finishTimestamp;
146146
std::optional<FB_UINT64> totalElapsedTicks;
147147
NonPooledMap<CursorRecSourceKey, RecordSourceStats> recordSourcesStats{defaultPool()};

src/remote/server/os/win32/window.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ static HWND hPSDlg = NULL;
5050
static HINSTANCE hInstance = NULL;
5151
static USHORT usServerFlags;
5252
static HWND hMainWnd = NULL;
53-
const int SHUTDOWN_TIMEOUT = 5000; // 5 sec
53+
constexpr int SHUTDOWN_TIMEOUT = 5000; // 5 sec
5454

5555
// Static functions to be called from this file only.
5656
static BOOL CanEndServer(HWND);

0 commit comments

Comments
 (0)