From b54b33d816cdc3d1aab3b80f4eb94c5bad56c889 Mon Sep 17 00:00:00 2001 From: David Phillips Date: Wed, 19 Sep 2018 14:28:35 +1200 Subject: Change if-else chain to switch Signed-off-by: Allan McRae --- lib/libalpm/sync.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'lib') diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index 696a5131..65a853dc 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -1176,17 +1176,23 @@ static int check_validity(alpm_handle_t *handle, if(errors) { for(i = errors; i; i = i->next) { struct validity *v = i->data; - if(v->error == ALPM_ERR_PKG_MISSING_SIG) { - _alpm_log(handle, ALPM_LOG_ERROR, - _("%s: missing required signature\n"), v->pkg->name); - } else if(v->error == ALPM_ERR_PKG_INVALID_SIG) { - _alpm_process_siglist(handle, v->pkg->name, v->siglist, - v->siglevel & ALPM_SIG_PACKAGE_OPTIONAL, - v->siglevel & ALPM_SIG_PACKAGE_MARGINAL_OK, - v->siglevel & ALPM_SIG_PACKAGE_UNKNOWN_OK); - prompt_to_delete(handle, v->path, v->error); - } else if(v->error == ALPM_ERR_PKG_INVALID_CHECKSUM) { - prompt_to_delete(handle, v->path, v->error); + switch(v->error) { + case ALPM_ERR_PKG_MISSING_SIG: + _alpm_log(handle, ALPM_LOG_ERROR, + _("%s: missing required signature\n"), v->pkg->name); + break; + case ALPM_ERR_PKG_INVALID_SIG: + _alpm_process_siglist(handle, v->pkg->name, v->siglist, + v->siglevel & ALPM_SIG_PACKAGE_OPTIONAL, + v->siglevel & ALPM_SIG_PACKAGE_MARGINAL_OK, + v->siglevel & ALPM_SIG_PACKAGE_UNKNOWN_OK); + /* fallthrough */ + case ALPM_ERR_PKG_INVALID_CHECKSUM: + prompt_to_delete(handle, v->path, v->error); + break; + default: + /* ignore */ + break; } alpm_siglist_cleanup(v->siglist); free(v->siglist); -- cgit v1.2.3-70-g09d2