keyutil.c: Only copy the shared parts of a parameters key.
authorMark Wooding <mdw@distorted.org.uk>
Sun, 22 Jan 2012 12:58:57 +0000 (12:58 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Sun, 22 Jan 2012 13:09:58 +0000 (13:09 +0000)
Reported by GCC warning that `kf' wasn't used for anything.  Use the new
function key_copydata to copy only the bits which really ought to be
copied.

This is unlikely to make much difference in practice since all
parameters keys we make have all of their components shared.

keyutil.c

index bae57cf..79cf2c2 100644 (file)
--- a/keyutil.c
+++ b/keyutil.c
@@ -235,8 +235,12 @@ static int copyparam(keyopts *k, const char **pp)
 {
   key_filter kf;
   key_attriter i;
+  key_data *kd;
   const char *n, *v;
 
+  kf.f = KCAT_SHARE;
+  kf.m = KF_CATMASK;
+
   /* --- Quick check if no parameters supplied --- */
 
   if (!k->p)
@@ -248,16 +252,17 @@ static int copyparam(keyopts *k, const char **pp)
     key_data *kd = key_structfind(k->p->k, *pp);
     if (!kd)
       die(EXIT_FAILURE, "bad parameter key: parameter `%s' not found", *pp);
-    if ((kd->e & KF_CATMASK) != KCAT_SHARE)
+    if (!KEY_MATCH(kd, &kf))
       die(EXIT_FAILURE, "bad parameter key: subkey `%s' is not shared", *pp);
     pp++;
   }
 
   /* --- Copy over the parameters --- */
 
-  kf.f = KCAT_SHARE;
-  kf.m = KF_CATMASK;
-  key_setkeydata(k->kf, k->k, k->p->k);
+  kd = key_copydata(k->p->k, &kf);
+  assert(kd);
+  key_setkeydata(k->kf, k->k, kd);
+  key_drop(kd);
 
   /* --- Copy over attributes --- */