Skip to content

Commit

Permalink
dird: removed memset for del_ctx
Browse files Browse the repository at this point in the history
  • Loading branch information
franku committed Nov 5, 2019
1 parent 8356183 commit 30b135b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 16 deletions.
3 changes: 1 addition & 2 deletions core/src/dird/autoprune.cc
Expand Up @@ -89,7 +89,7 @@ void PruneVolumes(JobControlRecord* jcr,
int count;
UaContext* ua;
dbid_list ids;
struct del_ctx prune_list;
del_ctx prune_list;
PoolMem query(PM_MESSAGE);
char ed1[50], ed2[100], ed3[50];

Expand All @@ -99,7 +99,6 @@ void PruneVolumes(JobControlRecord* jcr,
return;
}

memset(&prune_list, 0, sizeof(prune_list));
prune_list.max_ids = 10000;
prune_list.JobId = (JobId_t*)malloc(sizeof(JobId_t) * prune_list.max_ids);

Expand Down
2 changes: 1 addition & 1 deletion core/src/dird/dird.h
Expand Up @@ -53,7 +53,7 @@ namespace directordaemon {
/* Used in ua_prune.c and ua_purge.c */

struct s_count_ctx {
int count;
int count{};
};

#define MAX_DEL_LIST_LEN 2000000
Expand Down
20 changes: 8 additions & 12 deletions core/src/dird/ua_prune.cc
Expand Up @@ -49,14 +49,14 @@ static const ClientDbRecord emptyClientDbRecord = {};
/* Forward referenced functions */
static bool PruneDirectory(UaContext* ua, ClientResource* client);
static bool PruneStats(UaContext* ua, utime_t retention);
static bool GrowDelList(struct del_ctx* del);
static bool GrowDelList(del_ctx* del);

/**
* Called here to count entries to be deleted
*/
int DelCountHandler(void* ctx, int num_fields, char** row)
{
struct s_count_ctx* cnt = (struct s_count_ctx*)ctx;
s_count_ctx* cnt = static_cast<s_count_ctx*>(ctx);

if (row[0]) {
cnt->count = str_to_int64(row[0]);
Expand All @@ -76,7 +76,7 @@ int DelCountHandler(void* ctx, int num_fields, char** row)
*/
int JobDeleteHandler(void* ctx, int num_fields, char** row)
{
struct del_ctx* del = (struct del_ctx*)ctx;
del_ctx* del = static_cast<del_ctx*>(ctx);

if (!GrowDelList(del)) { return 1; }
del->JobId[del->num_ids] = (JobId_t)str_to_int64(row[0]);
Expand All @@ -88,7 +88,7 @@ int JobDeleteHandler(void* ctx, int num_fields, char** row)

int FileDeleteHandler(void* ctx, int num_fields, char** row)
{
struct del_ctx* del = (struct del_ctx*)ctx;
del_ctx* del = static_cast<del_ctx*>(ctx);

if (!GrowDelList(del)) { return 1; }
del->JobId[del->num_ids++] = (JobId_t)str_to_int64(row[0]);
Expand Down Expand Up @@ -489,16 +489,14 @@ static bool prune_set_filter(UaContext* ua,
*/
bool PruneFiles(UaContext* ua, ClientResource* client, PoolResource* pool)
{
struct del_ctx del;
del_ctx del;
struct s_count_ctx cnt;
PoolMem query(PM_MESSAGE);
PoolMem sql_where(PM_MESSAGE);
PoolMem sql_from(PM_MESSAGE);
utime_t period;
char ed1[50];

memset(&del, 0, sizeof(del));

if (pool && pool->FileRetention > 0) {
period = pool->FileRetention;

Expand Down Expand Up @@ -585,7 +583,7 @@ static bool CreateTempTables(UaContext* ua)
return true;
}

static bool GrowDelList(struct del_ctx* del)
static bool GrowDelList(del_ctx* del)
{
if (del->num_ids == MAX_DEL_LIST_LEN) { return false; }

Expand Down Expand Up @@ -666,8 +664,7 @@ static bool PruneBackupJobs(UaContext* ua,
struct accurate_check_ctx* elt = nullptr;
db_list_ctx jobids, tempids;
JobDbRecord jr;
struct del_ctx del;
memset(&del, 0, sizeof(del));
del_ctx del;

if (pool && pool->JobRetention > 0) {
period = pool->JobRetention;
Expand Down Expand Up @@ -843,15 +840,14 @@ bool PruneJobs(UaContext* ua,
bool PruneVolume(UaContext* ua, MediaDbRecord* mr)
{
PoolMem query(PM_MESSAGE);
struct del_ctx del;
del_ctx del;
bool ok = false;
int count;

if (mr->Enabled == VOL_ARCHIVED) {
return false; /* Cannot prune archived volumes */
}

memset(&del, 0, sizeof(del));
del.max_ids = 10000;
del.JobId = (JobId_t*)malloc(sizeof(JobId_t) * del.max_ids);

Expand Down
2 changes: 1 addition & 1 deletion core/src/dird/ua_purge.cc
Expand Up @@ -282,7 +282,7 @@ static bool PurgeFilesFromClient(UaContext* ua, ClientResource* client)
*/
static bool PurgeJobsFromClient(UaContext* ua, ClientResource* client)
{
struct del_ctx del;
del_ctx del;
PoolMem query(PM_MESSAGE);
ClientDbRecord cr;
char ed1[50];
Expand Down

0 comments on commit 30b135b

Please sign in to comment.