Skip to content

Commit 0715e0f

Browse files
committed
Fix -Wparentheses in pretty
+ misc other improvements
1 parent 898fa33 commit 0715e0f

File tree

1 file changed

+26
-24
lines changed

1 file changed

+26
-24
lines changed

src/common/pretty.cpp

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
#include "../common/prett_proto.h"
3737
#include "../yvalve/gds_proto.h"
3838

39-
static inline void ADVANCE_PTR(TEXT*& ptr)
39+
static inline void ADVANCE_PTR(TEXT*& ptr) noexcept
4040
{
4141
while (*ptr)
4242
ptr++;
@@ -77,45 +77,45 @@ struct ctl
7777

7878
static int blr_format(ctl*, const char *, ...);
7979
static int error(ctl*, SSHORT, const TEXT *, int);
80-
static int indent(ctl*, SSHORT);
80+
static int indent(ctl*, SSHORT) noexcept;
8181
static int print_blr_dtype(ctl*, bool);
82-
static void print_blr_line(void*, SSHORT, const char*);
82+
static void print_blr_line(void*, SSHORT, const char*) noexcept;
8383
static int print_byte(ctl*);
8484
static int print_char(ctl*, SSHORT);
8585
static int print_dyn_verb(ctl*, SSHORT);
86-
static int print_line(ctl*, SSHORT);
86+
static int print_line(ctl*, SSHORT) noexcept;
8787
static SLONG print_long(ctl*);
8888
static int print_sdl_verb(ctl*, SSHORT);
8989
static int print_string(ctl*, SSHORT);
9090
static int print_word(ctl*);
9191

9292

93-
static inline void CHECK_BUFFER(ctl* control, SSHORT offset)
93+
static inline void CHECK_BUFFER(ctl* control, SSHORT offset) noexcept
9494
{
9595
if (control->remaining() < 20)
9696
print_line(control, offset);
9797
}
9898

9999

100-
const char *dyn_table[] =
100+
constexpr const char *dyn_table[] =
101101
{
102102
#include "../common/dyntable.h"
103103
NULL
104104
};
105105

106-
const char *cdb_table[] =
106+
constexpr const char *cdb_table[] =
107107
{
108108
#include "../common/cdbtable.h"
109109
NULL
110110
};
111111

112-
const char *sdl_table[] =
112+
constexpr const char *sdl_table[] =
113113
{
114114
#include "../common/sdltable.h"
115115
NULL
116116
};
117117

118-
const char *map_strings[] =
118+
constexpr const char *map_strings[] =
119119
{
120120
"FIELD2",
121121
"FIELD1",
@@ -153,7 +153,7 @@ int PRETTY_print_cdb(const UCHAR* blr, FPTR_PRINT_CALLBACK routine, void* user_a
153153
control->ctl_language = language;
154154
control->reset();
155155

156-
SSHORT level = 0;
156+
constexpr SSHORT level = 0;
157157
indent(control, level);
158158
const SSHORT i = BLR_BYTE;
159159

@@ -164,11 +164,11 @@ int PRETTY_print_cdb(const UCHAR* blr, FPTR_PRINT_CALLBACK routine, void* user_a
164164
snprintf(temp, sizeof(temp), "gds__dpb_version%d", i);
165165
blr_format(control, temp);
166166

167-
SSHORT offset = 0;
167+
constexpr SSHORT offset = 0;
168168
print_line(control, offset);
169169

170170
SSHORT parameter;
171-
while (parameter = BLR_BYTE)
171+
while ((parameter = BLR_BYTE))
172172
{
173173
const char* p;
174174
if (parameter > static_cast<FB_SSIZE_T>(FB_NELEM(cdb_table)) || !(p = cdb_table[parameter]))
@@ -216,13 +216,13 @@ int PRETTY_print_dyn(const UCHAR* blr, FPTR_PRINT_CALLBACK routine, void* user_a
216216

217217
const SSHORT version = BLR_BYTE;
218218

219-
SSHORT offset = 0;
219+
constexpr SSHORT offset = 0;
220220
if (version != isc_dyn_version_1)
221221
return error(control, offset, "*** dyn version %d is not supported ***\n", version);
222222

223223
blr_format(control, "gds__dyn_version_1, ");
224224
print_line(control, offset);
225-
SSHORT level = 1;
225+
constexpr SSHORT level = 1;
226226
PRINT_DYN_VERB;
227227

228228
if (BLR_BYTE != isc_dyn_eoc)
@@ -264,7 +264,7 @@ int PRETTY_print_sdl(const UCHAR* blr, FPTR_PRINT_CALLBACK routine, void *user_a
264264

265265
blr_format(control, "gds__sdl_version1, ");
266266
print_line(control, offset);
267-
SSHORT level = 1;
267+
constexpr SSHORT level = 1;
268268

269269
while (NEXT_BYTE != isc_sdl_eoc)
270270
PRINT_SDL_VERB;
@@ -318,7 +318,7 @@ static int error( ctl* control, SSHORT offset, const TEXT* string, int arg)
318318
// Indent for pretty printing.
319319
//
320320

321-
static int indent( ctl* control, SSHORT level)
321+
static int indent( ctl* control, SSHORT level) noexcept
322322
{
323323

324324
level *= 3;
@@ -493,15 +493,15 @@ static int print_blr_dtype(ctl* control, bool print_object)
493493
// Print a line of pretty-printed BLR.
494494
//
495495

496-
static void print_blr_line(void* arg, SSHORT offset, const char* line)
496+
static void print_blr_line(void* arg, SSHORT offset, const char* line) noexcept
497497
{
498498
ctl* control = static_cast<ctl*>(arg);
499499
bool comma = false;
500500
char c;
501501

502502
indent(control, control->ctl_level);
503503

504-
while (c = *line++)
504+
while ((c = *line++))
505505
{
506506
PUT_BYTE(c);
507507
if (c == ',')
@@ -565,8 +565,8 @@ static int print_dyn_verb( ctl* control, SSHORT level)
565565
const UCHAR dyn_operator = BLR_BYTE;
566566

567567
const char* p;
568-
const int size = FB_NELEM(dyn_table);
569-
if (dyn_operator > size || dyn_operator <= 0 || !(p = dyn_table[dyn_operator])) {
568+
constexpr int size = FB_NELEM(dyn_table);
569+
if (dyn_operator >= size || dyn_operator <= 0 || !(p = dyn_table[dyn_operator])) {
570570
return error(control, offset, "*** dyn operator %d is undefined ***\n", (int) dyn_operator);
571571
}
572572

@@ -634,7 +634,7 @@ static int print_dyn_verb( ctl* control, SSHORT level)
634634
return 0;
635635

636636
case isc_dyn_del_exception:
637-
if (length = print_word(control))
637+
if ((length = print_word(control)))
638638
do {
639639
print_char(control, offset);
640640
} while (--length);
@@ -668,7 +668,7 @@ static int print_dyn_verb( ctl* control, SSHORT level)
668668
return 0;
669669
}
670670

671-
if (length = print_word(control))
671+
if ((length = print_word(control)))
672672
do {
673673
print_char(control, offset);
674674
} while (--length);
@@ -743,7 +743,7 @@ static int print_dyn_verb( ctl* control, SSHORT level)
743743
// Invoke callback routine to print (or do something with) a line.
744744
//
745745

746-
static int print_line( ctl* control, SSHORT offset)
746+
static int print_line( ctl* control, SSHORT offset) noexcept
747747
{
748748
*control->ctl_ptr = 0;
749749
(*control->ctl_routine) (control->ctl_user_arg, offset, control->ctl_buffer);
@@ -818,7 +818,7 @@ static int print_sdl_verb( ctl* control, SSHORT level)
818818

819819
case isc_sdl_scalar:
820820
print_byte(control);
821-
821+
[[fallthrough]];
822822
case isc_sdl_element:
823823
n = print_byte(control);
824824
print_line(control, offset);
@@ -863,8 +863,10 @@ static int print_sdl_verb( ctl* control, SSHORT level)
863863

864864
case isc_sdl_do3:
865865
n++;
866+
[[fallthrough]];
866867
case isc_sdl_do2:
867868
n++;
869+
[[fallthrough]];
868870
case isc_sdl_do1:
869871
n += 2;
870872
print_byte(control);

0 commit comments

Comments
 (0)