Skip to content

Commit

Permalink
KEYS: Use the variable 'key' in keyctl_describe_key()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
David Howells authored and James Morris committed Aug 2, 2010
1 parent 0849e3b commit 94fd840
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions security/keys/keyctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -505,13 +505,11 @@ long keyctl_describe_key(key_serial_t keyid,

ret = snprintf(tmpbuf, PAGE_SIZE - 1,
"%s;%d;%d;%08x;%s",
key_ref_to_ptr(key_ref)->type->name,
key_ref_to_ptr(key_ref)->uid,
key_ref_to_ptr(key_ref)->gid,
key_ref_to_ptr(key_ref)->perm,
key_ref_to_ptr(key_ref)->description ?
key_ref_to_ptr(key_ref)->description : ""
);
key->type->name,
key->uid,
key->gid,
key->perm,
key->description ?: "");

/* include a NUL char at the end of the data */
if (ret > PAGE_SIZE - 1)
Expand Down

0 comments on commit 94fd840

Please sign in to comment.