[PATCH] KEYS: Use the variable 'key' in keyctl_describe_key()

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: David Howells
Date: Monday, June 28, 2010 - 6:05 am

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>
---

 security/keys/keyctl.c |   12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
index 639226a..b2b0998 100644
--- a/security/keys/keyctl.c
+++ b/security/keys/keyctl.c
@@ -505,13 +505,11 @@ okay:
 
 	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)

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 0/5] Fix gcc 4.6.0 set but unused variable warnings , Justin P. Mattock, (Sat Jun 26, 11:47 pm)
[PATCH 1/5]security:key.c Fix warning: variable 'key' set ..., Justin P. Mattock, (Sat Jun 26, 11:47 pm)
[PATCH 2/5]security:ebitmap.c Fix warning: variable 'e_sft ..., Justin P. Mattock, (Sat Jun 26, 11:47 pm)
[PATCH 3/5]acpi:glue.c Fix warning: variable 'ret' set but ..., Justin P. Mattock, (Sat Jun 26, 11:47 pm)
[PATCH 4/5]block:cryptoloop Fix warning: variable 'cipher' ..., Justin P. Mattock, (Sat Jun 26, 11:47 pm)
Re: [PATCH 5/5]bluetooth:hci_bcsp Fix operation on 'bcsp-&gt; ..., Gustavo F. Padovan, (Sun Jun 27, 12:31 am)
[PATCH] Bluetooth: Fix abuse of the preincrement operator, David Howells, (Mon Jun 28, 5:57 am)
[PATCH] KEYS: Use the variable 'key' in keyctl_describe_key(), David Howells, (Mon Jun 28, 6:05 am)
Re: [PATCH] Bluetooth: Fix abuse of the preincrement operator, Gustavo F. Padovan, (Mon Jun 28, 6:12 am)
Re: [PATCH] Bluetooth: Fix abuse of the preincrement operator, Justin P. Mattock, (Mon Jun 28, 10:44 am)
Re: [PATCH 1/5]security:key.c Fix warning: variable 'key' ..., Justin P. Mattock, (Mon Jun 28, 10:48 am)
Re: [PATCH 2/5]security:ebitmap.c Fix warning: variable 'e ..., Justin P. Mattock, (Mon Jun 28, 10:49 am)
Re: [PATCH 3/5]acpi:glue.c Fix warning: variable 'ret' set ..., Justin P. Mattock, (Mon Jun 28, 10:52 am)
Re: [PATCH 3/5]acpi:glue.c Fix warning: variable 'ret' set ..., Justin P. Mattock, (Mon Jun 28, 12:03 pm)
Re: [PATCH 3/5]acpi:glue.c Fix warning: variable 'ret' set ..., Justin P. Mattock, (Mon Jun 28, 12:08 pm)
Re: [PATCH 3/5]acpi:glue.c Fix warning: variable 'ret' set ..., Justin P. Mattock, (Mon Jun 28, 8:23 pm)
Re: [PATCH 3/5]acpi:glue.c Fix warning: variable 'ret' set ..., Justin P. Mattock, (Tue Jun 29, 10:14 am)
Re: [PATCH 3/5]acpi:glue.c Fix warning: variable 'ret' set ..., Justin P. Mattock, (Tue Jun 29, 2:53 pm)
Re: [PATCH 3/5]acpi:glue.c Fix warning: variable 'ret' set ..., Justin P. Mattock, (Wed Jun 30, 6:21 am)
Re: [PATCH 3/5]acpi:glue.c Fix warning: variable 'ret' set ..., Justin P. Mattock, (Wed Jun 30, 12:47 pm)