Skip to content

Commit f408855

Browse files
committed
Fix -Wformat= warning in burp
+ misc other improvements
1 parent 9ea7100 commit f408855

File tree

3 files changed

+23
-27
lines changed

3 files changed

+23
-27
lines changed

src/burp/burp.cpp

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ enum gbak_action
108108
static void close_out_transaction(gbak_action, Firebird::ITransaction**);
109109
//static void enable_signals();
110110
//static void excp_handler();
111-
static SLONG get_number(const SCHAR*);
111+
static SLONG get_number(const SCHAR*) noexcept;
112112
static ULONG get_size(const SCHAR*, burp_fil*);
113113
static gbak_action open_files(const TEXT *, const TEXT**, USHORT,
114114
const Firebird::ClumpletWriter&);
@@ -134,8 +134,8 @@ struct StatFormat
134134
static inline constexpr const char* STAT_CHARS = "TDRW";
135135
static inline constexpr StatFormat STAT_FORMATS[] =
136136
{
137-
{"time", "%4lu.%03u ", 9},
138-
{"delta", "%2lu.%03u ", 7},
137+
{"time", "%4u.%03u ", 9},
138+
{"delta", "%2u.%03u ", 7},
139139
{"reads", "%6" UQUADFORMAT" ", 7},
140140
{"writes", "%6" UQUADFORMAT" ", 7}
141141
};
@@ -260,7 +260,7 @@ static int svc_api_gbak(Firebird::UtilSvc* uSvc, const Switches& switches)
260260
case IN_SW_BURP_SE: // service name
261261
if (itr >= argc - 1)
262262
{
263-
int errnum = inSw->in_sw == IN_SW_BURP_USER ? 188 : // user name parameter missing
263+
const int errnum = inSw->in_sw == IN_SW_BURP_USER ? 188 : // user name parameter missing
264264
inSw->in_sw == IN_SW_BURP_PASS ? 189 : // password parameter missing
265265
273; // service name parameter missing
266266

@@ -953,7 +953,7 @@ int gbak(Firebird::UtilSvc* uSvc)
953953
if (++itr >= argc)
954954
BURP_error(326, true); // verbose interval parameter missing
955955

956-
SLONG verbint_val = get_number(argv[itr]);
956+
const SLONG verbint_val = get_number(argv[itr]);
957957
if (verbint_val < MIN_VERBOSE_INTERVAL)
958958
{
959959
// verbose interval value cannot be smaller than @1
@@ -1170,7 +1170,7 @@ int gbak(Firebird::UtilSvc* uSvc)
11701170
uSvc->fillDpb(dpb);
11711171

11721172
const UCHAR* authBlock;
1173-
unsigned int authSize = uSvc->getAuthBlock(&authBlock);
1173+
const unsigned int authSize = uSvc->getAuthBlock(&authBlock);
11741174
if (authBlock)
11751175
{
11761176
dpb.insertBytes(isc_dpb_auth_block, authBlock, authSize);
@@ -1521,7 +1521,7 @@ int gbak(Firebird::UtilSvc* uSvc)
15211521

15221522

15231523

1524-
void BURP_abort(Firebird::IStatus* status)
1524+
void BURP_abort(const Firebird::IStatus* status)
15251525
{
15261526
/**************************************
15271527
*
@@ -1536,7 +1536,7 @@ void BURP_abort(Firebird::IStatus* status)
15361536
BurpMaster master;
15371537
BurpGlobals* tdgbl = master.get();
15381538

1539-
USHORT code = tdgbl->action && tdgbl->action->act_action == ACT_backup_fini ? 351 : 83;
1539+
const USHORT code = tdgbl->action && tdgbl->action->act_action == ACT_backup_fini ? 351 : 83;
15401540
// msg 351 Error closing database, but backup file is OK
15411541
// msg 83 Exiting before completion due to errors
15421542

@@ -1606,7 +1606,7 @@ void BURP_error(USHORT errcode, bool abort, const char* str)
16061606
}
16071607

16081608

1609-
void BURP_error_redirect(Firebird::IStatus* status_vector, USHORT errcode, const SafeArg& arg)
1609+
void BURP_error_redirect(const Firebird::IStatus* status_vector, USHORT errcode, const SafeArg& arg)
16101610
{
16111611
/**************************************
16121612
*
@@ -1759,7 +1759,7 @@ void BURP_print(bool err, USHORT number, const char* str)
17591759
}
17601760

17611761

1762-
void BURP_print_status(bool err, Firebird::IStatus* status_vector, USHORT secondNumber)
1762+
void BURP_print_status(bool err, const Firebird::IStatus* status_vector, USHORT secondNumber)
17631763
{
17641764
/**************************************
17651765
*
@@ -1814,7 +1814,7 @@ void BURP_print_status(bool err, Firebird::IStatus* status_vector, USHORT second
18141814
}
18151815

18161816

1817-
void BURP_print_warning(Firebird::IStatus* status, bool printErrorAsWarning)
1817+
void BURP_print_warning(const Firebird::IStatus* status, bool printErrorAsWarning)
18181818
{
18191819
/**************************************
18201820
*
@@ -1977,7 +1977,7 @@ static void close_out_transaction(gbak_action action, Firebird::ITransaction** t
19771977
}
19781978

19791979

1980-
static SLONG get_number( const SCHAR* string)
1980+
static SLONG get_number(const SCHAR* string) noexcept
19811981
{
19821982
/**************************************
19831983
*
@@ -1986,10 +1986,7 @@ static SLONG get_number( const SCHAR* string)
19861986
**************************************
19871987
*
19881988
* Functional description
1989-
* Convert a string to binary, complaining bitterly if
1990-
* the string is bum.
1991-
* CVC: where does it complain? It does return zero, nothing else.
1992-
* Worse, this function doesn't check for overflow.
1989+
* Convert a string to binary
19931990
**************************************/
19941991
SCHAR c;
19951992
SLONG value = 0;
@@ -2077,7 +2074,7 @@ static gbak_action open_files(const TEXT* file1,
20772074

20782075
if (tdgbl->gbl_sw_keyholder)
20792076
{
2080-
unsigned char info[] = {fb_info_crypt_key, fb_info_crypt_plugin};
2077+
constexpr unsigned char info[] = {fb_info_crypt_key, fb_info_crypt_plugin};
20812078
unsigned char buffer[(1 + 2 + MAX_SQL_IDENTIFIER_SIZE) * 2 + 2];
20822079
unsigned int len;
20832080

@@ -2616,7 +2613,7 @@ static ULONG get_size(const SCHAR* string, burp_fil* file)
26162613
{
26172614
if (isdigit(c))
26182615
{
2619-
int val = c - '0';
2616+
const int val = c - '0';
26202617
if (size >= overflow)
26212618
{
26222619
file->fil_size_code = size_e;
@@ -2836,13 +2833,13 @@ void BurpGlobals::print_stats(USHORT number)
28362833

28372834
if (gbl_stat_flags & (1 << TIME_TOTAL))
28382835
{
2839-
SINT64 t1 = (t0 - gbl_stats[TIME_TOTAL]) / freq_ms;
2836+
const SINT64 t1 = (t0 - gbl_stats[TIME_TOTAL]) / freq_ms;
28402837
burp_output(false, STAT_FORMATS[TIME_TOTAL].format, (int)(t1 / 1000), (int)(t1 % 1000));
28412838
}
28422839

28432840
if (gbl_stat_flags & (1 << TIME_DELTA))
28442841
{
2845-
SINT64 t2 = (t0 - gbl_stats[TIME_DELTA]) / freq_ms;
2842+
const SINT64 t2 = (t0 - gbl_stats[TIME_DELTA]) / freq_ms;
28462843
burp_output(false, STAT_FORMATS[TIME_DELTA].format, (int)(t2 / 1000), (int)(t2 % 1000));
28472844

28482845
gbl_stats[TIME_DELTA] = t0;

src/burp/burp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1394,7 +1394,7 @@ static inline UCHAR* BURP_alloc_zero(ULONG size)
13941394
return (UCHAR*)(tdgbl->getPool().calloc(size ALLOC_ARGS));
13951395
}
13961396

1397-
static inline void BURP_free(void* block)
1397+
static inline void BURP_free(void* block) noexcept
13981398
{
13991399
MemoryPool::globalFree(block);
14001400
}

src/burp/burp_proto.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,18 @@ class BurpGlobals;
3434
int BURP_main(Firebird::UtilSvc*);
3535
int gbak(Firebird::UtilSvc*);
3636

37-
void BURP_abort(Firebird::IStatus* status = nullptr);
37+
void BURP_abort(const Firebird::IStatus* status = nullptr);
3838
void BURP_error(USHORT, bool, const MsgFormat::SafeArg& arg = MsgFormat::SafeArg());
3939
void BURP_error(USHORT, bool, const char* str);
40-
void BURP_error_redirect(Firebird::IStatus*, USHORT, const MsgFormat::SafeArg& arg = MsgFormat::SafeArg());
40+
void BURP_error_redirect(const Firebird::IStatus*, USHORT, const MsgFormat::SafeArg& arg = MsgFormat::SafeArg());
4141
void BURP_msg_partial(bool, USHORT, const MsgFormat::SafeArg& arg = MsgFormat::SafeArg());
4242
void BURP_msg_put(bool, USHORT, const MsgFormat::SafeArg& arg);
43-
const int BURP_MSG_GET_SIZE = 128; // Use it for buffers passed to this function.
43+
inline constexpr int BURP_MSG_GET_SIZE = 128; // Use it for buffers passed to this function.
4444
void BURP_msg_get(USHORT, TEXT*, const MsgFormat::SafeArg& arg = MsgFormat::SafeArg());
45-
void BURP_output_version(void*, const TEXT*);
4645
void BURP_print(bool err, USHORT, const MsgFormat::SafeArg& arg = MsgFormat::SafeArg());
4746
void BURP_print(bool err, USHORT, const char* str);
48-
void BURP_print_status(bool err, Firebird::IStatus* status, USHORT secondNumber = 0);
49-
void BURP_print_warning(Firebird::IStatus* status, bool printErrorAsWarning = false);
47+
void BURP_print_status(bool err, const Firebird::IStatus* status, USHORT secondNumber = 0);
48+
void BURP_print_warning(const Firebird::IStatus* status, bool printErrorAsWarning = false);
5049
void BURP_verbose(USHORT, const MsgFormat::SafeArg& arg = MsgFormat::SafeArg());
5150
void BURP_verbose(USHORT, const Firebird::string& str);
5251
void BURP_message(USHORT, const MsgFormat::SafeArg& arg = MsgFormat::SafeArg(), bool totals = false);

0 commit comments

Comments
 (0)