From: Mark Wooding Date: Sun, 22 Jan 2012 12:58:57 +0000 (+0000) Subject: keyutil.c: Only copy the shared parts of a parameters key. X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/commitdiff_plain/9eef0c14b1b57daf12c8724df26f665087c1b01a keyutil.c: Only copy the shared parts of a parameters key. 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. --- diff --git a/keyutil.c b/keyutil.c index bae57cf..79cf2c2 100644 --- 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 --- */