[PATCH linux-next] security/integrity: Fix build error and warnings when CONFIG_INTEGRITY_ASYMMETRIC_KEYS is disabled

From: Shuah Khan
Date: Fri Nov 08 2013 - 16:23:35 EST


Fixed both linux-next build error and warnings with the following changes

- define integrity_init_keyring() only when CONFIG_INTEGRITY_ASYMMETRIC_KEYS
is enabled
- move integrity_init_keyring() stub from integrity.h
- define integrity_init_keyring() prototype as an extern when
CONFIG_INTEGRITY_ASYMMETRIC_KEYS

linux-next build fails with the following error when CONFIG_INTEGRITY_ASYMMETRIC_KEYS
is disabled.

CC security/integrity/digsig.o
security/integrity/digsig.c:70:5: error: redefinition of âintegrity_init_keyringâ
int integrity_init_keyring(const unsigned int id)
^
In file included from security/integrity/digsig.c:22:0:
security/integrity/integrity.h:149:12: note: previous definition of âintegrity_init_keyringâ was here
static int integrity_init_keyring(const unsigned int id)
^
security/integrity/integrity.h:149:12: warning: âintegrity_init_keyringâ defined but not used [-Wunused-function]
make[2]: *** [security/integrity/digsig.o] Error 1
make[1]: *** [security/integrity] Error 2
make: *** [security] Error 2

Signed-off-by: Shuah Khan <shuah.kh@xxxxxxxxxxx>
---
security/integrity/digsig.c | 7 +++++++
security/integrity/integrity.h | 8 ++------
2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/security/integrity/digsig.c b/security/integrity/digsig.c
index 77ca965..28bc1a7 100644
--- a/security/integrity/digsig.c
+++ b/security/integrity/digsig.c
@@ -67,6 +67,7 @@ int integrity_digsig_verify(const unsigned int id, const char *sig, int siglen,
return -EOPNOTSUPP;
}

+#ifdef CONFIG_INTEGRITY_ASYMMETRIC_KEYS
int integrity_init_keyring(const unsigned int id)
{
const struct cred *cred = current_cred();
@@ -84,3 +85,9 @@ int integrity_init_keyring(const unsigned int id)
keyring_name[id], PTR_ERR(keyring[id]));
return 0;
}
+#else
+int integrity_init_keyring(const unsigned int id)
+{
+ return 0;
+}
+#endif
diff --git a/security/integrity/integrity.h b/security/integrity/integrity.h
index b9e7c13..99ac783 100644
--- a/security/integrity/integrity.h
+++ b/security/integrity/integrity.h
@@ -134,22 +134,18 @@ static inline int integrity_digsig_verify(const unsigned int id,

#endif /* CONFIG_INTEGRITY_SIGNATURE */

+extern int integrity_init_keyring(const unsigned int id);
+
#ifdef CONFIG_INTEGRITY_ASYMMETRIC_KEYS
int asymmetric_verify(struct key *keyring, const char *sig,
int siglen, const char *data, int datalen);

-int integrity_init_keyring(const unsigned int id);
#else
static inline int asymmetric_verify(struct key *keyring, const char *sig,
int siglen, const char *data, int datalen)
{
return -EOPNOTSUPP;
}
-
-static int integrity_init_keyring(const unsigned int id)
-{
- return 0;
-}
#endif

#ifdef CONFIG_INTEGRITY_AUDIT
--
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/