@@ -97,32 +97,32 @@ ITransaction* handleToITransaction(CheckStatusWrapper*, FB_API_HANDLE*);
9797// Bug 7119 - BLOB_load will open external file for read in BINARY mode.
9898
9999#ifdef WIN_NT
100- static const char * const FOPEN_READ_TYPE = " rb" ;
101- static const char * const FOPEN_WRITE_TYPE = " wb" ;
102- static const char * const FOPEN_READ_TYPE_TEXT = " rt" ;
103- static const char * const FOPEN_WRITE_TYPE_TEXT = " wt" ;
100+ static inline constexpr const char * FOPEN_READ_TYPE = " rb" ;
101+ static inline constexpr const char * FOPEN_WRITE_TYPE = " wb" ;
102+ static inline constexpr const char * FOPEN_READ_TYPE_TEXT = " rt" ;
103+ static inline constexpr const char * FOPEN_WRITE_TYPE_TEXT = " wt" ;
104104#else
105- static const char * const FOPEN_READ_TYPE = " r" ;
106- static const char * const FOPEN_WRITE_TYPE = " w" ;
107- static const char * const FOPEN_READ_TYPE_TEXT = FOPEN_READ_TYPE;
108- static const char * const FOPEN_WRITE_TYPE_TEXT = FOPEN_WRITE_TYPE;
105+ static inline constexpr const char * FOPEN_READ_TYPE = " r" ;
106+ static inline constexpr const char * FOPEN_WRITE_TYPE = " w" ;
107+ static inline constexpr const char * FOPEN_READ_TYPE_TEXT = FOPEN_READ_TYPE;
108+ static inline constexpr const char * FOPEN_WRITE_TYPE_TEXT = FOPEN_WRITE_TYPE;
109109#endif
110110
111111#define LOWER7 (c ) ( (c >= ' A' && c<= ' Z' ) ? c + ' a' - ' A' : c )
112112
113113
114114// Blob stream stuff
115115
116- const int BSTR_input = 0 ;
117- const int BSTR_output = 1 ;
118- const int BSTR_alloc = 2 ;
116+ inline constexpr int BSTR_input = 0 ;
117+ inline constexpr int BSTR_output = 1 ;
118+ inline constexpr int BSTR_alloc = 2 ;
119119
120120static void isc_expand_dpb_internal (const UCHAR** dpb, SSHORT* dpb_size, ...);
121121
122122
123123// Blob info stuff
124124
125- static const char blob_items[] =
125+ static inline constexpr char blob_items[] =
126126{
127127 isc_info_blob_max_segment, isc_info_blob_num_segments,
128128 isc_info_blob_total_length
@@ -131,13 +131,13 @@ static const char blob_items[] =
131131
132132// gds__version stuff
133133
134- static const unsigned char info[] =
134+ static inline constexpr unsigned char info[] =
135135 { isc_info_firebird_version, isc_info_implementation, fb_info_implementation, isc_info_end };
136136
137- static const unsigned char ods_info[] =
137+ static inline constexpr unsigned char ods_info[] =
138138 { isc_info_ods_version, isc_info_ods_minor_version, isc_info_end };
139139
140- static const TEXT* const impl_class[] =
140+ static inline constexpr const TEXT* impl_class[] =
141141{
142142 NULL , // 0
143143 " access method" , // 1
@@ -252,13 +252,12 @@ void dump(CheckStatusWrapper* status, ISC_QUAD* blobId, IAttachment* att, ITrans
252252
253253 // Copy data from blob to scratch file
254254
255- SCHAR buffer[256 ];
256- const SSHORT short_length = sizeof (buffer);
255+ SCHAR buffer[8192 ];
257256
258257 for (bool cond = true ; cond; )
259258 {
260259 unsigned l = 0 ;
261- switch (blob->getSegment (status, short_length , buffer, &l))
260+ switch (blob->getSegment (status, sizeof (buffer) , buffer, &l))
262261 {
263262 case Firebird::IStatus::RESULT_ERROR:
264263 case Firebird::IStatus::RESULT_NO_DATA:
@@ -486,7 +485,7 @@ void UtilInterface::getFbVersion(CheckStatusWrapper* status, IAttachment* att,
486485
487486 case isc_info_truncated:
488487 redo = true ;
489- // fall down...
488+ [[fallthrough]];
490489 case isc_info_end:
491490 break ;
492491
@@ -581,7 +580,7 @@ YAttachment* UtilInterface::executeCreateDatabase2(
581580 *stmtIsCreateDb = FB_FALSE;
582581
583582 string statement (creatDBstatement,
584- (stmtLength == 0 && creatDBstatement ? strlen (creatDBstatement) : stmtLength));
583+ (stmtLength == 0 && creatDBstatement ? fb_strlen (creatDBstatement) : stmtLength));
585584
586585 if (!PREPARSE_execute (status, &att, statement, &stmtEaten, dialect, dpbLength, dpb))
587586 return NULL ;
@@ -716,7 +715,7 @@ void UtilInterface::encodeTimeTz(CheckStatusWrapper* status, ISC_TIME_TZ* timeTz
716715 try
717716 {
718717 timeTz->utc_time = encodeTime (hours, minutes, seconds, fractions);
719- timeTz->time_zone = TimeZoneUtil::parse (timeZone, strlen (timeZone));
718+ timeTz->time_zone = TimeZoneUtil::parse (timeZone, fb_strlen (timeZone));
720719 TimeZoneUtil::localTimeToUtc (*timeTz);
721720 }
722721 catch (const Exception& ex)
@@ -790,7 +789,7 @@ void UtilInterface::encodeTimeStampTz(CheckStatusWrapper* status, ISC_TIMESTAMP_
790789 {
791790 timeStampTz->utc_timestamp .timestamp_date = encodeDate (year, month, day);
792791 timeStampTz->utc_timestamp .timestamp_time = encodeTime (hours, minutes, seconds, fractions);
793- timeStampTz->time_zone = TimeZoneUtil::parse (timeZone, strlen (timeZone));
792+ timeStampTz->time_zone = TimeZoneUtil::parse (timeZone, fb_strlen (timeZone));
794793 TimeZoneUtil::localTimeStampToUtc (*timeStampTz);
795794 }
796795 catch (const Exception& ex)
@@ -1001,7 +1000,7 @@ class XpbBuilder final : public DisposeIface<IXpbBuilderImpl<XpbBuilder, CheckSt
10011000 {
10021001 try
10031002 {
1004- pb->insertString (tag, str, strlen (str));
1003+ pb->insertString (tag, str, fb_strlen (str));
10051004 }
10061005 catch (const Exception& ex)
10071006 {
@@ -1192,7 +1191,7 @@ class XpbBuilder final : public DisposeIface<IXpbBuilderImpl<XpbBuilder, CheckSt
11921191
11931192private:
11941193 AutoPtr<ClumpletWriter> pb;
1195- unsigned char nextTag;
1194+ unsigned char nextTag = 0 ;
11961195 string strVal;
11971196};
11981197
@@ -1229,7 +1228,7 @@ class DecFloat16 final : public AutoIface<IDecFloat16Impl<DecFloat16, CheckStatu
12291228 {
12301229 char temp[STRING_SIZE];
12311230 decDoubleToString (reinterpret_cast <const decDouble*>(from), temp);
1232- unsigned int len = strlen (temp);
1231+ unsigned int len = fb_strlen (temp);
12331232 if (len < bufSize)
12341233 strncpy (buffer, temp, bufSize);
12351234 else
@@ -1290,7 +1289,7 @@ class DecFloat34 final : public AutoIface<IDecFloat34Impl<DecFloat34, CheckStatu
12901289 {
12911290 char temp[STRING_SIZE];
12921291 decQuadToString (reinterpret_cast <const decQuad*>(from), temp);
1293- unsigned int len = strlen (temp);
1292+ unsigned int len = fb_strlen (temp);
12941293 if (len < bufSize)
12951294 strncpy (buffer, temp, bufSize);
12961295 else
@@ -3359,8 +3358,8 @@ void ThreadCleanup::remove(FPTR_VOID_PTR cleanup, void* arg)
33593358class ThreadBuffer : public GlobalStorage
33603359{
33613360private:
3362- const static size_t BUFFER_SIZE = 8192 ; // make it match with call stack limit == 2048
3363- char buffer[BUFFER_SIZE];
3361+ static inline constexpr size_t BUFFER_SIZE = 8192 ; // make it match with call stack limit == 2048
3362+ char buffer[BUFFER_SIZE]{} ;
33643363 char * buffer_ptr;
33653364
33663365public:
@@ -3429,7 +3428,7 @@ class Strings
34293428};
34303429Firebird::GlobalPtr<Strings> cleanStrings;
34313430
3432- const char * circularAlloc (const char * s, unsigned len)
3431+ const char * circularAlloc (const char * s, size_t len)
34333432{
34343433 return getThreadBuffer ()->alloc (s, len);
34353434}
0 commit comments