aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/core/function/gpg/GpgKeyManager.cpp6
-rw-r--r--src/core/function/gpg/GpgKeyOpera.cpp6
-rw-r--r--src/core/function/gpg/GpgUIDOperator.cpp4
-rw-r--r--src/ui/dialog/import_export/ExportKeyPackageDialog.cpp5
-rw-r--r--src/ui/dialog/import_export/KeyUploadDialog.cpp5
-rw-r--r--src/ui/dialog/keypair_details/KeyUIDSignDialog.cpp5
-rw-r--r--src/ui/main_window/KeyMgmt.cpp10
-rw-r--r--src/ui/main_window/MainWindowFileSlotFunction.cpp32
-rw-r--r--src/ui/main_window/MainWindowGpgOperaFunction.cpp15
9 files changed, 42 insertions, 46 deletions
diff --git a/src/core/function/gpg/GpgKeyManager.cpp b/src/core/function/gpg/GpgKeyManager.cpp
index 630b2b0c..d0576e59 100644
--- a/src/core/function/gpg/GpgKeyManager.cpp
+++ b/src/core/function/gpg/GpgKeyManager.cpp
@@ -173,7 +173,8 @@ auto GpgKeyManager::SetOwnerTrustLevel(const GpgKey& key,
}
auto GpgKeyManager::DeleteSubkey(const GpgKey& key, int subkey_index) -> bool {
- if (subkey_index < 0 || subkey_index >= key.GetSubKeys()->size()) {
+ if (subkey_index < 0 ||
+ subkey_index >= static_cast<int>(key.GetSubKeys()->size())) {
LOG_W() << "illegal subkey index: " << subkey_index;
return false;
}
@@ -258,7 +259,8 @@ auto GpgKeyManager::DeleteSubkey(const GpgKey& key, int subkey_index) -> bool {
auto GpgKeyManager::RevokeSubkey(const GpgKey& key, int subkey_index,
int reason_code,
const QString& reason_text) -> bool {
- if (subkey_index < 0 || subkey_index >= key.GetSubKeys()->size()) {
+ if (subkey_index < 0 ||
+ subkey_index >= static_cast<int>(key.GetSubKeys()->size())) {
LOG_W() << "illegal subkey index: " << subkey_index;
return false;
}
diff --git a/src/core/function/gpg/GpgKeyOpera.cpp b/src/core/function/gpg/GpgKeyOpera.cpp
index 6898b355..a5346655 100644
--- a/src/core/function/gpg/GpgKeyOpera.cpp
+++ b/src/core/function/gpg/GpgKeyOpera.cpp
@@ -87,10 +87,12 @@ auto GpgKeyOpera::SetExpire(const GpgKey& key, const SubkeyId& subkey_fpr,
err =
gpgme_op_setexpire(ctx_.DefaultContext(), static_cast<gpgme_key_t>(key),
expires_time, nullptr, 0);
+ assert(gpg_err_code(err) == GPG_ERR_NO_ERROR);
} else {
err =
gpgme_op_setexpire(ctx_.DefaultContext(), static_cast<gpgme_key_t>(key),
expires_time, subkey_fpr.toUtf8(), 0);
+ assert(gpg_err_code(err) == GPG_ERR_NO_ERROR);
}
return err;
@@ -200,6 +202,7 @@ void GpgKeyOpera::GenerateKey(const std::shared_ptr<GenKeyInfo>& params,
err = gpgme_op_createkey(ctx.DefaultContext(), userid.toUtf8(),
algo.toUtf8(), 0, expires, nullptr, flags);
+ assert(gpg_err_code(err) == GPG_ERR_NO_ERROR);
if (CheckGpgError(err) == GPG_ERR_NO_ERROR) {
data_object->Swap({GpgGenerateKeyResult{
@@ -240,6 +243,7 @@ auto GpgKeyOpera::GenerateKeySync(const std::shared_ptr<GenKeyInfo>& params)
err = gpgme_op_createkey(ctx.DefaultContext(), userid.toUtf8(),
algo.toUtf8(), 0, expires, nullptr, flags);
+ assert(gpg_err_code(err) == GPG_ERR_NO_ERROR);
if (CheckGpgError(err) == GPG_ERR_NO_ERROR) {
data_object->Swap({GpgGenerateKeyResult{
@@ -360,6 +364,7 @@ void GpgKeyOpera::GenerateKeyWithSubkey(
err = gpgme_op_createkey(ctx.DefaultContext(), userid, algo, 0, expires,
nullptr, flags);
+ assert(gpg_err_code(err) == GPG_ERR_NO_ERROR);
if (CheckGpgError(err) != GPG_ERR_NO_ERROR) {
data_object->Swap({GpgGenerateKeyResult{}});
@@ -441,6 +446,7 @@ auto GpgKeyOpera::GenerateKeyWithSubkeySync(
err = gpgme_op_createkey(ctx.DefaultContext(), userid, algo, 0, expires,
nullptr, flags);
+ assert(gpg_err_code(err) == GPG_ERR_NO_ERROR);
if (CheckGpgError(err) != GPG_ERR_NO_ERROR) {
data_object->Swap({GpgGenerateKeyResult{}});
diff --git a/src/core/function/gpg/GpgUIDOperator.cpp b/src/core/function/gpg/GpgUIDOperator.cpp
index afcd3bae..3fc506f4 100644
--- a/src/core/function/gpg/GpgUIDOperator.cpp
+++ b/src/core/function/gpg/GpgUIDOperator.cpp
@@ -59,7 +59,7 @@ auto GpgUIDOperator::AddUID(const GpgKey& key, const QString& name,
}
auto GpgUIDOperator::DeleteUID(const GpgKey& key, int uid_index) -> bool {
- if (uid_index < 2 || uid_index > key.GetUIDs()->size()) {
+ if (uid_index < 2 || uid_index > static_cast<int>(key.GetUIDs()->size())) {
LOG_W() << "illegal uid_index index: " << uid_index;
return false;
}
@@ -144,7 +144,7 @@ auto GpgUIDOperator::DeleteUID(const GpgKey& key, int uid_index) -> bool {
auto GpgUIDOperator::RevokeUID(const GpgKey& key, int uid_index,
int reason_code,
const QString& reason_text) -> bool {
- if (uid_index < 2 || uid_index > key.GetUIDs()->size()) {
+ if (uid_index < 2 || uid_index > static_cast<int>(key.GetUIDs()->size())) {
LOG_W() << "illegal uid index: " << uid_index;
return false;
}
diff --git a/src/ui/dialog/import_export/ExportKeyPackageDialog.cpp b/src/ui/dialog/import_export/ExportKeyPackageDialog.cpp
index 8c283f66..762c79b7 100644
--- a/src/ui/dialog/import_export/ExportKeyPackageDialog.cpp
+++ b/src/ui/dialog/import_export/ExportKeyPackageDialog.cpp
@@ -98,9 +98,8 @@ GpgFrontend::UI::ExportKeyPackageDialog::ExportKeyPackageDialog(
// get suitable key ids
auto keys = GpgKeyGetter::GetInstance(current_gpg_context_channel_)
.GetKeys(key_ids_);
- for (const auto& key : *keys) {
- assert(key.IsGood());
- }
+ assert(std::all_of(keys->begin(), keys->end(),
+ [](const auto& key) { return key.IsGood(); }));
auto keys_new_end =
std::remove_if(keys->begin(), keys->end(), [this](const auto& key) {
diff --git a/src/ui/dialog/import_export/KeyUploadDialog.cpp b/src/ui/dialog/import_export/KeyUploadDialog.cpp
index 0f1d1e20..9a02ea0e 100644
--- a/src/ui/dialog/import_export/KeyUploadDialog.cpp
+++ b/src/ui/dialog/import_export/KeyUploadDialog.cpp
@@ -47,9 +47,8 @@ KeyUploadDialog::KeyUploadDialog(int channel, const KeyIdArgsListPtr& keys_ids,
current_gpg_context_channel_(channel),
m_keys_(GpgKeyGetter::GetInstance(current_gpg_context_channel_)
.GetKeys(keys_ids)) {
- for (const auto& key : *m_keys_) {
- assert(key.IsGood());
- }
+ assert(std::all_of(m_keys_->begin(), m_keys_->end(),
+ [](const auto& key) { return key.IsGood(); }));
auto* pb = new QProgressBar();
pb->setRange(0, 0);
diff --git a/src/ui/dialog/keypair_details/KeyUIDSignDialog.cpp b/src/ui/dialog/keypair_details/KeyUIDSignDialog.cpp
index 1c99539b..e079e683 100644
--- a/src/ui/dialog/keypair_details/KeyUIDSignDialog.cpp
+++ b/src/ui/dialog/keypair_details/KeyUIDSignDialog.cpp
@@ -108,9 +108,8 @@ void KeyUIDSignDialog::slot_sign_key(bool clicked) {
auto key_ids = m_key_list_->GetChecked();
auto keys =
GpgKeyGetter::GetInstance(current_gpg_context_channel_).GetKeys(key_ids);
- for (const auto& key : *keys) {
- assert(key.IsGood());
- }
+ assert(std::all_of(keys->begin(), keys->end(),
+ [](const auto& key) { return key.IsGood(); }));
auto expires = std::make_unique<QDateTime>(expires_edit_->dateTime());
diff --git a/src/ui/main_window/KeyMgmt.cpp b/src/ui/main_window/KeyMgmt.cpp
index 150017a1..d6530c64 100644
--- a/src/ui/main_window/KeyMgmt.cpp
+++ b/src/ui/main_window/KeyMgmt.cpp
@@ -413,9 +413,8 @@ void KeyMgmt::SlotExportKeyToClipboard() {
auto keys =
GpgKeyGetter::GetInstance(key_list_->GetCurrentGpgContextChannel())
.GetKeys(keys_checked);
- for (const auto& key : *keys) {
- assert(key.IsGood());
- }
+ assert(std::all_of(keys->begin(), keys->end(),
+ [](const auto& key) { return key.IsGood(); }));
CommonUtils::WaitForOpera(
this, tr("Exporting"), [=](const OperaWaitingHd& op_hd) {
@@ -504,9 +503,8 @@ void KeyMgmt::SlotExportAsOpenSSHFormat() {
auto keys =
GpgKeyGetter::GetInstance(key_list_->GetCurrentGpgContextChannel())
.GetKeys(keys_checked);
- for (const auto& key : *keys) {
- assert(key.IsGood());
- }
+ assert(std::all_of(keys->begin(), keys->end(),
+ [](const auto& key) { return key.IsGood(); }));
CommonUtils::WaitForOpera(
this, tr("Exporting"), [this, keys](const OperaWaitingHd& op_hd) {
diff --git a/src/ui/main_window/MainWindowFileSlotFunction.cpp b/src/ui/main_window/MainWindowFileSlotFunction.cpp
index b94da713..184635a7 100644
--- a/src/ui/main_window/MainWindowFileSlotFunction.cpp
+++ b/src/ui/main_window/MainWindowFileSlotFunction.cpp
@@ -122,9 +122,8 @@ void MainWindow::SlotFileEncrypt(const QString& path) {
auto p_keys =
GpgKeyGetter::GetInstance(m_key_list_->GetCurrentGpgContextChannel())
.GetKeys(key_ids);
- for (const auto& key : *p_keys) {
- assert(key.IsGood());
- }
+ assert(std::all_of(p_keys->begin(), p_keys->end(),
+ [](const auto& key) { return key.IsGood(); }));
// check key abilities
for (const auto& key : *p_keys) {
@@ -248,9 +247,8 @@ void MainWindow::SlotDirectoryEncrypt(const QString& path) {
auto p_keys =
GpgKeyGetter::GetInstance(m_key_list_->GetCurrentGpgContextChannel())
.GetKeys(key_ids);
- for (const auto& key : *p_keys) {
- assert(key.IsGood());
- }
+ assert(std::all_of(p_keys->begin(), p_keys->end(),
+ [](const auto& key) { return key.IsGood(); }));
// check key abilities
for (const auto& key : *p_keys) {
@@ -415,9 +413,8 @@ void MainWindow::SlotFileSign(const QString& path) {
auto keys =
GpgKeyGetter::GetInstance(m_key_list_->GetCurrentGpgContextChannel())
.GetKeys(key_ids);
- for (const auto& key : *keys) {
- assert(key.IsGood());
- }
+ assert(std::all_of(keys->begin(), keys->end(),
+ [](const auto& key) { return key.IsGood(); }));
if (keys->empty()) {
QMessageBox::critical(
@@ -578,9 +575,8 @@ void MainWindow::SlotFileEncryptSign(const QString& path) {
auto p_keys =
GpgKeyGetter::GetInstance(m_key_list_->GetCurrentGpgContextChannel())
.GetKeys(key_ids);
- for (const auto& key : *p_keys) {
- assert(key.IsGood());
- }
+ assert(std::all_of(p_keys->begin(), p_keys->end(),
+ [](const auto& key) { return key.IsGood(); }));
if (p_keys->empty()) {
QMessageBox::critical(
@@ -640,9 +636,8 @@ void MainWindow::SlotFileEncryptSign(const QString& path) {
auto p_signer_keys =
GpgKeyGetter::GetInstance(m_key_list_->GetCurrentGpgContextChannel())
.GetKeys(signer_key_ids);
- for (const auto& key : *p_signer_keys) {
- assert(key.IsGood());
- }
+ assert(std::all_of(p_signer_keys->begin(), p_signer_keys->end(),
+ [](const auto& key) { return key.IsGood(); }));
CommonUtils::WaitForOpera(
this, tr("Encrypting and Signing"), [=](const OperaWaitingHd& op_hd) {
@@ -697,9 +692,8 @@ void MainWindow::SlotDirectoryEncryptSign(const QString& path) {
auto p_keys =
GpgKeyGetter::GetInstance(m_key_list_->GetCurrentGpgContextChannel())
.GetKeys(key_ids);
- for (const auto& key : *p_keys) {
- assert(key.IsGood());
- }
+ assert(std::all_of(p_keys->begin(), p_keys->end(),
+ [](const auto& key) { return key.IsGood(); }));
if (p_keys->empty()) {
QMessageBox::critical(
@@ -759,9 +753,11 @@ void MainWindow::SlotDirectoryEncryptSign(const QString& path) {
auto p_signer_keys =
GpgKeyGetter::GetInstance(m_key_list_->GetCurrentGpgContextChannel())
.GetKeys(signer_key_ids);
+#ifndef NDEBUG
for (const auto& key : *p_signer_keys) {
assert(key.IsGood());
}
+#endif
CommonUtils::WaitForOpera(
this, tr("Archiving & Encrypting & Signing"),
diff --git a/src/ui/main_window/MainWindowGpgOperaFunction.cpp b/src/ui/main_window/MainWindowGpgOperaFunction.cpp
index 776801e5..a9a65797 100644
--- a/src/ui/main_window/MainWindowGpgOperaFunction.cpp
+++ b/src/ui/main_window/MainWindowGpgOperaFunction.cpp
@@ -102,9 +102,8 @@ void MainWindow::SlotEncrypt() {
auto keys =
GpgKeyGetter::GetInstance(m_key_list_->GetCurrentGpgContextChannel())
.GetKeys(key_ids);
- for (const auto& key : *keys) {
- assert(key.IsGood());
- }
+ assert(std::all_of(keys->begin(), keys->end(),
+ [](const auto& key) { return key.IsGood(); }));
for (const auto& key : *keys) {
if (!key.IsHasActualEncryptionCapability()) {
@@ -168,9 +167,8 @@ void MainWindow::SlotSign() {
auto keys =
GpgKeyGetter::GetInstance(m_key_list_->GetCurrentGpgContextChannel())
.GetKeys(key_ids);
- for (const auto& key : *keys) {
- assert(key.IsGood());
- }
+ assert(std::all_of(keys->begin(), keys->end(),
+ [](const auto& key) { return key.IsGood(); }));
for (const auto& key : *keys) {
if (!key.IsHasActualSigningCapability()) {
@@ -384,9 +382,8 @@ void MainWindow::SlotEncryptSign() {
auto keys =
GpgKeyGetter::GetInstance(m_key_list_->GetCurrentGpgContextChannel())
.GetKeys(key_ids);
- for (const auto& key : *keys) {
- assert(key.IsGood());
- }
+ assert(std::all_of(keys->begin(), keys->end(),
+ [](const auto& key) { return key.IsGood(); }));
for (const auto& key : *keys) {
bool key_can_encrypt = key.IsHasActualEncryptionCapability();