Skip to content

Commit be7a5e6

Browse files
committed
misc const/constexpr/noexcept in gpre/cmd
1 parent 24ef7af commit be7a5e6

File tree

2 files changed

+38
-40
lines changed

2 files changed

+38
-40
lines changed

src/common/isc_file.cpp

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191

9292
#include "../common/config/config.h"
9393

94-
const char INET_FLAG = ':';
94+
constexpr char INET_FLAG = ':';
9595

9696
// Unix/NFS specific stuff
9797
#ifndef NO_NFS
@@ -106,15 +106,15 @@ const char INET_FLAG = ':';
106106
#endif
107107

108108
#if defined(_PATH_MOUNTED)
109-
const char* const MTAB = _PATH_MOUNTED;
109+
constexpr const char* MTAB = _PATH_MOUNTED;
110110
#elif defined(HPUX)
111-
const char* const MTAB = "/etc/mnttab";
111+
constexpr const char* MTAB = "/etc/mnttab";
112112
#elif defined(SOLARIS)
113-
const char* const MTAB = "/etc/mnttab";
113+
constexpr const char* MTAB = "/etc/mnttab";
114114
#elif defined(FREEBSD)
115-
const char* const MTAB = "/etc/fstab";
115+
constexpr const char* MTAB = "/etc/fstab";
116116
#else
117-
const char* const MTAB = "/etc/mtab";
117+
constexpr const char* MTAB = "/etc/mtab";
118118
#endif
119119

120120
#ifdef HAVE_SETMNTENT
@@ -198,7 +198,7 @@ static void expand_filename2(tstring&, bool);
198198

199199

200200
#if defined(WIN_NT)
201-
static void translate_slashes(tstring&);
201+
static void translate_slashes(tstring&) noexcept;
202202
static void expand_share_name(tstring&);
203203
static void share_name_from_resource(tstring&, LPNETRESOURCE);
204204
static void share_name_from_unc(tstring&, LPREMOTE_NAME_INFO);
@@ -602,10 +602,10 @@ bool ISC_expand_filename(tstring& buff, bool expand_mounts)
602602

603603
#ifdef WIN_NT
604604

