Skip to content

Commit

Permalink
ask_dir.cc: fix class-memaccess warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
pstorz authored and franku committed Nov 5, 2019
1 parent dc958a9 commit e0a2d1c
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 59 deletions.
5 changes: 3 additions & 2 deletions core/src/stored/askdir.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-2016 Bareos GmbH & Co. KG
Copyright (C) 2013-2019 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 @@ -103,7 +103,8 @@ static bool DoGetVolumeInfo(DeviceControlRecord* dcr)
Mmsg(jcr->errmsg, _("Network error on BnetRecv in req_vol_info.\n"));
return false;
}
memset(&vol, 0, sizeof(vol));
static const VolumeCatalogInfo emptyVolumeCatalogInfo{};
vol = emptyVolumeCatalogInfo;
Dmsg1(debuglevel, "<dird %s", dir->msg);
n = sscanf(dir->msg, OK_media, vol.VolCatName, &vol.VolCatJobs,
&vol.VolCatFiles, &vol.VolCatBlocks, &vol.VolCatBytes,
Expand Down
80 changes: 40 additions & 40 deletions core/src/stored/dev.h
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-2018 Bareos GmbH & Co. KG
Copyright (C) 2013-2019 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 @@ -232,43 +232,43 @@ struct VolumeCatalogInfo {
/*
* Media info for the current Volume
*/
uint32_t VolCatJobs = 0; /**< number of jobs on this Volume */
uint32_t VolCatFiles = 0; /**< Number of files */
uint32_t VolCatBlocks = 0; /**< Number of blocks */
uint64_t VolCatBytes = 0; /**< Number of bytes written */
uint32_t VolCatMounts = 0; /**< Number of mounts this volume */
uint32_t VolCatErrors = 0; /**< Number of errors this volume */
uint32_t VolCatWrites = 0; /**< Number of writes this volume */
uint32_t VolCatReads = 0; /**< Number of reads this volume */
uint64_t VolCatRBytes = 0; /**< Number of bytes read */
uint32_t VolCatRecycles = 0; /**< Number of recycles this volume */
uint32_t EndFile = 0; /**< Last file number */
uint32_t EndBlock = 0; /**< Last block number */
int32_t LabelType = 0; /**< Bareos/ANSI/IBM */
int32_t Slot = 0; /**< >0=Slot loaded, 0=nothing, -1=unknown */
uint32_t VolCatMaxJobs = 0; /**< Maximum Jobs to write to volume */
uint32_t VolCatMaxFiles = 0; /**< Maximum files to write to volume */
uint64_t VolCatMaxBytes = 0; /**< Max bytes to write to volume */
uint64_t VolCatCapacityBytes = 0; /**< capacity estimate */
btime_t VolReadTime = 0; /**< time spent reading */
btime_t VolWriteTime = 0; /**< time spent writing this Volume */
int64_t VolMediaId = 0; /**< MediaId */
utime_t VolFirstWritten = 0; /**< Time of first write */
utime_t VolLastWritten = 0; /**< Time of last write */
bool InChanger = false; /**< Set if vol in current magazine */
bool is_valid = false; /**< set if this data is valid */
char VolCatStatus[20]{0}; /**< Volume status */
uint32_t VolCatJobs{0}; /**< number of jobs on this Volume */
uint32_t VolCatFiles{0}; /**< Number of files */
uint32_t VolCatBlocks{0}; /**< Number of blocks */
uint64_t VolCatBytes{0}; /**< Number of bytes written */
uint32_t VolCatMounts{0}; /**< Number of mounts this volume */
uint32_t VolCatErrors{0}; /**< Number of errors this volume */
uint32_t VolCatWrites{0}; /**< Number of writes this volume */
uint32_t VolCatReads{0}; /**< Number of reads this volume */
uint64_t VolCatRBytes{0}; /**< Number of bytes read */
uint32_t VolCatRecycles{0}; /**< Number of recycles this volume */
uint32_t EndFile{0}; /**< Last file number */
uint32_t EndBlock{0}; /**< Last block number */
int32_t LabelType{0}; /**< Bareos/ANSI/IBM */
int32_t Slot{0}; /**< >0=Slot loaded, 0=nothing, -1=unknown */
uint32_t VolCatMaxJobs{0}; /**< Maximum Jobs to write to volume */
uint32_t VolCatMaxFiles{0}; /**< Maximum files to write to volume */
uint64_t VolCatMaxBytes{0}; /**< Max bytes to write to volume */
uint64_t VolCatCapacityBytes{0}; /**< capacity estimate */
btime_t VolReadTime{0}; /**< time spent reading */
btime_t VolWriteTime{0}; /**< time spent writing this Volume */
int64_t VolMediaId{0}; /**< MediaId */
utime_t VolFirstWritten{0}; /**< Time of first write */
utime_t VolLastWritten{0}; /**< Time of last write */
bool InChanger{false}; /**< Set if vol in current magazine */
bool is_valid{false}; /**< set if this data is valid */
char VolCatStatus[20]{0}; /**< Volume status */
char VolCatName[MAX_NAME_LENGTH]{0}; /**< Desired volume to mount */
char VolEncrKey[MAX_NAME_LENGTH]{
0}; /**< Encryption Key needed to read the media
*/
uint32_t VolMinBlocksize = 0; /**< Volume Minimum Blocksize */
uint32_t VolMaxBlocksize = 0; /**< Volume Maximum Blocksize */
0}; /**< Encryption Key needed to read the media
*/
uint32_t VolMinBlocksize{0}; /**< Volume Minimum Blocksize */
uint32_t VolMaxBlocksize{0}; /**< Volume Maximum Blocksize */
};

