Skip to content

Commit

Permalink
Revert "dird,filed, findlib and lib fix class-memaccess warnings"
Browse files Browse the repository at this point in the history
This reverts commit e37fe3f.
  • Loading branch information
pstorz authored and franku committed Nov 5, 2019
1 parent 97c373c commit a312b81
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 68 deletions.
9 changes: 6 additions & 3 deletions core/src/dird/next_vol.cc
Expand Up @@ -3,7 +3,7 @@
Copyright (C) 2001-2012 Free Software Foundation Europe e.V.
Copyright (C) 2011-2016 Planets Communications B.V.
Copyright (C) 2013-2019 Bareos GmbH & Co. KG
Copyright (C) 2013-2018 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 @@ -452,6 +452,9 @@ bool GetScratchVolume(JobControlRecord* jcr,
* GetPoolRecord will first try ScratchPoolId,
* and then try the pool named Scratch
*/
memset(&smr, 0, sizeof(smr));
memset(&spr, 0, sizeof(spr));

bstrncpy(spr.Name, "Scratch", sizeof(spr.Name));
spr.PoolId = mr->ScratchPoolId;
if (jcr->db->GetPoolRecord(jcr, &spr)) {
Expand Down Expand Up @@ -479,12 +482,12 @@ bool GetScratchVolume(JobControlRecord* jcr,

if (found) {
PoolMem query(PM_MESSAGE);
static const PoolDbRecord emtpyPoolDbRecord{};

/*
* Get pool record where the Scratch Volume will go to ensure that we can
* add a Volume.
*/
pr = emtpyPoolDbRecord;
memset(&pr, 0, sizeof(pr));
bstrncpy(pr.Name, jcr->res.pool->resource_name_, sizeof(pr.Name));

if (!jcr->db->GetPoolRecord(jcr, &pr)) {
Expand Down
11 changes: 8 additions & 3 deletions core/src/dird/stats.cc
Expand Up @@ -2,7 +2,7 @@
BAREOS® - Backup Archiving REcovery Open Sourced
Copyright (C) 2016-2016 Planets Communications B.V.
Copyright (C) 2014-2019 Bareos GmbH & Co. KG
Copyright (C) 2014-2016 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 @@ -74,6 +74,8 @@ static inline bool LookupDevice(JobControlRecord* jcr,
{
DeviceDbRecord dr;

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

if (cached_device.StorageId == StorageId &&
bstrcmp(cached_device.device_name, device_name)) {
*DeviceId = cached_device.DeviceId;
Expand Down Expand Up @@ -175,8 +177,8 @@ extern "C" void* statistics_thread(void* arg)
store = NULL;
}

store = (StorageResource*)my_config->GetNextRes(R_STORAGE,
(BareosResource*)store);
store = (StorageResource*)my_config->GetNextRes(
R_STORAGE, (BareosResource*)store);
if (!store) {
PmStrcpy(current_store, "");
UnlockRes(my_config);
Expand Down Expand Up @@ -218,6 +220,7 @@ extern "C" void* statistics_thread(void* arg)
PoolMem DevName(PM_NAME);
DeviceStatisticsDbRecord dsr;

memset(&dsr, 0, sizeof(dsr));
if (sscanf(sd->msg, DevStats, &dsr.SampleTime, DevName.c_str(),
&dsr.ReadBytes, &dsr.WriteBytes, &dsr.SpoolSize,
&dsr.NumWaiting, &dsr.NumWriters, &dsr.ReadTime,
Expand Down Expand Up @@ -252,6 +255,7 @@ extern "C" void* statistics_thread(void* arg)
PoolMem DevName(PM_NAME);
TapealertStatsDbRecord tsr;

memset(&tsr, 0, sizeof(tsr));
if (sscanf(sd->msg, TapeAlerts, &tsr.SampleTime, DevName.c_str(),
&tsr.AlertFlags) == 3) {
UnbashSpaces(DevName);
Expand All @@ -272,6 +276,7 @@ extern "C" void* statistics_thread(void* arg)
PoolMem DevName(PM_NAME);
JobStatisticsDbRecord jsr;

memset(&jsr, 0, sizeof(jsr));
if (sscanf(sd->msg, JobStats, &jsr.SampleTime, &jsr.JobId,
&jsr.JobFiles, &jsr.JobBytes, DevName.c_str()) == 5) {
UnbashSpaces(DevName);
Expand Down
3 changes: 2 additions & 1 deletion core/src/filed/restore.cc
Expand Up @@ -3,7 +3,7 @@
Copyright (C) 2000-2012 Free Software Foundation Europe e.V.
Copyright (C) 2011-2012 Planets Communications B.V.
Copyright (C) 2013-2019 Bareos GmbH & Co. KG
Copyright (C) 2013-2018 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 @@ -427,6 +427,7 @@ void DoRestore(JobControlRecord* jcr)
int non_support_crypto = 0;
int non_support_xattr = 0;

memset(&rctx, 0, sizeof(rctx));
rctx.jcr = jcr;

sd = jcr->store_bsock;
Expand Down
54 changes: 26 additions & 28 deletions core/src/filed/restore.h
@@ -1,7 +1,7 @@
/*
BAREOS® - Backup Archiving REcovery Open Sourced
Copyright (C) 2018-2019 Bareos GmbH & Co. KG
Copyright (C) 2018-2018 Bareos GmbH & Co. KG
Copyright (C) 2009 Free Software Foundation Europe e.V.
This program is Free Software; you can redistribute it and/or
Expand Down Expand Up @@ -39,39 +39,37 @@ struct RestoreCipherContext {
CIPHER_CONTEXT* cipher;
uint32_t block_size;

POOLMEM* buf; /* Pointer to description buffer */
POOLMEM* buf; /* Pointer to descryption buffer */
int32_t buf_len; /* Count of bytes currently in buf */
int32_t packet_len; /* Total bytes in packet */
};

struct r_ctx {
JobControlRecord* jcr{nullptr};
int32_t stream{0}; /* stream less new bits */
int32_t prev_stream{0}; /* previous stream */
int32_t full_stream{0}; /* full stream including new bits */
int32_t comp_stream{0}; /* last compressed stream found. Needed only to
restore encrypted compressed backup */
BareosWinFilePacket bfd; /* File content */
uint64_t fileAddr{0}; /* file write address */
uint32_t size{0}; /* Size of file */
char flags[FOPTS_BYTES]{}; /* Options for ExtractData() */
BareosWinFilePacket forkbfd; /* Alternative data stream */
uint64_t fork_addr{0}; /* Write address for alternative stream */
int64_t fork_size{0}; /* Size of alternate stream */
char fork_flags[FOPTS_BYTES]{}; /* Options for ExtractData() */
int32_t type{0}; /* file type FT_ */
Attributes* attr{nullptr}; /* Pointer to attributes */
bool extract{false}; /* set when extracting */
alist* delayed_streams; /* streams that should be restored as last */
JobControlRecord* jcr;
int32_t stream; /* stream less new bits */
int32_t prev_stream; /* previous stream */
int32_t full_stream; /* full stream including new bits */
int32_t comp_stream; /* last compressed stream found. needed only to restore
encrypted compressed backup */
BareosWinFilePacket bfd; /* File content */
uint64_t fileAddr; /* file write address */
uint32_t size; /* Size of file */
char flags[FOPTS_BYTES]; /* Options for ExtractData() */
BareosWinFilePacket forkbfd; /* Alternative data stream */
uint64_t fork_addr; /* Write address for alternative stream */
int64_t fork_size; /* Size of alternate stream */
char fork_flags[FOPTS_BYTES]; /* Options for ExtractData() */
int32_t type; /* file type FT_ */
Attributes* attr; /* Pointer to attributes */
bool extract; /* set when extracting */
alist* delayed_streams; /* streams that should be restored as last */

SIGNATURE* sig{nullptr}; /* Cryptographic signature (if any) for file */
CRYPTO_SESSION* cs{
nullptr}; /* Cryptographic session data (if any) for file */
RestoreCipherContext cipher_ctx{
nullptr}; /* Cryptographic restore context (if any) for file */
RestoreCipherContext fork_cipher_ctx{
nullptr}; /* Cryptographic restore context (if any) for alternative stream
*/
SIGNATURE* sig; /* Cryptographic signature (if any) for file */
CRYPTO_SESSION* cs; /* Cryptographic session data (if any) for file */
RestoreCipherContext
cipher_ctx; /* Cryptographic restore context (if any) for file */
RestoreCipherContext fork_cipher_ctx; /* Cryptographic restore context (if
any) for alternative stream */
};

void DoRestore(JobControlRecord* jcr);
Expand Down
5 changes: 2 additions & 3 deletions core/src/findlib/match.cc
Expand Up @@ -3,7 +3,7 @@
Copyright (C) 2000-2008 Free Software Foundation Europe e.V.
Copyright (C) 2011-2012 Planets Communications B.V.
Copyright (C) 2013-2019 Bareos GmbH & Co. KG
Copyright (C) 2013-2016 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 @@ -567,8 +567,7 @@ bool ParseSizeMatch(const char* size_match_pattern,
/*
* Empty the matching arguments.
*/
static const s_sz_matching empty_s_sz_matching{};
*size_matching = empty_s_sz_matching;
memset(size_matching, 0, sizeof(struct s_sz_matching));

/*
* See if the size is a range e.g. there is a - in the
Expand Down
60 changes: 30 additions & 30 deletions core/src/lib/tree.h
Expand Up @@ -2,7 +2,7 @@
BAREOS® - Backup Archiving REcovery Open Sourced
Copyright (C) 2002-2009 Free Software Foundation Europe e.V.
Copyright (C) 2016-2019 Bareos GmbH & Co. KG
Copyright (C) 2016-2016 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 @@ -72,23 +72,23 @@ struct s_tree_node {
* do initialization of child */
rblink sibling;
rblist child;
char* fname{nullptr}; /* file name */
int32_t FileIndex{0}; /* file index */
uint32_t JobId{0}; /* JobId */
int32_t delta_seq{0}; /* current delta sequence */
uint16_t fname_len{0}; /* filename length */
char* fname; /* file name */
int32_t FileIndex; /* file index */
uint32_t JobId; /* JobId */
int32_t delta_seq; /* current delta sequence */
uint16_t fname_len; /* filename length */
unsigned int type : 8; /* node type */
unsigned int extract : 1; /* extract item */
unsigned int extract_dir : 1; /* extract dir entry only */
unsigned int hard_link : 1; /* set if have hard link */
unsigned int soft_link : 1; /* set if is soft link */
unsigned int inserted : 1; /* set when node newly inserted */
unsigned int loaded : 1; /* set when the dir is in the tree */
struct s_tree_node* parent{nullptr};
struct s_tree_node* next{nullptr}; /* next hash of FileIndex */
struct delta_list* delta_list{nullptr}; /* delta parts for this node */
uint64_t fhinfo{0}; /* NDMP Fh_info */
uint64_t fhnode{0}; /* NDMP Fh_node */
struct s_tree_node* parent;
struct s_tree_node* next; /* next hash of FileIndex */
struct delta_list* delta_list; /* delta parts for this node */
uint64_t fhinfo; /* NDMP Fh_info */
uint64_t fhnode; /* NDMP Fh_node */
};
typedef struct s_tree_node TREE_NODE;

Expand All @@ -97,39 +97,39 @@ struct s_tree_root {
* do initialization of child */
rblink sibling;
rblist child;
const char* fname{nullptr}; /* file name */
int32_t FileIndex{0}; /* file index */
uint32_t JobId{0}; /* JobId */
int32_t delta_seq{0}; /* current delta sequence */
uint16_t fname_len{0}; /* filename length */
const char* fname; /* file name */
int32_t FileIndex; /* file index */
uint32_t JobId; /* JobId */
int32_t delta_seq; /* current delta sequence */
uint16_t fname_len; /* filename length */
unsigned int type : 8; /* node type */
unsigned int extract : 1; /* extract item */
unsigned int extract_dir : 1; /* extract dir entry only */
unsigned int have_link : 1; /* set if have hard link */
unsigned int inserted : 1; /* set when newly inserted */
unsigned int loaded : 1; /* set when the dir is in the tree */
struct s_tree_node* parent{nullptr};
struct s_tree_node* next{nullptr}; /* next hash of FileIndex */
struct delta_list* delta_list{nullptr}; /* delta parts for this node */
struct s_tree_node* parent;
struct s_tree_node* next; /* next hash of FileIndex */
struct delta_list* delta_list; /* delta parts for this node */

/* The above ^^^ must be identical to a TREE_NODE structure */
struct s_tree_node* first{nullptr}; /* first entry in the tree */
struct s_tree_node* last{nullptr}; /* last entry in tree */
struct s_mem* mem{nullptr}; /* tree memory */
uint32_t total_size{0}; /* total bytes allocated */
uint32_t blocks{0}; /* total mallocs */
int cached_path_len{0}; /* length of cached path */
char* cached_path{0}; /* cached current path */
TREE_NODE* cached_parent{nullptr}; /* cached parent for above path */
htable hardlinks; /* references to first occurence of hardlinks */
struct s_tree_node* first; /* first entry in the tree */
struct s_tree_node* last; /* last entry in tree */
struct s_mem* mem; /* tree memory */
uint32_t total_size; /* total bytes allocated */
uint32_t blocks; /* total mallocs */
int cached_path_len; /* length of cached path */
char* cached_path; /* cached current path */
TREE_NODE* cached_parent; /* cached parent for above path */
htable hardlinks; /* references to first occurence of hardlinks */
};
typedef struct s_tree_root TREE_ROOT;

/* hardlink hashtable entry */
struct s_hl_entry {
uint64_t key{0};
uint64_t key;
hlink link;
TREE_NODE* node{nullptr};
TREE_NODE* node;
};
typedef struct s_hl_entry HL_ENTRY;

Expand Down

0 comments on commit a312b81

Please sign in to comment.