5454#define getpid _getpid
5555#endif
5656
57- const char * const SCRATCH = " fb_monitor_" ;
57+ constexpr const char * SCRATCH = " fb_monitor_" ;
5858
5959using namespace Firebird ;
6060using namespace Jrd ;
6161
6262
6363namespace
6464{
65- class DumpWriter : public SnapshotData ::DumpRecord::Writer
65+ class DumpWriter final : public SnapshotData::DumpRecord::Writer
6666 {
6767 public:
6868 DumpWriter (MonitoringData* data, AttNumber att_id, const char * user_name, ULONG generation)
@@ -71,7 +71,7 @@ namespace
7171 fb_assert (offset);
7272 }
7373
74- void write (const SnapshotData::DumpRecord& record)
74+ void write (const SnapshotData::DumpRecord& record) override
7575 {
7676 const ULONG length = record.getLength ();
7777 dump->write (offset, sizeof (ULONG), &length);
@@ -83,14 +83,14 @@ namespace
8383 const ULONG offset;
8484 };
8585
86- class TempWriter : public SnapshotData ::DumpRecord::Writer
86+ class TempWriter final : public SnapshotData::DumpRecord::Writer
8787 {
8888 public:
89- TempWriter (TempSpace& temp)
89+ TempWriter (TempSpace& temp) noexcept
9090 : tempSpace(temp)
9191 {}
9292
93- void write (const SnapshotData::DumpRecord& record)
93+ void write (const SnapshotData::DumpRecord& record) override
9494 {
9595 const offset_t offset = tempSpace.getSize ();
9696 const ULONG length = record.getLength ();
@@ -102,22 +102,22 @@ namespace
102102 TempSpace& tempSpace;
103103 };
104104
105- const ULONG HEADER_SIZE = (ULONG) FB_ALIGN(sizeof (MonitoringHeader), FB_ALIGNMENT);
105+ constexpr ULONG HEADER_SIZE = (ULONG) FB_ALIGN(sizeof (MonitoringHeader), FB_ALIGNMENT);
106106
107107} // namespace
108108
109109
110110const Format* MonitoringTableScan::getFormat (thread_db* tdbb, jrd_rel* relation) const
111111{
112- MonitoringSnapshot * const snapshot = MonitoringSnapshot::create (tdbb);
112+ const auto * const snapshot = MonitoringSnapshot::create (tdbb);
113113 return snapshot->getData (relation)->getFormat ();
114114}
115115
116116
117117bool MonitoringTableScan::retrieveRecord (thread_db* tdbb, jrd_rel* relation,
118118 FB_UINT64 position, Record* record) const
119119{
120- MonitoringSnapshot * const snapshot = MonitoringSnapshot::create (tdbb);
120+ const auto * const snapshot = MonitoringSnapshot::create (tdbb);
121121 if (!snapshot->getData (relation)->fetch (position, record))
122122 return false ;
123123
@@ -149,7 +149,7 @@ bool MonitoringTableScan::retrieveRecord(thread_db* tdbb, jrd_rel* relation,
149149
150150 // hvlad: this will assign local system (server) time zone that was actual
151151 // when current attachment created.
152- Attachment* att = tdbb->getAttachment ();
152+ const Attachment* att = tdbb->getAttachment ();
153153 ts->time_zone = att->att_timestamp .time_zone ;
154154 }
155155 }
@@ -260,8 +260,8 @@ void MonitoringData::enumerate(const char* userName, ULONG generation, SessionLi
260260
261261 for (ULONG offset = HEADER_SIZE; offset < m_sharedMemory->getHeader ()->used ;)
262262 {
263- const auto ptr = (UCHAR*) m_sharedMemory->getHeader () + offset;
264- const auto element = (Element*) ptr;
263+ const auto * ptr = (UCHAR*) m_sharedMemory->getHeader () + offset;
264+ const auto * element = (Element*) ptr;
265265 const ULONG length = element->getBlockLength ();
266266
267267 if (!userName || !strcmp (element->userName , userName)) // permitted
@@ -288,8 +288,8 @@ void MonitoringData::read(const char* userName, TempSpace& temp)
288288
289289 for (ULONG offset = HEADER_SIZE; offset < m_sharedMemory->getHeader ()->used ;)
290290 {
291- const auto ptr = (UCHAR*) m_sharedMemory->getHeader () + offset;
292- const auto element = (Element*) ptr;
291+ const auto * ptr = (UCHAR*) m_sharedMemory->getHeader () + offset;
292+ const auto * element = (Element*) ptr;
293293 const ULONG length = element->getBlockLength ();
294294
295295 if (!userName || !strcmp (element->userName , userName)) // permitted
@@ -344,7 +344,7 @@ void MonitoringData::cleanup(AttNumber att_id)
344344 for (ULONG offset = HEADER_SIZE; offset < m_sharedMemory->getHeader ()->used ;)
345345 {
346346 const auto ptr = (UCHAR*) m_sharedMemory->getHeader () + offset;
347- const auto element = (Element*) ptr;
347+ const auto * element = (Element*) ptr;
348348 const ULONG length = element->getBlockLength ();
349349
350350 if (element->attId == att_id)
@@ -369,7 +369,7 @@ void MonitoringData::cleanup(AttNumber att_id)
369369
370370void MonitoringData::ensureSpace (ULONG length)
371371{
372- FB_UINT64 newSize = m_sharedMemory->getHeader ()->used + length;
372+ const FB_UINT64 newSize = m_sharedMemory->getHeader ()->used + length;
373373
374374 if (newSize > m_sharedMemory->getHeader ()->allocated )
375375 {
@@ -693,7 +693,7 @@ MonitoringSnapshot::MonitoringSnapshot(thread_db* tdbb, MemoryPool& pool)
693693}
694694
695695
696- void SnapshotData::clearSnapshot ()
696+ void SnapshotData::clearSnapshot () noexcept
697697{
698698 for (FB_SIZE_T i = 0 ; i < m_snapshot.getCount (); i++)
699699 delete m_snapshot[i].data ;
@@ -702,15 +702,15 @@ void SnapshotData::clearSnapshot()
702702}
703703
704704
705- RecordBuffer* SnapshotData::getData (const jrd_rel* relation) const
705+ RecordBuffer* SnapshotData::getData (const jrd_rel* relation) const noexcept
706706{
707707 fb_assert (relation);
708708
709709 return getData (relation->rel_id );
710710}
711711
712712
713- RecordBuffer* SnapshotData::getData (int id) const
713+ RecordBuffer* SnapshotData::getData (int id) const noexcept
714714{
715715 for (FB_SIZE_T i = 0 ; i < m_snapshot.getCount (); i++)
716716 {
@@ -897,7 +897,7 @@ void SnapshotData::putField(thread_db* tdbb, Record* record, const DumpField& fi
897897// Monitoring class
898898
899899
900- SINT64 Monitoring::getGlobalId (int value)
900+ SINT64 Monitoring::getGlobalId (int value) noexcept
901901{
902902 return ((SINT64) getpid () << BITS_PER_LONG) + value;
903903}
@@ -912,7 +912,7 @@ void Monitoring::putDatabase(thread_db* tdbb, SnapshotData::DumpRecord& record)
912912 // Determine the backup state
913913 int backupState = backup_state_unknown;
914914
915- const auto bm = dbb->dbb_backup_manager ;
915+ const auto * bm = dbb->dbb_backup_manager ;
916916
917917 if (bm && !bm->isShutDown ())
918918 {
@@ -1042,7 +1042,7 @@ void Monitoring::putAttachment(SnapshotData::DumpRecord& record, const Jrd::Atta
10421042 if (!attachment->att_user )
10431043 return ;
10441044
1045- const auto dbb = attachment->att_database ;
1045+ const auto * dbb = attachment->att_database ;
10461046
10471047 record.reset (rel_mon_attachments);
10481048
@@ -1281,7 +1281,7 @@ void Monitoring::putRequest(SnapshotData::DumpRecord& record, const Request* req
12811281{
12821282 fb_assert (request);
12831283
1284- const auto dbb = request->req_attachment ->att_database ;
1284+ const auto * dbb = request->req_attachment ->att_database ;
12851285
12861286 record.reset (rel_mon_statements);
12871287
@@ -1344,7 +1344,7 @@ void Monitoring::putCall(SnapshotData::DumpRecord& record, const Request* reques
13441344{
13451345 fb_assert (request);
13461346
1347- const auto dbb = request->req_attachment ->att_database ;
1347+ const auto * dbb = request->req_attachment ->att_database ;
13481348 auto initialRequest = request->req_caller ;
13491349
13501350 while (initialRequest->req_caller )
@@ -1527,7 +1527,7 @@ void Monitoring::putMemoryUsage(SnapshotData::DumpRecord& record, const MemorySt
15271527
15281528void Monitoring::checkState (thread_db* tdbb)
15291529{
1530- const auto dbb = tdbb->getDatabase ();
1530+ const auto * dbb = tdbb->getDatabase ();
15311531 const auto attachment = tdbb->getAttachment ();
15321532
15331533 if (!(attachment && (attachment->att_flags & ATT_monitor_init)))
@@ -1621,7 +1621,7 @@ void Monitoring::dumpAttachment(thread_db* tdbb, Attachment* attachment, ULONG g
16211621
16221622 for (const auto request : attachment->att_requests )
16231623 {
1624- const auto statement = request->getStatement ();
1624+ const auto * statement = request->getStatement ();
16251625
16261626 if (!(statement->flags & (Statement::FLAG_INTERNAL | Statement::FLAG_SYS_TRIGGER)))
16271627 {
0 commit comments