Commit 94fd8405ea62bd2d4a40f3013e8e6935b6643235

Authored by David Howells
Committed by James Morris
1 parent 0849e3ba53

KEYS: Use the variable 'key' in keyctl_describe_key()

keyctl_describe_key() turns the key reference it gets into a usable key pointer
and assigns that to a variable called 'key', which it then ignores in favour of
recomputing the key pointer each time it needs it.  Make it use the precomputed
pointer instead.

Without this patch, gcc 4.6 reports that the variable key is set but not used:

	building with gcc 4.6 I'm getting a warning message:
	 CC      security/keys/keyctl.o
	security/keys/keyctl.c: In function 'keyctl_describe_key':
	security/keys/keyctl.c:472:14: warning: variable 'key' set but not used

Reported-by: Justin P. Mattock <justinmattock@gmail.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: James Morris <jmorris@namei.org>

Showing 1 changed file with 5 additions and 7 deletions Side-by-side Diff

security/keys/keyctl.c
... ... @@ -505,13 +505,11 @@
505 505  
506 506 ret = snprintf(tmpbuf, PAGE_SIZE - 1,
507 507 "%s;%d;%d;%08x;%s",
508   - key_ref_to_ptr(key_ref)->type->name,
509   - key_ref_to_ptr(key_ref)->uid,
510   - key_ref_to_ptr(key_ref)->gid,
511   - key_ref_to_ptr(key_ref)->perm,
512   - key_ref_to_ptr(key_ref)->description ?
513   - key_ref_to_ptr(key_ref)->description : ""
514   - );
  508 + key->type->name,
  509 + key->uid,
  510 + key->gid,
  511 + key->perm,
  512 + key->description ?: "");
515 513  
516 514 /* include a NUL char at the end of the data */
517 515 if (ret > PAGE_SIZE - 1)