diff options
author | Richard Kettlewell <rjk@greenend.org.uk> | 2020-06-07 17:48:41 +0100 |
---|---|---|
committer | Richard Kettlewell <rjk@greenend.org.uk> | 2020-06-07 17:48:41 +0100 |
commit | b965776429088c62f09a50388f878d490f92c5af (patch) | |
tree | f2bf4885e2cf2148f57e65b738424a2235961f74 | |
parent | 0d79e469ca9767765a8b55dfb35f3c9aeba4ff9e (diff) |
Trivial coverity fixes
-rw-r--r-- | src/Action.cc | 2 | ||||
-rw-r--r-- | src/MakeBackup.cc | 36 | ||||
-rw-r--r-- | src/RetireVolumes.cc | 2 |
3 files changed, 28 insertions, 12 deletions
diff --git a/src/Action.cc b/src/Action.cc index d47ea02..afd7a7d 100644 --- a/src/Action.cc +++ b/src/Action.cc @@ -113,7 +113,7 @@ void ActionList::cleanup(Action *a, bool succeeded, bool ran) { if(it != actions.end()) { assert(a == it->second); if(ran) { - assert(a->state = Action::Running); + assert(a->state == Action::Running); for(std::string &r: a->resources) resources.erase(r); a->state = succeeded ? Action::Succeeded : Action::Failed; diff --git a/src/MakeBackup.cc b/src/MakeBackup.cc index 321a9ee..d29268c 100644 --- a/src/MakeBackup.cc +++ b/src/MakeBackup.cc @@ -435,8 +435,14 @@ static void logBackup(Backup *outcome, Device *device, const char *what) { // Backup VOLUME onto DEVICE. // // device->store is assumed to be set. -static void backupVolume(Volume *volume, const std::string &sourcePath, - Device *device) { +// +// The group lock is assumed to be held on entry, and stays held. +// The global lock is assumed to be held on entry. From time to +// time it will be transiently released while waiting for resource +// availability or (further down the call tree) during command execution. +// The device lock is assumed to be held on entry, and stays held. +static void backupVolumeToDevice(Volume *volume, const std::string &sourcePath, + Device *device) { Host *host = volume->parent; if(globalWarningMask & WARNING_VERBOSE) IO::out.writef("INFO: backup %s:%s to %s\n", host->name.c_str(), @@ -447,9 +453,14 @@ static void backupVolume(Volume *volume, const std::string &sourcePath, // Backup VOLUME onto DEVICE, if possible. // -// The device lock is held. -static void maybeBackupVolume(Volume *volume, const std::string &sourcePath, - Device *device) { +// The group lock is assumed to be held on entry, and stays held. +// The global lock is assumed to be held on entry. From time to +// time it will be transiently released while waiting for resource +// availability or (further down the call tree) during command execution. +// The device lock is assumed to be held on entry, and stays held. +static void maybeBackupVolumeToDevice(Volume *volume, + const std::string &sourcePath, + Device *device) { Host *host = volume->parent; char buffer[1024]; BackupRequirement br = volume->needsBackup(device); @@ -464,7 +475,7 @@ static void maybeBackupVolume(Volume *volume, const std::string &sourcePath, case BackupRequired: globalConfig.identifyDevices(Store::Enabled); if(device->store && device->store->state == Store::Enabled) - backupVolume(volume, sourcePath, device); + backupVolumeToDevice(volume, sourcePath, device); else if(globalWarningMask & WARNING_STORE) { globalConfig.identifyDevices(Store::Disabled); if(device->store) @@ -508,8 +519,13 @@ static void maybeBackupVolume(Volume *volume, const std::string &sourcePath, } } -// Backup VOLUME -static void backupVolume(Volume *volume) { +// Backup VOLUME on all devices. +// +// The group lock is assumed to be held on entry, and stays held. +// The global lock is assumed to be held on entry. From time to +// time it will be transiently released while waiting for resource +// availability or (further down the call tree) during command execution. +static void backupVolumeToAllDevices(Volume *volume) { Host *host = volume->parent; // Build a list of devices std::set<Device *> devices; @@ -552,7 +568,7 @@ static void backupVolume(Volume *volume) { } ran_pre_volume_hook = true; } - maybeBackupVolume(volume, sourcePath, device); + maybeBackupVolumeToDevice(volume, sourcePath, device); attempted_backups = true; devices.erase(device); worked = true; @@ -591,7 +607,7 @@ static void backupHost(Host *host, std::mutex *lock) { for(auto &v: host->volumes) { Volume *volume = v.second; if(volume->selected()) - backupVolume(volume); + backupVolumeToAllDevices(volume); } } diff --git a/src/RetireVolumes.cc b/src/RetireVolumes.cc index eee2731..c42352f 100644 --- a/src/RetireVolumes.cc +++ b/src/RetireVolumes.cc @@ -97,7 +97,7 @@ struct Retirable { // Remove incomplete indicator std::string incompletePath = backupPath + ".incomplete"; if(unlink(incompletePath.c_str()) < 0 && errno != ENOENT) { - error("removing %s", incompletePath.c_str(), strerror(errno)); + error("removing %s: %s", incompletePath.c_str(), strerror(errno)); return; } forget(); |