Skip to content

Commit

Permalink
also pass with unused parameter checking
Browse files Browse the repository at this point in the history
  • Loading branch information
pstorz authored and arogge committed Nov 2, 2022
1 parent b5551be commit c12f184
Show file tree
Hide file tree
Showing 126 changed files with 2,026 additions and 1,652 deletions.
8 changes: 4 additions & 4 deletions core/src/cats/bvfs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class pathid_cache {
};

// Generic path handlers used for database queries.
static int GetPathHandler(void* ctx, int fields, char** row)
static int GetPathHandler(void* ctx, [[maybe_unused]] int fields, char** row)
{
PoolMem* buf = (PoolMem*)ctx;

Expand Down Expand Up @@ -355,7 +355,7 @@ int BareosDb::BvfsBuildLsFileQuery(PoolMem& query,
return nb_record;
}

static int ResultHandler(void* ctx, int fields, char** row)
static int ResultHandler([[maybe_unused]] void* ctx, int fields, char** row)
{
Dmsg1(100, "ResultHandler(*,%d,**)", fields);
if (fields == 4) {
Expand Down Expand Up @@ -548,7 +548,7 @@ DBId_t Bvfs::get_root()
return p;
}

int Bvfs::_handlePath(void* ctx, int fields, char** row)
int Bvfs::_handlePath([[maybe_unused]] void* ctx, int fields, char** row)
{
if (BvfsIsDir(row)) {
// Can have the same path 2 times
Expand Down Expand Up @@ -598,7 +598,7 @@ bool Bvfs::ls_dirs()
return true;
}

static void build_ls_files_query(JobControlRecord* jcr,
static void build_ls_files_query([[maybe_unused]] JobControlRecord* jcr,
BareosDb* db,
PoolMem& query,
const char* JobId,
Expand Down
10 changes: 6 additions & 4 deletions core/src/cats/cats.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Copyright (C) 2011-2011 Free Software Foundation Europe e.V.
Copyright (C) 2011-2016 Planets Communications B.V.
Copyright (C) 2013-2020 Bareos GmbH & Co. KG
Copyright (C) 2013-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
Expand Down Expand Up @@ -166,7 +166,7 @@ void BareosDb::PrintLockInfo(FILE* fp)
* string must be long enough (max 2*old+1) to hold
* the escaped output.
*/
void BareosDb::EscapeString(JobControlRecord* jcr,
void BareosDb::EscapeString([[maybe_unused]] JobControlRecord* jcr,
char* snew,
const char* old,
int len)
Expand Down Expand Up @@ -201,7 +201,9 @@ void BareosDb::EscapeString(JobControlRecord* jcr,
* We base64 encode the data so its normal ASCII
* Memory is stored in BareosDb struct, no need to free it.
*/
char* BareosDb::EscapeObject(JobControlRecord* jcr, char* old, int len)
char* BareosDb::EscapeObject([[maybe_unused]] JobControlRecord* jcr,
char* old,
int len)
{
const int MaxLength = Base64LengthUnpadded(len) + 1;
esc_obj = CheckPoolMemorySize(esc_obj, MaxLength + 1);
Expand All @@ -215,7 +217,7 @@ char* BareosDb::EscapeObject(JobControlRecord* jcr, char* old, int len)
* Unescape binary object
* We base64 encode the data so its normal ASCII
*/
void BareosDb::UnescapeObject(JobControlRecord* jcr,
void BareosDb::UnescapeObject([[maybe_unused]] JobControlRecord* jcr,
char* from,
int32_t expected_len,
POOLMEM*& dest,
Expand Down
8 changes: 4 additions & 4 deletions core/src/cats/cats.h
Original file line number Diff line number Diff line change
Expand Up @@ -939,13 +939,13 @@ class BareosDb : public BareosDbQueryEnum {
const char* old,
int len);
virtual char* EscapeObject(JobControlRecord* jcr, char* old, int len);
virtual unsigned char* EscapeObject(const unsigned char* old,
std::size_t old_len,
std::size_t& new_len)
virtual unsigned char* EscapeObject([[maybe_unused]] const unsigned char* old,
[[maybe_unused]] std::size_t old_len,
[[maybe_unused]] std::size_t& new_len)
{
return nullptr;
}
virtual void FreeEscapedObjectMemory(unsigned char* obj) {}
virtual void FreeEscapedObjectMemory([[maybe_unused]] unsigned char* obj) {}

virtual void UnescapeObject(JobControlRecord* jcr,
char* from,
Expand Down
9 changes: 5 additions & 4 deletions core/src/cats/postgresql.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ static dlist<BareosDbPostgresql>* db_list = NULL;

static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;

BareosDbPostgresql::BareosDbPostgresql(JobControlRecord* jcr,
const char* db_driver,
BareosDbPostgresql::BareosDbPostgresql([[maybe_unused]] JobControlRecord* jcr,
[[maybe_unused]] const char* db_driver,
const char* db_name,
const char* db_user,
const char* db_password,
Expand Down Expand Up @@ -388,7 +388,7 @@ void BareosDbPostgresql::FreeEscapedObjectMemory(unsigned char* obj)
*/
void BareosDbPostgresql::UnescapeObject(JobControlRecord* jcr,
char* from,
int32_t expected_len,
[[maybe_unused]] int32_t expected_len,
POOLMEM*& dest,
int32_t* dest_len)
{
Expand Down Expand Up @@ -578,7 +578,8 @@ bool BareosDbPostgresql::SqlQueryWithHandler(const char* query,
* Returns: true on success
* false on failure
*/
bool BareosDbPostgresql::SqlQueryWithoutHandler(const char* query, int flags)
bool BareosDbPostgresql::SqlQueryWithoutHandler(const char* query,
[[maybe_unused]] int flags)
{
int i;
bool retry = true;
Expand Down
15 changes: 9 additions & 6 deletions core/src/cats/postgresql_batch.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Copyright (C) 2003-2011 Free Software Foundation Europe e.V.
Copyright (C) 2011-2016 Planets Communications B.V.
Copyright (C) 2013-2020 Bareos GmbH & Co. KG
Copyright (C) 2013-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
Expand Down Expand Up @@ -34,7 +34,8 @@
# include "lib/berrno.h"
# include "lib/dlist.h"

bool BareosDbPostgresql::SqlBatchStartFileTable(JobControlRecord* jcr)
bool BareosDbPostgresql::SqlBatchStartFileTable([
[maybe_unused]] JobControlRecord* jcr)
{
const char* query = "COPY batch FROM STDIN";

Expand Down Expand Up @@ -94,8 +95,9 @@ bool BareosDbPostgresql::SqlBatchStartFileTable(JobControlRecord* jcr)
}

// Set error to something to abort operation
bool BareosDbPostgresql::SqlBatchEndFileTable(JobControlRecord* jcr,
const char* error)
bool BareosDbPostgresql::SqlBatchEndFileTable(
[[maybe_unused]] JobControlRecord* jcr,
const char* error)
{
int res;
int count = 30;
Expand Down Expand Up @@ -191,8 +193,9 @@ static char* pgsql_copy_escape(char* dest, const char* src, size_t len)
return dest;
}

bool BareosDbPostgresql::SqlBatchInsertFileTable(JobControlRecord* jcr,
AttributesDbRecord* ar)
bool BareosDbPostgresql::SqlBatchInsertFileTable(
[[maybe_unused]] JobControlRecord* jcr,
AttributesDbRecord* ar)
{
int res;
int count = 30;
Expand Down
12 changes: 7 additions & 5 deletions core/src/cats/sql.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ DBId_t dbid_list::get(int i) const
}


int DbIntHandler(void* ctx, int num_fields, char** row)
int DbIntHandler(void* ctx, [[maybe_unused]] int num_fields, char** row)
{
uint32_t* val = (uint32_t*)ctx;

Expand All @@ -83,7 +83,7 @@ int DbIntHandler(void* ctx, int num_fields, char** row)
* Called here to retrieve a 32/64 bit integer from the database.
* The returned integer will be extended to 64 bit.
*/
int db_int64_handler(void* ctx, int num_fields, char** row)
int db_int64_handler(void* ctx, [[maybe_unused]] int num_fields, char** row)
{
db_int64_ctx* lctx = (db_int64_ctx*)ctx;

Expand All @@ -98,7 +98,7 @@ int db_int64_handler(void* ctx, int num_fields, char** row)
* Called here to retrieve a btime from the database.
* The returned integer will be extended to 64 bit.
*/
int DbStrtimeHandler(void* ctx, int num_fields, char** row)
int DbStrtimeHandler(void* ctx, [[maybe_unused]] int num_fields, char** row)
{
db_int64_ctx* lctx = (db_int64_ctx*)ctx;

Expand Down Expand Up @@ -126,7 +126,9 @@ struct max_connections_context {
uint32_t nr_connections;
};

static inline int DbMaxConnectionsHandler(void* ctx, int num_fields, char** row)
static inline int DbMaxConnectionsHandler(void* ctx,
[[maybe_unused]] int num_fields,
char** row)
{
struct max_connections_context* context;
uint32_t index;
Expand Down Expand Up @@ -422,7 +424,7 @@ void BareosDb::ListDashes(OutputFormatter* send)
}

// List result handler used by queries done with db_big_sql_query()
int BareosDb::ListResult(void* vctx, int nb_col, char** row)
int BareosDb::ListResult(void* vctx, [[maybe_unused]] int nb_col, char** row)
{
JobControlRecord* jcr;
char ewc[30];
Expand Down
2 changes: 1 addition & 1 deletion core/src/cats/sql_delete.cc
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ struct s_del_ctx {
* is allowed to get to MAX_DEL_LIST_LEN to limit the
* maximum malloc'ed memory.
*/
static int DeleteHandler(void* ctx, int num_fields, char** row)
static int DeleteHandler(void* ctx, [[maybe_unused]] int num_fields, char** row)
{
struct s_del_ctx* del = (struct s_del_ctx*)ctx;

Expand Down
6 changes: 3 additions & 3 deletions core/src/cats/sql_get.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1231,7 +1231,7 @@ static void strip_md5(char* q)
*
* TODO: See if we can do the SORT only if needed (as an argument)
*/
bool BareosDb::GetFileList(JobControlRecord* jcr,
bool BareosDb::GetFileList([[maybe_unused]] JobControlRecord* jcr,
const char* jobids,
bool use_md5,
bool use_delta,
Expand Down Expand Up @@ -1277,7 +1277,7 @@ bool BareosDb::GetFileList(JobControlRecord* jcr,
return BigSqlQuery(query.c_str(), ResultHandler, ctx);
}

bool BareosDb::GetUsedBaseJobids(JobControlRecord* jcr,
bool BareosDb::GetUsedBaseJobids([[maybe_unused]] JobControlRecord* jcr,
const char* jobids,
db_list_ctx* result)
{
Expand Down Expand Up @@ -1479,7 +1479,7 @@ bool BareosDb::GetBaseJobid(JobControlRecord* jcr,
return retval;
}

bool BareosDb::GetVolumeJobids(JobControlRecord* jcr,
bool BareosDb::GetVolumeJobids([[maybe_unused]] JobControlRecord* jcr,
MediaDbRecord* mr,
db_list_ctx* lst)
{
Expand Down
2 changes: 1 addition & 1 deletion core/src/cats/sql_list.cc
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ void BareosDb::ListJobRecords(JobControlRecord* jcr,
}

void BareosDb::ListJobTotals(JobControlRecord* jcr,
JobDbRecord* jr,
[[maybe_unused]] JobDbRecord* jr,
OutputFormatter* sendit)
{
DbLocker _{this};
Expand Down
34 changes: 17 additions & 17 deletions core/src/cats/sql_pooling.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Copyright (C) 2010-2012 Free Software Foundation Europe e.V.
Copyright (C) 2011-2016 Planets Communications B.V.
Copyright (C) 2013-2020 Bareos GmbH & Co. KG
Copyright (C) 2013-2022 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
Expand Down Expand Up @@ -84,21 +84,21 @@ BareosDb* DbSqlGetNonPooledConnection(JobControlRecord* jcr,
* Initialize the sql connection pool.
* For non pooling this is a no-op.
*/
bool db_sql_pool_initialize(const char* db_drivername,
const char* db_name,
const char* db_user,
const char* db_password,
const char* db_address,
int db_port,
const char* db_socket,
bool disable_batch_insert,
bool try_reconnect,
bool exit_on_fatal,
int min_connections,
int max_connections,
int increment_connections,
int idle_timeout,
int validate_timeout)
bool db_sql_pool_initialize([[maybe_unused]] const char* db_drivername,
[[maybe_unused]] const char* db_name,
[[maybe_unused]] const char* db_user,
[[maybe_unused]] const char* db_password,
[[maybe_unused]] const char* db_address,
[[maybe_unused]] int db_port,
[[maybe_unused]] const char* db_socket,
[[maybe_unused]] bool disable_batch_insert,
[[maybe_unused]] bool try_reconnect,
[[maybe_unused]] bool exit_on_fatal,
[[maybe_unused]] int min_connections,
[[maybe_unused]] int max_connections,
[[maybe_unused]] int increment_connections,
[[maybe_unused]] int idle_timeout,
[[maybe_unused]] int validate_timeout)
{
return true;
}
Expand Down Expand Up @@ -145,7 +145,7 @@ BareosDb* DbSqlGetPooledConnection(JobControlRecord* jcr,
*/
void DbSqlClosePooledConnection(JobControlRecord* jcr,
BareosDb* mdb,
bool abort)
[[maybe_unused]] bool abort)
{
mdb->CloseDatabase(jcr);
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/cats/sql_update.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
bool BareosDb::AddDigestToFileRecord(JobControlRecord* jcr,
FileId_t FileId,
char* digest,
int type)
[[maybe_unused]] int type)
{
char ed1[50];
int len = strlen(digest);
Expand Down

0 comments on commit c12f184

Please sign in to comment.