605-
static void translate_slashes(tstring& Path)
605+
static void translate_slashes(tstring& Path) noexcept
606606
{
607-
const char sep = '\\';
608-
const char bad_sep = '/';
607+
constexpr char sep = '\\';
608+
constexpr char bad_sep = '/';
609609
for (char *p = Path.begin(), *q = Path.end(); p < q; p++)
610610
{
611611
if (*p == bad_sep) {
@@ -615,7 +615,7 @@ static void translate_slashes(tstring& Path)
615615
}
616616

617617

618-
static bool isDriveLetter(const tstring::char_type letter)
618+
static bool isDriveLetter(const tstring::char_type letter) noexcept
619619
{
620620
return (letter >= 'A' && letter <= 'Z') || (letter >= 'a' && letter <= 'z');
621621
}
@@ -628,8 +628,8 @@ static bool isDriveLetter(const tstring::char_type letter)
628628
static bool ShortToLongPathName(tstring& Path)
629629
{
630630
// Special characters.
631-
const char sep = '\\';
632-
const char colon = ':';
631+
constexpr char sep = '\\';
632+
constexpr char colon = ':';
633633

634634
// Copy the short path into the work buffer and convert forward
635635
// slashes to backslashes.
@@ -1718,7 +1718,7 @@ template <int BUFSIZE>
17181718
class WideCharBuffer
17191719
{
17201720
public:
1721-
WideCharBuffer() :
1721+
WideCharBuffer() noexcept :
17221722
m_len16(0)
17231723
{}
17241724

@@ -1736,7 +1736,7 @@ class WideCharBuffer
17361736

17371737
if (m_len16 == 0)
17381738
{
1739-
DWORD err = GetLastError();
1739+
const DWORD err = GetLastError();
17401740
if (err != ERROR_INSUFFICIENT_BUFFER)
17411741
return false;
17421742

@@ -1764,15 +1764,15 @@ class WideCharBuffer
17641764
if (codePage == CP_UTF8 || codePage == CP_UTF7)
17651765
pDefaultCharUsed = NULL;
17661766

1767-
WCHAR* utf16Buffer = m_utf16.begin();
1767+
const WCHAR* utf16Buffer = m_utf16.begin();
17681768

17691769
char* utf8Buffer = str.getBuffer(str.capacity());
17701770
int len8 = WideCharToMultiByte(codePage, 0, utf16Buffer, m_len16,
17711771
utf8Buffer, str.capacity(), NULL, pDefaultCharUsed);
17721772

17731773
if (len8 == 0 || defaultCharUsed)
17741774
{
1775-
DWORD err = GetLastError();
1775+
const DWORD err = GetLastError();
17761776
if (err != ERROR_INSUFFICIENT_BUFFER)
17771777
return false;
17781778

@@ -1823,7 +1823,7 @@ void ISC_systemToUtf8(Firebird::AbstractString& str)
18231823

18241824
if (!wBuffer.fromString(CP_ACP, str) || !wBuffer.toString(CP_UTF8, str))
18251825
{
1826-
DWORD err = GetLastError();
1826+
const DWORD err = GetLastError();
18271827
status_exception::raise(
18281828
Arg::Gds(isc_bad_conn_str) << Arg::Gds(isc_transliteration_failed) <<
18291829
Arg::Windows(err));
@@ -1846,7 +1846,7 @@ void ISC_utf8ToSystem(Firebird::AbstractString& str)
18461846

18471847
if (!wBuffer.fromString(CP_UTF8, str) || !wBuffer.toString(CP_ACP, str))
18481848
{
1849-
DWORD err = GetLastError();
1849+
const DWORD err = GetLastError();
18501850
status_exception::raise(
18511851
Arg::Gds(isc_bad_conn_str) << Arg::Gds(isc_transliteration_failed) <<
18521852
Arg::Windows(err));

src/gpre/cmd.cpp

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ static void create_check_constraint(gpre_req*, const act*, cnstrt*);
4949
static void create_constraint(gpre_req*, const act*, cnstrt*);
5050
static void create_database(gpre_req*, const act*);
5151
static void create_database_modify_dyn(gpre_req*, act*);
52-
static void create_default_blr(gpre_req*, const TEXT*, const USHORT);
53-
static void create_del_cascade_trg(gpre_req*, const act*, cnstrt*);
52+
static void create_default_blr(gpre_req*, const TEXT*, const USHORT) noexcept;
53+
static void create_del_cascade_trg(gpre_req*, const act*, const cnstrt*);
5454
static void create_domain(gpre_req*, const act*);
5555
static void create_domain_constraint(gpre_req*, const cnstrt*);
5656
static void create_generator(gpre_req*, const act*);
@@ -69,15 +69,15 @@ static void declare_filter(gpre_req*, const act*);
6969
static void declare_udf(gpre_req*, const act*);
7070
static void get_referred_fields(const act*, cnstrt*);
7171
static void grant_revoke_privileges(gpre_req*, const act*);
72-
static void init_field_struct(gpre_fld*);
73-
static void put_array_info(gpre_req*, const gpre_fld*);
74-
static void put_blr(gpre_req*, USHORT, gpre_nod*, pfn_local_trigger_cb);
72+
static void init_field_struct(gpre_fld*) noexcept;
73+
static void put_array_info(gpre_req*, const gpre_fld*) noexcept;
74+
static void put_blr(gpre_req*, USHORT, gpre_nod*, pfn_local_trigger_cb) noexcept;
7575
static void put_computed_blr(gpre_req*, const gpre_fld*);
7676
static void put_computed_source(gpre_req*, const gpre_fld*);
7777
static void put_cstring(gpre_req*, USHORT, const TEXT*);
7878
static void put_dtype(gpre_req*, const gpre_fld*);
7979
static void put_field_attributes(gpre_req*, const gpre_fld*);
80-
static void put_numeric(gpre_req*, USHORT, SSHORT);
80+
static void put_numeric(gpre_req*, USHORT, SSHORT) noexcept;
8181
static void put_short_cstring(gpre_req*, USHORT, const TEXT*);
8282
static void put_string(gpre_req*, USHORT, const TEXT*, USHORT);
8383
static void put_symbol(gpre_req*, int, const gpre_sym*);
@@ -95,7 +95,7 @@ static inline void STUFF_CHECK(gpre_req* request, int n)
9595
}
9696

9797

98-
const int BLOB_BUFFER_SIZE = 4096; // to read in blr blob for default values
98+
constexpr int BLOB_BUFFER_SIZE = 4096; // to read in blr blob for default values
9999

100100

101101
//____________________________________________________________
@@ -584,7 +584,7 @@ static void create_matching_blr(gpre_req* request, const cnstrt* constraint)
584584
//
585585

586586
static void create_default_blr(gpre_req* request,
587-
const TEXT* default_buff, const USHORT buff_size)
587+
const TEXT* default_buff, const USHORT buff_size) noexcept
588588
{
589589
int i;
590590

@@ -604,12 +604,12 @@ static void create_default_blr(gpre_req* request,
604604
// integrity) along with the trigger blr.
605605
//
606606

607-
static void create_upd_cascade_trg( gpre_req* request, const act* action,
607+
static void create_upd_cascade_trg(gpre_req* request, const act* action,
608608
cnstrt* constraint)
609609
{
610610
gpre_lls* for_key_fld = constraint->cnstrt_fields;
611611
gpre_lls* prim_key_fld = constraint->cnstrt_referred_fields;
612-
gpre_rel* relation = (gpre_rel*) action->act_object;
612+
const gpre_rel* relation = (gpre_rel*) action->act_object;
613613

614614
// no trigger name is generated here. Let the engine make one up
615615
put_string(request, isc_dyn_def_trigger, "", (USHORT) 0);
@@ -693,8 +693,8 @@ static void create_upd_cascade_trg( gpre_req* request, const act* action,
693693
// integrity) along with the trigger blr.
694694
//
695695

696-
static void create_del_cascade_trg( gpre_req* request, const act* action,
697-
cnstrt* constraint)
696+
static void create_del_cascade_trg(gpre_req* request, const act* action,
697+
const cnstrt* constraint)
698698
{
699699
const gpre_rel* relation = (gpre_rel*) action->act_object;
700700

@@ -2219,7 +2219,7 @@ static void grant_revoke_privileges( gpre_req* request, const act* action)
22192219
//
22202220
//
22212221

2222-
static void init_field_struct( gpre_fld* field)
2222+
static void init_field_struct(gpre_fld* field) noexcept
22232223
{
22242224
field->fld_dtype = 0;
22252225
field->fld_length = 0;
@@ -2254,7 +2254,7 @@ static void init_field_struct( gpre_fld* field)
22542254
// Put dimensions for the array field.
22552255
//
22562256

2257-
static void put_array_info( gpre_req* request, const gpre_fld* field)
2257+
static void put_array_info(gpre_req* request, const gpre_fld* field) noexcept
22582258
{
22592259
const ary* array_info = field->fld_array_info;
22602260
const SSHORT dims = (SSHORT) array_info->ary_dimension_count;
@@ -2281,7 +2281,7 @@ static void put_array_info( gpre_req* request, const gpre_fld* field)
22812281
//
22822282

22832283
static void put_blr(gpre_req* request,
2284-
USHORT blr_operator, gpre_nod* node, pfn_local_trigger_cb routine)
2284+
USHORT blr_operator, gpre_nod* node, pfn_local_trigger_cb routine) noexcept
22852285
{
22862286
request->add_byte(blr_operator);
22872287
const USHORT offset = request->req_blr - request->req_base;
@@ -2378,8 +2378,6 @@ static void put_dtype( gpre_req* request, const gpre_fld* field)
23782378
USHORT dtype = 0;
23792379

23802380
USHORT length = field->fld_length;
2381-
//const USHORT precision = field->fld_precision;
2382-
//const USHORT sub_type = field->fld_sub_type;
23832381
switch (field->fld_dtype)
23842382
{
23852383
case dtype_cstring:
@@ -2398,11 +2396,12 @@ static void put_dtype( gpre_req* request, const gpre_fld* field)
23982396
length--;
23992397
dtype = blr_text;
24002398
}
2399+
[[fallthrough]];
24012400

24022401
case dtype_text:
24032402
if (field->fld_dtype == dtype_text)
24042403
dtype = blr_text;
2405-
// Fall into
2404+
[[fallthrough]];
24062405

24072406
case dtype_varying:
24082407
fb_assert(length);
@@ -2561,9 +2560,8 @@ static void put_field_attributes( gpre_req* request, const gpre_fld* field)
25612560
// Put a numeric valued attributed to the output string.
25622561
//
25632562

2564-
static void put_numeric( gpre_req* request, USHORT blr_operator, SSHORT number)
2563+
static void put_numeric(gpre_req* request, USHORT blr_operator, SSHORT number) noexcept
25652564
{
2566-
25672565
request->add_byte(blr_operator);
25682566
request->add_word(2);
25692567
request->add_word(number);
@@ -2780,7 +2778,7 @@ static void replace_field_names(gpre_nod* const input,
27802778
if ((*ptr)->nod_type == nod_field)
27812779
{
27822780
ref* reference = (ref*) (*ptr)->nod_arg[0];
2783-
gpre_fld* rse_field = reference->ref_field;
2781+
const gpre_fld* rse_field = reference->ref_field;
27842782
if (null_them)
27852783
{
27862784
if (reference->ref_context == contexts[2]) {

0 commit comments

Comments
 (0)