5454
5555using namespace Firebird ;
5656
57- namespace {
57+ namespace
58+ {
5859 THREAD_ENTRY_DECLARE cryptThreadStatic (THREAD_ENTRY_PARAM p)
5960 {
60- Jrd::CryptoManager* cryptoManager = (Jrd::CryptoManager*) p;
61+ const auto cryptoManager = (Jrd::CryptoManager*) p;
6162 cryptoManager->cryptThread ();
6263
6364 return 0 ;
@@ -68,12 +69,12 @@ namespace {
6869 const UCHAR CRYPT_CHANGE = LCK_PW;
6970 const UCHAR CRYPT_INIT = LCK_EX;
7071
71- const int MAX_PLUGIN_NAME_LEN = 31 ;
72+ constexpr int MAX_PLUGIN_NAME_LEN = sizeof (Ods::header_page::hdr_crypt_plugin) - 1 ;
7273}
7374
7475
75- namespace Jrd {
76-
76+ namespace Jrd
77+ {
7778 class Header
7879 {
7980 protected:
@@ -625,9 +626,9 @@ namespace Jrd {
625626
626627 void CryptoManager::changeCryptState (thread_db* tdbb, const string& plugName)
627628 {
628- if (plugName.length () > 31 )
629+ if (plugName.length () > MAX_PLUGIN_NAME_LEN )
629630 {
630- (Arg::Gds (isc_cp_name_too_long) << Arg::Num (31 )).raise ();
631+ (Arg::Gds (isc_cp_name_too_long) << Arg::Num (MAX_PLUGIN_NAME_LEN )).raise ();
631632 }
632633
633634 const bool newCryptState = plugName.hasData ();
@@ -656,8 +657,8 @@ namespace Jrd {
656657
657658 // Nbak's lock was taken in prepareChangeCryptState()
658659 // If it was invalidated it's enough reason not to continue now
659- int bak_state = dbb.dbb_backup_manager ->getState ();
660- if (bak_state != Ods::hdr_nbak_normal)
660+ auto backupState = dbb.dbb_backup_manager ->getState ();
661+ if (backupState != Ods::hdr_nbak_normal)
661662 {
662663 (Arg::Gds (isc_wish_list) << Arg::Gds (isc_random) <<
663664 " Cannot crypt: please wait for nbackup completion" ).raise ();
@@ -669,7 +670,7 @@ namespace Jrd {
669670 (Arg::Gds (isc_cp_process_active)).raise ();
670671 }
671672
672- bool headerCryptState = hdr->hdr_flags & Ods::hdr_encrypted;
673+ const bool headerCryptState = hdr->hdr_flags & Ods::hdr_encrypted;
673674 if (headerCryptState == newCryptState)
674675 {
675676 (Arg::Gds (isc_cp_already_crypted)).raise ();
0 commit comments