struct BlockSizes {
uint32_t max_block_size = 0;
uint32_t min_block_size = 0;
uint32_t max_block_size{0};
uint32_t min_block_size{0};
};

class DeviceResource; /* Forward reference Device resource defined in
Expand Down Expand Up @@ -296,13 +296,13 @@ class Device {
protected:
int fd_ = -1; /**< File descriptor */
private:
int blocked_ = 0; /**< Set if we must wait (i.e. change tape) */
int count_ = 0; /**< Mutex use count -- DEBUG only */
int num_reserved_ = 0; /**< Counter of device reservations */
slot_number_t slot_ = 0; /**< Slot loaded in drive or -1 if none */
pthread_t pid_ = 0; /**< Thread that locked -- DEBUG only */
bool unload_ = false; /**< Set when Volume must be unloaded */
bool load_ = false; /**< Set when Volume must be loaded */
int blocked_{0}; /**< Set if we must wait (i.e. change tape) */
int count_{0}; /**< Mutex use count -- DEBUG only */
int num_reserved_{0}; /**< Counter of device reservations */
slot_number_t slot_{0}; /**< Slot loaded in drive or -1 if none */
pthread_t pid_{0}; /**< Thread that locked -- DEBUG only */
bool unload_{false}; /**< Set when Volume must be unloaded */
bool load_{false}; /**< Set when Volume must be loaded */

public:
Device() = default;
Expand Down
15 changes: 8 additions & 7 deletions core/src/stored/vol_mgr.cc
Expand Up @@ -2,7 +2,7 @@
BAREOS® - Backup Archiving REcovery Open Sourced
Copyright (C) 2000-2013 Free Software Foundation Europe e.V.
Copyright (C) 2015-2016 Bareos GmbH & Co. KG
Copyright (C) 2015-2019 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 @@ -37,6 +37,9 @@

namespace storagedaemon {

static const VolumeReservationItem emptyVol{};


const int debuglevel = 150;

static brwlock_t vol_list_lock;
Expand Down Expand Up @@ -190,8 +193,7 @@ void RemoveReadVolume(JobControlRecord* jcr, const char* VolumeName)
VolumeReservationItem vol, *fvol;

LockReadVolumes();

memset(&vol, 0, sizeof(vol));
vol = emptyVol;
vol.vol_name = strdup(VolumeName);
vol.SetJobid(jcr->JobId);

Expand Down Expand Up @@ -230,8 +232,7 @@ static VolumeReservationItem* find_read_volume(const char* VolumeName)
* Do not lock reservations here
*/
LockReadVolumes();

memset(&vol, 0, sizeof(vol));
vol = emptyVol;
vol.vol_name = strdup(VolumeName);

/*
Expand Down Expand Up @@ -285,7 +286,7 @@ static VolumeReservationItem* new_vol_item(DeviceControlRecord* dcr,
VolumeReservationItem* vol;

vol = (VolumeReservationItem*)malloc(sizeof(VolumeReservationItem));
memset(vol, 0, sizeof(VolumeReservationItem));
*vol = emptyVol;
vol->vol_name = strdup(VolumeName);
if (dcr) {
vol->dev = dcr->dev;
Expand Down Expand Up @@ -529,7 +530,7 @@ VolumeReservationItem* reserve_volume(DeviceControlRecord* dcr,
dcr->SetDev(vol->dev); /* temp point to other dev */
slot = GetAutochangerLoadedSlot(dcr); /* get slot on other drive */
dcr->SetDev(dev); /* restore dev */
vol->SetSlotNumber(slot); /* save slot */
vol->SetSlotNumber(slot); /* save slot */
vol->dev->SetUnload(); /* unload the other drive */
vol->SetSwapping(); /* swap from other drive */
dev->swap_dev = vol->dev; /* remember to get this vol */
Expand Down
20 changes: 10 additions & 10 deletions core/src/stored/vol_mgr.h
Expand Up @@ -2,7 +2,7 @@
BAREOS® - Backup Archiving REcovery Open Sourced
Copyright (C) 2000-2013 Free Software Foundation Europe e.V.
Copyright (C) 2013-2018 Bareos GmbH & Co. KG
Copyright (C) 2013-2019 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 @@ -62,17 +62,17 @@ void ReadVolWalkEnd(VolumeReservationItem* vol);
* Volume reservation class -- see vol_mgr.c and reserve.c
*/
class VolumeReservationItem {
bool swapping_; /**< set when swapping to another drive */
bool in_use_; /**< set when volume reserved or in use */
bool reading_; /**< set when reading */
slot_number_t slot_; /**< slot of swapping volume */
uint32_t JobId_; /**< JobId for read volumes */
volatile int32_t use_count_; /**< Use count */
pthread_mutex_t mutex_; /**< Vol muntex */
bool swapping_{false}; /**< set when swapping to another drive */
bool in_use_{false}; /**< set when volume reserved or in use */
bool reading_{false}; /**< set when reading */
slot_number_t slot_{0}; /**< slot of swapping volume */
uint32_t JobId_{0}; /**< JobId for read volumes */
volatile int32_t use_count_{0}; /**< Use count */
pthread_mutex_t mutex_; /**< Vol muntex */
public:
dlink link;
char* vol_name; /**< Volume name */
Device* dev; /**< Pointer to device to which we are attached */
char* vol_name{nullptr}; /**< Volume name */
Device* dev{nullptr}; /**< Pointer to device to which we are attached */

void InitMutex() { pthread_mutex_init(&mutex_, NULL); }
void DestroyMutex() { pthread_mutex_destroy(&mutex_); }
Expand Down

0 comments on commit e0a2d1c

Please sign in to comment.