[pacman-dev] [PATCH 1/2] Change if-else chain to switch
Allan McRae
allan at archlinux.org
Wed Sep 19 07:06:07 UTC 2018
On 19/9/18 12:28 pm, David Phillips wrote:
> ---
> lib/libalpm/sync.c | 14 ++++++++++----
> 1 file changed, 10 insertions(+), 4 deletions(-)
>
Both patches are fine. Note that case statements should be indented
one further than the switch statement. I have handed the adjustment.
A
> diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
> index 696a5131..699fb2fd 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) {
> + switch(v->error) {
> + case 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) {
> + 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);
> - } else if(v->error == 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);
>
More information about the pacman-dev
mailing list