From 50615f5da315255bc30fee184f981a1c65bd386b Mon Sep 17 00:00:00 2001 From: Florian Festi Date: Thu, 24 Oct 2024 11:40:24 +0200 Subject: [PATCH] Simplify rpmKeyringModify(RPMKEYRING_REPLACE) Implement as RPMKEYRING_DELETE + RPMKEYRING_ADD. This will make it easier to handle the subkeys at the same time in the next commit. Related: 3350 --- rpmio/rpmkeyring.cc | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/rpmio/rpmkeyring.cc b/rpmio/rpmkeyring.cc index 72d0c3b285..fcf9fe3218 100644 --- a/rpmio/rpmkeyring.cc +++ b/rpmio/rpmkeyring.cc @@ -133,15 +133,11 @@ int rpmKeyringModify(rpmKeyring keyring, rpmPubkey key, rpmKeyringModifyMode mod if (item->second->fp == key->fp) break; } - if (item != range.second && mode == RPMKEYRING_DELETE) { + if (item != range.second && (mode == RPMKEYRING_DELETE || mode == RPMKEYRING_REPLACE)) { rpmPubkeyFree(item->second); keyring->keys.erase(item); rc = 0; - } else if (item != range.second && mode == RPMKEYRING_REPLACE) { - rpmPubkeyFree(item->second); - item->second = rpmPubkeyLink(key); - rc = 0; - } else if (item == range.second && (mode == RPMKEYRING_ADD || mode == RPMKEYRING_REPLACE) ) { + } else if ((item == range.second && mode == RPMKEYRING_ADD) || mode == RPMKEYRING_REPLACE) { keyring->keys.insert({key->keyid, rpmPubkeyLink(key)}); rc = 0; }