@@ -28,18 +28,18 @@ using namespace Firebird;
2828
2929namespace
3030{
31- const FB_SIZE_T NEXT_INDEX = 0 ;
32- const FB_SIZE_T OIT_INDEX = 1 ;
33- const FB_SIZE_T OAT_INDEX = 2 ;
34- const FB_SIZE_T OST_INDEX = 3 ;
31+ constexpr FB_SIZE_T NEXT_INDEX = 0 ;
32+ constexpr FB_SIZE_T OIT_INDEX = 1 ;
33+ constexpr FB_SIZE_T OAT_INDEX = 2 ;
34+ constexpr FB_SIZE_T OST_INDEX = 3 ;
3535}
3636
3737namespace Ods {
3838
39- bool isSupported (const header_page* hdr)
39+ bool isSupported (const header_page* hdr) noexcept
4040{
4141 USHORT majorVersion = hdr->hdr_ods_version ;
42- USHORT minorVersion = hdr->hdr_ods_minor ;
42+ const USHORT minorVersion = hdr->hdr_ods_minor ;
4343 const bool isFirebird = (majorVersion & ODS_FIREBIRD_FLAG);
4444 majorVersion &= ~ODS_FIREBIRD_FLAG;
4545
@@ -58,52 +58,52 @@ bool isSupported(const header_page* hdr)
5858 return false ;
5959}
6060
61- ULONG bytesBitPIP (ULONG page_size)
61+ ULONG bytesBitPIP (ULONG page_size) noexcept
6262{
6363 return static_cast <ULONG>(page_size - offsetof (page_inv_page, pip_bits[0 ]));
6464}
6565
66- ULONG pagesPerPIP (ULONG page_size)
66+ ULONG pagesPerPIP (ULONG page_size) noexcept
6767{
6868 return bytesBitPIP (page_size) * 8 ;
6969}
7070
71- ULONG pagesPerSCN (ULONG page_size)
71+ ULONG pagesPerSCN (ULONG page_size) noexcept
7272{
7373 return pagesPerPIP (page_size) / BITS_PER_LONG;
7474}
7575
7676// We must ensure that pagesPerSCN items can fit into scns_page::scn_pages array.
7777// We can't use fb_assert() here in ods.h so it is placed at pag.cpp
7878
79- ULONG maxPagesPerSCN (ULONG page_size)
79+ ULONG maxPagesPerSCN (ULONG page_size) noexcept
8080{
8181 return static_cast <ULONG>((page_size - offsetof (scns_page, scn_pages[0 ])) / sizeof (((scns_page*)NULL )->scn_pages ));
8282}
8383
84- ULONG transPerTIP (ULONG page_size)
84+ ULONG transPerTIP (ULONG page_size) noexcept
8585{
8686 return static_cast <ULONG>((page_size - offsetof (tx_inv_page, tip_transactions[0 ])) * 4 );
8787}
8888
89- ULONG gensPerPage (ULONG page_size)
89+ ULONG gensPerPage (ULONG page_size) noexcept
9090{
9191 return static_cast <ULONG>((page_size - offsetof (generator_page, gpg_values[0 ])) /
9292 sizeof (((generator_page*) NULL )->gpg_values ));
9393}
9494
95- ULONG dataPagesPerPP (ULONG page_size)
95+ ULONG dataPagesPerPP (ULONG page_size) noexcept
9696{
9797 // Compute the number of data pages per pointer page. Each data page requires
9898 // a 32 bit pointer (BITS_PER_LONG) and a 8 bit control field (PPG_DP_BITS_NUM).
9999 // Also, don't allow extent of data pages (8 pages) to cross PP boundary to
100100 // simplify code a bit.
101101
102- ULONG ret = static_cast <ULONG>((page_size - offsetof (pointer_page, ppg_page[0 ])) * 8 / (BITS_PER_LONG + PPG_DP_BITS_NUM));
102+ const ULONG ret = static_cast <ULONG>((page_size - offsetof (pointer_page, ppg_page[0 ])) * 8 / (BITS_PER_LONG + PPG_DP_BITS_NUM));
103103 return ret & (~7 );
104104}
105105
106- ULONG maxRecsPerDP (ULONG page_size)
106+ ULONG maxRecsPerDP (ULONG page_size) noexcept
107107{
108108 // Compute the number of records that can fit on a page using the
109109 // size of the record index (dpb_repeat) and a record header. This
@@ -126,7 +126,7 @@ ULONG maxRecsPerDP(ULONG page_size)
126126 return max_records;
127127}
128128
129- ULONG maxIndices (ULONG page_size)
129+ ULONG maxIndices (ULONG page_size) noexcept
130130{
131131 // Compute the number of index roots that will fit on an index root page,
132132 // assuming that each index has only one key
@@ -139,7 +139,7 @@ Firebird::string pagtype(UCHAR type)
139139{
140140 // Print pretty name for database page type
141141
142- const char * nameArray[pag_max + 1 ] = {
142+ static constexpr const char * nameArray[pag_max + 1 ] = {
143143 " purposely undefined" ,
144144 " database header" ,
145145 " page inventory" ,
@@ -162,9 +162,9 @@ Firebird::string pagtype(UCHAR type)
162162 return rc;
163163}
164164
165- TraNumber getTraNum (const void * ptr)
165+ TraNumber getTraNum (const void * ptr) noexcept
166166{
167- rhd* const record = (rhd*) ptr;
167+ const rhd* const record = (rhd*) ptr;
168168 USHORT high_word = 0 ;
169169
170170 if (record->rhd_flags & rhd_long_tranum)
@@ -176,7 +176,7 @@ TraNumber getTraNum(const void* ptr)
176176 return ((TraNumber) high_word << BITS_PER_LONG) | record->rhd_transaction ;
177177}
178178
179- void writeTraNum (void * ptr, TraNumber number, FB_SIZE_T header_size)
179+ void writeTraNum (void * ptr, TraNumber number, FB_SIZE_T header_size) noexcept
180180{
181181 rhd* const record = (rhd*) ptr;
182182
@@ -212,13 +212,13 @@ namespace
212212 class CheckODS
213213 {
214214 public:
215- CheckODS ()
215+ CheckODS () noexcept
216216 {
217217 for (ULONG page_size = MIN_PAGE_SIZE; page_size <= MAX_PAGE_SIZE; page_size *= 2 )
218218 {
219- ULONG pagesPerPIP = Ods::pagesPerPIP (page_size);
220- ULONG pagesPerSCN = Ods::pagesPerSCN (page_size);
221- ULONG maxPagesPerSCN = Ods::maxPagesPerSCN (page_size);
219+ const ULONG pagesPerPIP = Ods::pagesPerPIP (page_size);
220+ const ULONG pagesPerSCN = Ods::pagesPerSCN (page_size);
221+ const ULONG maxPagesPerSCN = Ods::maxPagesPerSCN (page_size);
222222
223223 fb_assert ((pagesPerPIP % pagesPerSCN) == 0 );
224224 fb_assert (pagesPerSCN <= maxPagesPerSCN);
0 commit comments