Fix: Eliminate warnings
Consider warnings as errors and correct them.
Signed-off-by: Gabor Toth <gabor.toth2@arm.com>
Change-Id: I2d777ee56b21750966b75147be6c4eb73229043f
diff --git a/components/app/remote-test-runner/remote_test_runner.cpp b/components/app/remote-test-runner/remote_test_runner.cpp
index 66d81f6..04c3113 100644
--- a/components/app/remote-test-runner/remote_test_runner.cpp
+++ b/components/app/remote-test-runner/remote_test_runner.cpp
@@ -121,7 +121,7 @@
void remote_test_runner::output_list(const struct test_summary &summary,
const std::vector<struct test_result> &results)
{
- for (int i = 0; i < results.size(); ++i) {
+ for (size_t i = 0; i < results.size(); ++i) {
printf("TEST(%s, %s)\n", results[i].group, results[i].name);
}
@@ -132,7 +132,7 @@
void remote_test_runner::output_results(const struct test_summary &summary,
const std::vector<struct test_result> &results)
{
- for (int i = 0; i < results.size(); ++i) {
+ for (size_t i = 0; i < results.size(); ++i) {
printf("TEST(%s, %s) ", results[i].group, results[i].name);
diff --git a/components/common/uuid/uuid.c b/components/common/uuid/uuid.c
index 6d26cfa..16b6730 100644
--- a/components/common/uuid/uuid.c
+++ b/components/common/uuid/uuid.c
@@ -52,10 +52,7 @@
/* Note that a valid canonical uuid may be part of a longer string
* such as a urn.
*/
- size_t input_len = strnlen(canonical_form, UUID_CANONICAL_FORM_LEN);
-
- if (input_len == UUID_CANONICAL_FORM_LEN) {
-
+ if (!memchr(canonical_form, '\0', UUID_CANONICAL_FORM_LEN)) {
size_t i;
valid_chars = UUID_CANONICAL_FORM_LEN;
diff --git a/components/service/crypto/client/caller/packed-c/crypto_caller_verify_pkcs7_signature.h b/components/service/crypto/client/caller/packed-c/crypto_caller_verify_pkcs7_signature.h
index fef4d28..53335d5 100644
--- a/components/service/crypto/client/caller/packed-c/crypto_caller_verify_pkcs7_signature.h
+++ b/components/service/crypto/client/caller/packed-c/crypto_caller_verify_pkcs7_signature.h
@@ -29,19 +29,24 @@
int status = RPC_ERROR_INTERNAL;
size_t req_len = 0;
+ if (signature_cert_len > UINT16_MAX ||
+ hash_len > UINT16_MAX ||
+ public_key_cert_len > signature_cert_len)
+ return RPC_ERROR_INVALID_VALUE;
+
struct tlv_record signature_record = {
.tag = TS_CRYPTO_VERIFY_PKCS7_SIGNATURE_IN_TAG_SIGNATURE,
- .length = signature_cert_len,
+ .length = (uint16_t)signature_cert_len,
.value = signature_cert
};
struct tlv_record hash_record = { .tag = TS_CRYPTO_VERIFY_PKCS7_SIGNATURE_IN_TAG_HASH,
- .length = hash_len,
+ .length = (uint16_t)hash_len,
.value = hash };
struct tlv_record public_key_record = {
.tag = TS_CRYPTO_VERIFY_PKCS7_SIGNATURE_IN_TAG_PUBLIC_KEY_CERT,
- .length = public_key_cert_len,
+ .length = (uint16_t)public_key_cert_len,
.value = public_key_cert
};
diff --git a/components/service/spm_test/sp.c b/components/service/spm_test/sp.c
index c79051e..0b75d94 100644
--- a/components/service/spm_test/sp.c
+++ b/components/service/spm_test/sp.c
@@ -881,7 +881,7 @@
return_error(err, msg);
}
-void test_mem_get_set(struct ffa_init_info *init_info)
+void test_mem_get_set(union ffa_boot_info *boot_info)
{
void *addr = NULL;
ffa_result res = FFA_OK;
@@ -895,7 +895,7 @@
DMSG("Testing FFA_MEM_PERM_GET/SET");
config_ramstore_init();
- if (!sp_config_load(init_info)) {
+ if (!sp_config_load(boot_info)) {
EMSG("Failed to load SP config");
goto err;
}
@@ -957,8 +957,6 @@
struct ffa_direct_msg msg = {0};
uint16_t own_id = 0;
- (void)boot_info;
-
/* Boot phase */
if (sp_discovery_own_id_get(&own_id) != SP_RESULT_OK) {
EMSG("Couldn't get own_id!!");
diff --git a/components/service/uefi/smm_variable/backend/uefi_variable_store.c b/components/service/uefi/smm_variable/backend/uefi_variable_store.c
index 14fb996..c93efbc 100644
--- a/components/service/uefi/smm_variable/backend/uefi_variable_store.c
+++ b/components/service/uefi/smm_variable/backend/uefi_variable_store.c
@@ -42,9 +42,9 @@
const struct variable_info *info,
const SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE *var);
+#if defined(UEFI_AUTH_VAR)
static bool compare_guid(const EFI_GUID *guid1, const EFI_GUID *guid2);
-#if defined(UEFI_AUTH_VAR)
/* Creating a map of the EFI SMM variable for easier access */
typedef struct {
const SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE *smm_variable;
@@ -70,7 +70,7 @@
static efi_status_t select_verification_keys(
const efi_data_map new_var, EFI_GUID global_variable_guid, EFI_GUID security_database_guid,
uint64_t maximum_variable_size,
- const SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE **allowed_key_store_variables);
+ SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE **allowed_key_store_variables);
static efi_status_t verify_var_by_key_var(const efi_data_map *new_var,
const efi_data_map *key_store_var,
@@ -113,7 +113,7 @@
static efi_status_t check_name_terminator(const int16_t *name, size_t name_size);
#if defined(UEFI_AUTH_VAR)
-static bool compare_name_to_key_store_name(const uint16_t *name1, size_t size1,
+static bool compare_name_to_key_store_name(const int16_t *name1, size_t size1,
const uint16_t *name2, size_t size2);
#endif
@@ -655,6 +655,7 @@
return status;
}
+#if defined(UEFI_AUTH_VAR)
/*
* Returns whether the two guid-s equal. To avoid structure padding related error
* the fields are checked separately instead of memcmp.
@@ -666,7 +667,6 @@
!memcmp(&guid1->Data4, &guid2->Data4, sizeof(guid1->Data4));
}
-#if defined(UEFI_AUTH_VAR)
/*
* Creates a "map" that contains pointers to some of the fields of the SMM variable and the
* UEFI variable stored in the SMM data field. This way a variable is parsed only once.
@@ -873,7 +873,7 @@
static efi_status_t select_verification_keys(
const efi_data_map new_var, EFI_GUID global_variable_guid, EFI_GUID security_database_guid,
uint64_t maximum_variable_size,
- const SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE **allowed_key_store_variables)
+ SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE **allowed_key_store_variables)
{
/**
* UEFI: Page 254
@@ -1152,7 +1152,7 @@
status = select_verification_keys(var_map, global_variable_guid, security_database_guid,
variable_info.MaximumVariableSize,
- &allowed_key_store_variables);
+ &allowed_key_store_variables[0]);
if (status != EFI_SUCCESS)
goto end;
@@ -1512,7 +1512,7 @@
#if defined(UEFI_AUTH_VAR)
/* Compares SMM variable name to key variable name. */
-static bool compare_name_to_key_store_name(const uint16_t *name1, size_t size1,
+static bool compare_name_to_key_store_name(const int16_t *name1, size_t size1,
const uint16_t *name2, size_t size2)
{
if (!name1 || !name2)
diff --git a/deployments/smm-gateway/common/smm_gateway.c b/deployments/smm-gateway/common/smm_gateway.c
index fdc1b8c..f7279fa 100644
--- a/deployments/smm-gateway/common/smm_gateway.c
+++ b/deployments/smm-gateway/common/smm_gateway.c
@@ -7,6 +7,8 @@
#include <stddef.h>
#include <protocols/rpc/common/packed-c/encoding.h>
#include <service/uefi/smm_variable/provider/smm_variable_provider.h>
+#include <service/crypto/client/psa/psa_crypto_client.h>
+#include "psa/crypto.h"
#include <service/secure_storage/backend/secure_storage_client/secure_storage_client.h>
#include <service/secure_storage/backend/mock_store/mock_store.h>
#include <service_locator.h>
diff --git a/deployments/smm-gateway/config/default-opteesp/CMakeLists.txt b/deployments/smm-gateway/config/default-opteesp/CMakeLists.txt
index 711597d..3f844e6 100644
--- a/deployments/smm-gateway/config/default-opteesp/CMakeLists.txt
+++ b/deployments/smm-gateway/config/default-opteesp/CMakeLists.txt
@@ -81,6 +81,7 @@
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_compile_options(smm-gateway PRIVATE
-std=c11
+ -Werror
)
endif()
diff --git a/deployments/smm-gateway/config/default-sp/CMakeLists.txt b/deployments/smm-gateway/config/default-sp/CMakeLists.txt
index d37a2bc..6a3f890 100644
--- a/deployments/smm-gateway/config/default-sp/CMakeLists.txt
+++ b/deployments/smm-gateway/config/default-sp/CMakeLists.txt
@@ -79,6 +79,7 @@
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_compile_options(smm-gateway PRIVATE
-std=c11
+ -Werror
)
endif()
diff --git a/environments/arm-linux/default_toolchain_file.cmake b/environments/arm-linux/default_toolchain_file.cmake
index 6909db6..1da144e 100644
--- a/environments/arm-linux/default_toolchain_file.cmake
+++ b/environments/arm-linux/default_toolchain_file.cmake
@@ -19,7 +19,7 @@
set(TS_DEBUG_INFO_FLAGS "-fdiagnostics-show-option -gdwarf-2" CACHE STRING "Compiler flags to add debug information.")
set(TS_MANDATORY_AARCH_FLAGS "-mstrict-align -march=armv8-a+crc -DARM64=1" CACHE STRING "Compiler flags configuring architecture specific ")
-set(TS_WARNING_FLAGS "-Wall" CACHE STRING "Compiler flags affecting generating warning messages.")
+set(TS_WARNING_FLAGS "-Wall -Werror" CACHE STRING "Compiler flags affecting generating warning messages.")
set(TS_MANDATORY_LINKER_FLAGS "" CACHE STRING "Linker flags needed for correct builds.")
# Set flags affecting all build types
diff --git a/environments/linux-pc/default_toolchain_file.cmake b/environments/linux-pc/default_toolchain_file.cmake
index e23bb79..58f29bc 100644
--- a/environments/linux-pc/default_toolchain_file.cmake
+++ b/environments/linux-pc/default_toolchain_file.cmake
@@ -11,7 +11,7 @@
set(TS_DEBUG_INFO_FLAGS "-fdiagnostics-show-option -gdwarf-2" CACHE STRING "Compiler flags to add debug information.")
set(TS_MANDATORY_AARCH_FLAGS "" CACHE STRING "Compiler flags configuring architecture specific ")
-set(TS_WARNING_FLAGS "-Wall" CACHE STRING "Compiler flags affecting generating warning messages.")
+set(TS_WARNING_FLAGS "-Wall -Werror" CACHE STRING "Compiler flags affecting generating warning messages.")
set(TS_MANDATORY_LINKER_FLAGS "" CACHE STRING "Linker flags needed for correct builds.")
# Set flags affecting all build types
diff --git a/environments/opteesp/default_toolchain_file.cmake b/environments/opteesp/default_toolchain_file.cmake
index 90a9418..43c19c5 100644
--- a/environments/opteesp/default_toolchain_file.cmake
+++ b/environments/opteesp/default_toolchain_file.cmake
@@ -21,7 +21,7 @@
set(TS_DEBUG_INFO_FLAGS "-fdiagnostics-show-option -gdwarf-2" CACHE STRING "Compiler flags to add debug information.")
set(TS_MANDATORY_AARCH_FLAGS "-fpic -mstrict-align -march=armv8-a+crc" CACHE STRING "Compiler flags configuring architecture specific ")
-set(TS_WARNING_FLAGS "-Wall" CACHE STRING "Compiler flags affecting generating warning messages.")
+set(TS_WARNING_FLAGS "-Wall -Werror" CACHE STRING "Compiler flags affecting generating warning messages.")
set(TS_MANDATORY_LINKER_FLAGS "-pie -Wl,--as-needed -Wl,--sort-section=alignment -zmax-page-size=4096"
CACHE STRING "Linker flags needed for correct builds.")