summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenny Root <kroot@google.com>2012-04-10 12:34:07 -0700
committerKenny Root <kroot@google.com>2012-04-10 12:34:09 -0700
commitda1ed9ab99c00698af64ec655ff668efffe2960d (patch)
tree600382831b66c5017afb6f19178fd3c3f1993319
parent98c2f8fcc1263a9d94adac66994fffc96c0df699 (diff)
downloadsystem_security-da1ed9ab99c00698af64ec655ff668efffe2960d.zip
system_security-da1ed9ab99c00698af64ec655ff668efffe2960d.tar.gz
system_security-da1ed9ab99c00698af64ec655ff668efffe2960d.tar.bz2
Turn on extra compiler checks
Turn on the compiler flags -Wall -Wextra -Werror to make sure no compiler warnings are added to the project. Eliminate all unused arguments. Remove unused variables in code. Change-Id: I0940ba897ac716b4a256f94fcd671f1ff5abc62c
-rw-r--r--keystore/Android.mk3
-rw-r--r--keystore/keystore.cpp35
2 files changed, 18 insertions, 20 deletions
diff --git a/keystore/Android.mk b/keystore/Android.mk
index 9faf5c2..d4fbe06 100644
--- a/keystore/Android.mk
+++ b/keystore/Android.mk
@@ -17,6 +17,7 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
+LOCAL_CFLAGS := -Wall -Wextra -Werror
LOCAL_SRC_FILES := keystore.cpp keyblob_utils.cpp
LOCAL_C_INCLUDES := external/openssl/include
LOCAL_SHARED_LIBRARIES := libcutils libcrypto libhardware
@@ -25,6 +26,7 @@ LOCAL_MODULE_TAGS := optional
include $(BUILD_EXECUTABLE)
include $(CLEAR_VARS)
+LOCAL_CFLAGS := -Wall -Wextra -Werror
LOCAL_SRC_FILES := keystore_cli.cpp
LOCAL_C_INCLUDES := external/openssl/include
LOCAL_SHARED_LIBRARIES := libcutils libcrypto
@@ -34,6 +36,7 @@ include $(BUILD_EXECUTABLE)
# Library for keystore clients
include $(CLEAR_VARS)
+LOCAL_CFLAGS := -Wall -Wextra -Werror
LOCAL_SRC_FILES := keystore_client.cpp keyblob_utils.cpp
LOCAL_SHARED_LIBRARIES := libcutils
LOCAL_MODULE := libkeystore_client
diff --git a/keystore/keystore.cpp b/keystore/keystore.cpp
index 8d30965..3f13c11 100644
--- a/keystore/keystore.cpp
+++ b/keystore/keystore.cpp
@@ -935,7 +935,7 @@ static ResponseCode get_key_for_name(KeyStore* keyStore, Blob* keyBlob, const Va
static const ResponseCode NO_ERROR_RESPONSE_CODE_SENT = (ResponseCode) 0;
-static ResponseCode test(KeyStore* keyStore, int sock, uid_t uid, Value*, Value*, Value*) {
+static ResponseCode test(KeyStore* keyStore, int, uid_t, Value*, Value*, Value*) {
return (ResponseCode) keyStore->getState();
}
@@ -952,7 +952,7 @@ static ResponseCode get(KeyStore* keyStore, int sock, uid_t uid, Value* keyName,
return NO_ERROR_RESPONSE_CODE_SENT;
}
-static ResponseCode insert(KeyStore* keyStore, int sock, uid_t uid, Value* keyName, Value* val,
+static ResponseCode insert(KeyStore* keyStore, int, uid_t uid, Value* keyName, Value* val,
Value*) {
char filename[NAME_MAX];
encode_key_for_uid(filename, uid, keyName);
@@ -960,7 +960,7 @@ static ResponseCode insert(KeyStore* keyStore, int sock, uid_t uid, Value* keyNa
return keyStore->put(filename, &keyBlob);
}
-static ResponseCode del(KeyStore* keyStore, int sock, uid_t uid, Value* keyName, Value*, Value*) {
+static ResponseCode del(KeyStore* keyStore, int, uid_t uid, Value* keyName, Value*, Value*) {
char filename[NAME_MAX];
encode_key_for_uid(filename, uid, keyName);
Blob keyBlob;
@@ -971,7 +971,7 @@ static ResponseCode del(KeyStore* keyStore, int sock, uid_t uid, Value* keyName,
return (unlink(filename) && errno != ENOENT) ? SYSTEM_ERROR : NO_ERROR;
}
-static ResponseCode exist(KeyStore* keyStore, int sock, uid_t uid, Value* keyName, Value*, Value*) {
+static ResponseCode exist(KeyStore*, int, uid_t uid, Value* keyName, Value*, Value*) {
char filename[NAME_MAX];
encode_key_for_uid(filename, uid, keyName);
if (access(filename, R_OK) == -1) {
@@ -980,7 +980,7 @@ static ResponseCode exist(KeyStore* keyStore, int sock, uid_t uid, Value* keyNam
return NO_ERROR;
}
-static ResponseCode saw(KeyStore* keyStore, int sock, uid_t uid, Value* keyPrefix, Value*, Value*) {
+static ResponseCode saw(KeyStore*, int sock, uid_t uid, Value* keyPrefix, Value*, Value*) {
DIR* dir = opendir(".");
if (!dir) {
return SYSTEM_ERROR;
@@ -1001,7 +1001,7 @@ static ResponseCode saw(KeyStore* keyStore, int sock, uid_t uid, Value* keyPrefi
return NO_ERROR_RESPONSE_CODE_SENT;
}
-static ResponseCode reset(KeyStore* keyStore, int sock, uid_t uid, Value*, Value*, Value*) {
+static ResponseCode reset(KeyStore* keyStore, int, uid_t, Value*, Value*, Value*) {
ResponseCode rc = keyStore->reset() ? NO_ERROR : SYSTEM_ERROR;
const keymaster_device_t* device = keyStore->getDevice();
@@ -1029,7 +1029,7 @@ static ResponseCode reset(KeyStore* keyStore, int sock, uid_t uid, Value*, Value
* any thing goes wrong during the transition, the new file will not overwrite
* the old one. This avoids permanent damages of the existing data. */
-static ResponseCode password(KeyStore* keyStore, int sock, uid_t uid, Value* pw, Value*, Value*) {
+static ResponseCode password(KeyStore* keyStore, int, uid_t, Value* pw, Value*, Value*) {
switch (keyStore->getState()) {
case STATE_UNINITIALIZED: {
// generate master key, encrypt with password, write to file, initialize mMasterKey*.
@@ -1047,7 +1047,7 @@ static ResponseCode password(KeyStore* keyStore, int sock, uid_t uid, Value* pw,
return SYSTEM_ERROR;
}
-static ResponseCode lock(KeyStore* keyStore, int sock, uid_t uid, Value*, Value*, Value*) {
+static ResponseCode lock(KeyStore* keyStore, int, uid_t, Value*, Value*, Value*) {
keyStore->lock();
return NO_ERROR;
}
@@ -1057,11 +1057,11 @@ static ResponseCode unlock(KeyStore* keyStore, int sock, uid_t uid, Value* pw, V
return password(keyStore, sock, uid, pw, unused, unused2);
}
-static ResponseCode zero(KeyStore* keyStore, int sock, uid_t uid, Value*, Value*, Value*) {
+static ResponseCode zero(KeyStore* keyStore, int, uid_t, Value*, Value*, Value*) {
return keyStore->isEmpty() ? KEY_NOT_FOUND : NO_ERROR;
}
-static ResponseCode generate(KeyStore* keyStore, int sock, uid_t uid, Value* keyName, Value*,
+static ResponseCode generate(KeyStore* keyStore, int, uid_t uid, Value* keyName, Value*,
Value*) {
char filename[NAME_MAX];
uint8_t* data;
@@ -1094,7 +1094,7 @@ static ResponseCode generate(KeyStore* keyStore, int sock, uid_t uid, Value* key
return keyStore->put(filename, &keyBlob);
}
-static ResponseCode import(KeyStore* keyStore, int sock, uid_t uid, Value* keyName, Value* key,
+static ResponseCode import(KeyStore* keyStore, int, uid_t uid, Value* keyName, Value* key,
Value*) {
char filename[NAME_MAX];
@@ -1149,7 +1149,7 @@ static ResponseCode get_pubkey(KeyStore* keyStore, int sock, uid_t uid, Value* k
return NO_ERROR_RESPONSE_CODE_SENT;
}
-static ResponseCode del_key(KeyStore* keyStore, int sock, uid_t uid, Value* keyName, Value*,
+static ResponseCode del_key(KeyStore* keyStore, int, uid_t uid, Value* keyName, Value*,
Value*) {
char filename[NAME_MAX];
encode_key_for_uid(filename, uid, keyName);
@@ -1169,9 +1169,6 @@ static ResponseCode del_key(KeyStore* keyStore, int sock, uid_t uid, Value* keyN
return SYSTEM_ERROR;
}
- uint8_t* data = NULL;
- size_t dataLength;
-
int rc = device->delete_keypair(device, keyBlob.getValue(), keyBlob.getLength());
return rc ? SYSTEM_ERROR : NO_ERROR;
@@ -1218,7 +1215,7 @@ static ResponseCode sign(KeyStore* keyStore, int sock, uid_t uid, Value* keyName
return NO_ERROR_RESPONSE_CODE_SENT;
}
-static ResponseCode verify(KeyStore* keyStore, int sock, uid_t uid, Value* keyName, Value* data,
+static ResponseCode verify(KeyStore* keyStore, int, uid_t uid, Value* keyName, Value* data,
Value* signature) {
Blob keyBlob;
int rc;
@@ -1250,7 +1247,7 @@ static ResponseCode verify(KeyStore* keyStore, int sock, uid_t uid, Value* keyNa
}
}
-static ResponseCode grant(KeyStore* keyStore, int sock, uid_t uid, Value* keyName,
+static ResponseCode grant(KeyStore* keyStore, int, uid_t uid, Value* keyName,
Value* granteeData, Value*) {
char filename[NAME_MAX];
encode_key_for_uid(filename, uid, keyName);
@@ -1262,7 +1259,7 @@ static ResponseCode grant(KeyStore* keyStore, int sock, uid_t uid, Value* keyNam
return NO_ERROR;
}
-static ResponseCode ungrant(KeyStore* keyStore, int sock, uid_t uid, Value* keyName,
+static ResponseCode ungrant(KeyStore* keyStore, int, uid_t uid, Value* keyName,
Value* granteeData, Value*) {
char filename[NAME_MAX];
encode_key_for_uid(filename, uid, keyName);
@@ -1375,8 +1372,6 @@ static ResponseCode process(KeyStore* keyStore, int sock, uid_t uid, int8_t code
}
int main(int argc, char* argv[]) {
- void* hardwareContext = NULL;
-
int controlSocket = android_get_control_socket("keystore");
if (argc < 2) {
ALOGE("A directory must be specified!");