From 131babe48094a94d217d1d8fbbb2fdf4e7e2c6e7 Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Thu, 26 May 2016 09:26:09 +0100 Subject: [PATCH] progs/key.c: Let `copyparam' worry about the parameter key's type. --- progs/key.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/progs/key.c b/progs/key.c index 597b93a7..74215d41 100644 --- a/progs/key.c +++ b/progs/key.c @@ -255,6 +255,8 @@ static int copyparam(keyopts *k, const char **pp) /* --- Run through the checklist --- */ key_fulltag(k->p, &t); + if ((k->p->k->e & KF_ENCMASK) != KENC_STRUCT) + die(EXIT_FAILURE, "parameter key `%s' is not structured", t.buf); while (*pp) { key_data *kd = key_structfind(k->p->k, *pp); if (!kd) { @@ -1246,12 +1248,8 @@ static int cmd_add(int argc, char *argv[]) /* --- Find the parameter key --- */ - if (ptag) { - if ((k.p = key_bytag(&f, ptag)) == 0) - die(EXIT_FAILURE, "parameter key `%s' not found", ptag); - if ((k.p->k->e & KF_ENCMASK) != KENC_STRUCT) - die(EXIT_FAILURE, "parameter key `%s' is not structured", ptag); - } + if (ptag && (k.p = key_bytag(&f, ptag)) == 0) + die(EXIT_FAILURE, "parameter key `%s' not found", ptag); /* --- Now generate the actual key data --- */ -- 2.11.0