From 4b116e0bedc832240166a1390cabc8ab2234e750 Mon Sep 17 00:00:00 2001 From: Jonathan Chiu Date: Tue, 5 Mar 2019 13:29:28 -0800 Subject: [PATCH] Change uint32_t option to enum --- adapters/platform_esp8266.c | 2 +- adapters/platform_freertos.c | 2 +- adapters/platform_linux.c | 2 +- adapters/platform_mbed.cpp | 2 +- adapters/platform_mbed_os5.cpp | 2 +- adapters/platform_stub.c | 2 +- adapters/platform_tizenrt.c | 2 +- adapters/platform_win32.c | 4 ++-- inc/azure_c_shared_utility/platform.h | 9 +++++++-- pal/ios-osx/platform_appleios.c | 2 +- samples/iot_c_utility/iot_c_utility.c | 2 +- tests/platform_win32_ut/platform_win32_ut.c | 2 +- 12 files changed, 19 insertions(+), 14 deletions(-) diff --git a/adapters/platform_esp8266.c b/adapters/platform_esp8266.c index 8af4ed37..1fef9405 100644 --- a/adapters/platform_esp8266.c +++ b/adapters/platform_esp8266.c @@ -29,7 +29,7 @@ const IO_INTERFACE_DESCRIPTION* platform_get_default_tlsio(void) return tlsio_openssl_get_interface_description(); } -STRING_HANDLE platform_get_platform_info(uint32_t options) +STRING_HANDLE platform_get_platform_info(PLATFORM_INFO_OPTION options) { (void)options; diff --git a/adapters/platform_freertos.c b/adapters/platform_freertos.c index f36d1a5c..1ea39424 100644 --- a/adapters/platform_freertos.c +++ b/adapters/platform_freertos.c @@ -20,7 +20,7 @@ const IO_INTERFACE_DESCRIPTION* platform_get_default_tlsio(void) return tlsio_cyclonessl_get_interface_description(); } -STRING_HANDLE platform_get_platform_info(uint32_t options) +STRING_HANDLE platform_get_platform_info(PLATFORM_INFO_OPTION options) { (void)options; diff --git a/adapters/platform_linux.c b/adapters/platform_linux.c index 1d7aa36a..98821ccc 100644 --- a/adapters/platform_linux.c +++ b/adapters/platform_linux.c @@ -47,7 +47,7 @@ const IO_INTERFACE_DESCRIPTION* platform_get_default_tlsio(void) #endif } -STRING_HANDLE platform_get_platform_info(uint32_t options) +STRING_HANDLE platform_get_platform_info(PLATFORM_INFO_OPTION options) { (void)options; diff --git a/adapters/platform_mbed.cpp b/adapters/platform_mbed.cpp index 34bb967d..077f83f1 100644 --- a/adapters/platform_mbed.cpp +++ b/adapters/platform_mbed.cpp @@ -64,7 +64,7 @@ const IO_INTERFACE_DESCRIPTION* platform_get_default_tlsio(void) return tlsio_wolfssl_get_interface_description(); } -STRING_HANDLE platform_get_platform_info(uint32_t options) +STRING_HANDLE platform_get_platform_info(PLATFORM_INFO_OPTION options) { (void)options; diff --git a/adapters/platform_mbed_os5.cpp b/adapters/platform_mbed_os5.cpp index f526453f..71c89a61 100644 --- a/adapters/platform_mbed_os5.cpp +++ b/adapters/platform_mbed_os5.cpp @@ -16,7 +16,7 @@ const IO_INTERFACE_DESCRIPTION *platform_get_default_tlsio(void) return tlsio_mbedtls_get_interface_description(); } -STRING_HANDLE platform_get_platform_info(uint32_t options) +STRING_HANDLE platform_get_platform_info(PLATFORM_INFO_OPTION options) { (void)options; diff --git a/adapters/platform_stub.c b/adapters/platform_stub.c index cab3aa54..8ee9a99c 100644 --- a/adapters/platform_stub.c +++ b/adapters/platform_stub.c @@ -13,7 +13,7 @@ const IO_INTERFACE_DESCRIPTION* platform_get_default_tlsio(void) return NULL; } -STRING_HANDLE platform_get_platform_info(uint32_t options) +STRING_HANDLE platform_get_platform_info(PLATFORM_INFO_OPTION options) { (void)options; diff --git a/adapters/platform_tizenrt.c b/adapters/platform_tizenrt.c index dff137da..73ada11f 100644 --- a/adapters/platform_tizenrt.c +++ b/adapters/platform_tizenrt.c @@ -15,7 +15,7 @@ const IO_INTERFACE_DESCRIPTION* platform_get_default_tlsio(void) return tlsio_mbedtls_get_interface_description(); } -STRING_HANDLE platform_get_platform_info(uint32_t options) +STRING_HANDLE platform_get_platform_info(PLATFORM_INFO_OPTION options) { (void)options; diff --git a/adapters/platform_win32.c b/adapters/platform_win32.c index a31861cf..8ce0446a 100644 --- a/adapters/platform_win32.c +++ b/adapters/platform_win32.c @@ -114,7 +114,7 @@ static char* get_win_sqm_info(void) return result; } -STRING_HANDLE platform_get_platform_info(uint32_t options) +STRING_HANDLE platform_get_platform_info(PLATFORM_INFO_OPTION options) { // Expected format: "(; ; )" STRING_HANDLE result; @@ -171,7 +171,7 @@ STRING_HANDLE platform_get_platform_info(uint32_t options) LogError("STRING_construct_sprintf failed"); } - if (options & PLATFORM_OPTION_RETRIEVE_SQM) + if (options & PLATFORM_INFO_OPTION_RETRIEVE_SQM) { // Failure here should continue char* sqm_info = get_win_sqm_info(); diff --git a/inc/azure_c_shared_utility/platform.h b/inc/azure_c_shared_utility/platform.h index e1cfef2c..d2aee2b4 100644 --- a/inc/azure_c_shared_utility/platform.h +++ b/inc/azure_c_shared_utility/platform.h @@ -9,7 +9,12 @@ #include "azure_c_shared_utility/umock_c_prod.h" #define GUID_LENGTH 64 -#define PLATFORM_OPTION_RETRIEVE_SQM 0x0001 + +#define PLATFORM_INFO_OPTION_VALUES \ + PLATFORM_INFO_OPTION_DEFAULT, \ + PLATFORM_INFO_OPTION_RETRIEVE_SQM + +DEFINE_ENUM(PLATFORM_INFO_OPTION, PLATFORM_INFO_OPTION_VALUES); #ifdef __cplusplus extern "C" { @@ -21,7 +26,7 @@ extern "C" { MOCKABLE_FUNCTION(, int, platform_init); MOCKABLE_FUNCTION(, void, platform_deinit); MOCKABLE_FUNCTION(, const IO_INTERFACE_DESCRIPTION*, platform_get_default_tlsio); - MOCKABLE_FUNCTION(, STRING_HANDLE, platform_get_platform_info, uint32_t, options); + MOCKABLE_FUNCTION(, STRING_HANDLE, platform_get_platform_info, PLATFORM_INFO_OPTION, options); #ifdef __cplusplus } diff --git a/pal/ios-osx/platform_appleios.c b/pal/ios-osx/platform_appleios.c index bfaf60b4..433581d5 100644 --- a/pal/ios-osx/platform_appleios.c +++ b/pal/ios-osx/platform_appleios.c @@ -20,7 +20,7 @@ const IO_INTERFACE_DESCRIPTION* platform_get_default_tlsio(void) return tlsio_appleios_get_interface_description(); } -STRING_HANDLE platform_get_platform_info(uint32_t options) +STRING_HANDLE platform_get_platform_info(PLATFORM_INFO_OPTION options) { (void)options; STRING_HANDLE result; diff --git a/samples/iot_c_utility/iot_c_utility.c b/samples/iot_c_utility/iot_c_utility.c index 529c8dc1..6c9290ea 100644 --- a/samples/iot_c_utility/iot_c_utility.c +++ b/samples/iot_c_utility/iot_c_utility.c @@ -53,7 +53,7 @@ static void show_sastoken_example() static void show_platform_info() { - STRING_HANDLE platform_info = platform_get_platform_info(PLATFORM_OPTION_RETRIEVE_SQM); + STRING_HANDLE platform_info = platform_get_platform_info(PLATFORM_INFO_OPTION_RETRIEVE_SQM); if (platform_info != NULL) { (void)printf("%s\r\n", STRING_c_str(platform_info)); diff --git a/tests/platform_win32_ut/platform_win32_ut.c b/tests/platform_win32_ut/platform_win32_ut.c index 236241c7..7e24550d 100644 --- a/tests/platform_win32_ut/platform_win32_ut.c +++ b/tests/platform_win32_ut/platform_win32_ut.c @@ -242,7 +242,7 @@ TEST_FUNCTION(platform_get_platform_info_success) //arrange //act - STRING_HANDLE platform = platform_get_platform_info(PLATFORM_OPTION_RETRIEVE_SQM); + STRING_HANDLE platform = platform_get_platform_info(PLATFORM_INFO_OPTION_RETRIEVE_SQM); //assert ASSERT_IS_NOT_NULL(platform);