chiark / gitweb /
progs/key.c: Let `copyparam' worry about the parameter key's type.
authorMark Wooding <mdw@distorted.org.uk>
Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sat, 22 Apr 2017 19:17:05 +0000 (20:17 +0100)
progs/key.c

index 597b93a7b16ab62a8fcfc9ab6553171c49cabfa5..74215d41cf9afd268f2b64fea2fce5e8a07f7a53 100644 (file)
@@ -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 --- */