Make azure-c-shared-utility compile cleanly for clang
This commit is contained in:
Родитель
889783fcb4
Коммит
488ec8849f
|
@ -164,10 +164,10 @@ if(MSVC)
|
|||
endif()
|
||||
|
||||
endif()
|
||||
elseif(LINUX)
|
||||
elseif(UNIX) #LINUX OR APPLE
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Werror")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -Werror")
|
||||
if(NOT IN_OPENWRT)
|
||||
if(NOT (IN_OPENWRT OR APPLE))
|
||||
set (CMAKE_C_FLAGS "-D_POSIX_C_SOURCE=200112L ${CMAKE_C_FLAGS}")
|
||||
endif()
|
||||
endif()
|
||||
|
|
|
@ -60,8 +60,8 @@ static int ParseStringToDecimal(const char *src, int* dst)
|
|||
{
|
||||
int result;
|
||||
char* next;
|
||||
(*dst) = strtol(src, &next, 0);
|
||||
if ((src == next) || ((((*dst) == LONG_MAX) || ((*dst) == LONG_MIN)) && (errno != 0)))
|
||||
long num = strtol(src, &next, 0);
|
||||
if (src == next || num < INT_MIN || num > INT_MAX)
|
||||
{
|
||||
result = EOF;
|
||||
}
|
||||
|
@ -69,6 +69,9 @@ static int ParseStringToDecimal(const char *src, int* dst)
|
|||
{
|
||||
result = 1;
|
||||
}
|
||||
if (num < INT_MIN) num = INT_MIN;
|
||||
if (num > INT_MAX) num = INT_MAX;
|
||||
*dst = (int)num;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -366,24 +369,23 @@ static int InternStrnicmp(const char* s1, const char* s2, size_t n)
|
|||
{
|
||||
int result;
|
||||
|
||||
if ((s1 == NULL) || (s2 == NULL))
|
||||
{
|
||||
result = -1;
|
||||
}
|
||||
if (s1 == NULL) result = -1;
|
||||
else if (s2 == NULL) result = 1;
|
||||
else
|
||||
{
|
||||
result = 0;
|
||||
while (((n--) >= 0) && ((*s1) != '\0') && ((*s2) != '\0') && (result == 0))
|
||||
{
|
||||
/* compute the difference between the chars */
|
||||
result = TOLOWER(*s1) - TOLOWER(*s2);
|
||||
s1++;
|
||||
s2++;
|
||||
}
|
||||
|
||||
if ((*s2) != '\0')
|
||||
while(n-- && result == 0)
|
||||
{
|
||||
result = -1;
|
||||
if (*s1 == 0) result = -1;
|
||||
else if (*s2 == 0) result = 1;
|
||||
else
|
||||
{
|
||||
|
||||
result = TOLOWER(*s1) - TOLOWER(*s2);
|
||||
++s1;
|
||||
++s2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -506,7 +508,7 @@ static int readLine(HTTP_HANDLE_DATA* http_instance, char* buf, const size_t max
|
|||
{
|
||||
int resultLineSize;
|
||||
|
||||
if ((http_instance == NULL) || (buf == NULL) || (maxBufSize < 0))
|
||||
if ((http_instance == NULL) || (buf == NULL) || (maxBufSize == 0))
|
||||
{
|
||||
LogError("%s", ((http_instance == NULL) ? "Invalid HTTP instance" : "Invalid HTTP buffer"));
|
||||
resultLineSize = -1;
|
||||
|
@ -932,12 +934,12 @@ static HTTPAPI_RESULT RecieveContentInfoFromXIO(HTTP_HANDLE_DATA* http_instance,
|
|||
const char* substr;
|
||||
char* whereIsColon;
|
||||
int lengthInMsg;
|
||||
const char* ContentLength = "content-length:";
|
||||
const int ContentLengthSize = 16;
|
||||
const char* TransferEncoding = "transfer-encoding:";
|
||||
const int TransferEncodingSize = 19;
|
||||
const char* Chunked = "chunked";
|
||||
const int ChunkedSize = 8;
|
||||
const char ContentLength[] = "content-length:";
|
||||
const size_t ContentLengthSize = sizeof(ContentLength) - 1;
|
||||
const char TransferEncoding[] = "transfer-encoding:";
|
||||
const size_t TransferEncodingSize = sizeof(TransferEncoding) - 1;
|
||||
const char Chunked[] = "chunked";
|
||||
const size_t ChunkedSize = sizeof(Chunked) - 1;
|
||||
|
||||
http_instance->is_io_error = 0;
|
||||
|
||||
|
@ -957,7 +959,7 @@ static HTTPAPI_RESULT RecieveContentInfoFromXIO(HTTP_HANDLE_DATA* http_instance,
|
|||
{
|
||||
if (InternStrnicmp(buf, ContentLength, ContentLengthSize) == 0)
|
||||
{
|
||||
substr = buf + ContentLengthSize - 1;
|
||||
substr = buf + ContentLengthSize;
|
||||
if (ParseStringToDecimal(substr, &lengthInMsg) != 1)
|
||||
{
|
||||
/*Codes_SRS_HTTPAPI_COMPACT_21_032: [ If the HTTPAPI_ExecuteRequest cannot read the message with the request result, it shall return HTTPAPI_READ_DATA_FAILED. ]*/
|
||||
|
@ -970,7 +972,7 @@ static HTTPAPI_RESULT RecieveContentInfoFromXIO(HTTP_HANDLE_DATA* http_instance,
|
|||
}
|
||||
else if (InternStrnicmp(buf, TransferEncoding, TransferEncodingSize) == 0)
|
||||
{
|
||||
substr = buf + TransferEncodingSize - 1;
|
||||
substr = buf + TransferEncodingSize;
|
||||
|
||||
while (isspace(*substr)) substr++;
|
||||
|
||||
|
|
|
@ -503,7 +503,7 @@ void tlsio_arduino_dowork(CONCRETE_IO_HANDLE tlsio_handle)
|
|||
int tlsio_arduino_setoption(CONCRETE_IO_HANDLE tlsio_handle, const char* optionName, const void* value)
|
||||
{
|
||||
/* Codes_SRS_TLSIO_ARDUINO_21_077: [ The tlsio_arduino_setoption shall not do anything, and return 0. ]*/
|
||||
(void)(tlsio_handle, optionName, value);
|
||||
(void)tlsio_handle, (void)optionName, (void)value;
|
||||
|
||||
/* Not implementing any options */
|
||||
return 0;
|
||||
|
|
|
@ -11542,7 +11542,7 @@ IF(X, "true", "false") => "true"
|
|||
#define DEFINE_ENUM_STRINGS(enumName, ...) const char* C2(enumName, StringStorage)[COUNT_ARG(__VA_ARGS__)] = {FOR_EACH_1(DEFINE_ENUMERATION_CONSTANT_AS_STRING, __VA_ARGS__)}; \
|
||||
const char* C2(enumName,Strings)(enumName value) \
|
||||
{ \
|
||||
if(value>=COUNT_ARG(__VA_ARGS__)) \
|
||||
if((int)value>=COUNT_ARG(__VA_ARGS__)) \
|
||||
{ \
|
||||
/*this is an error case*/ \
|
||||
return NULL; \
|
||||
|
@ -11567,7 +11567,7 @@ int C2(enumName, _FromString)(const char* enumAsString, enumName* destination)
|
|||
{ \
|
||||
if(strcmp(enumAsString, C2(enumName, StringStorage)[i])==0) \
|
||||
{ \
|
||||
*destination = (enumName)i; \
|
||||
*destination = (enumName)i; \
|
||||
return 0; \
|
||||
} \
|
||||
} \
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "azure_c_shared_utility/strings.h"
|
||||
#include "azure_c_shared_utility/umock_c_prod.h"
|
||||
#include "azure_c_shared_utility/string_tokenizer_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
|
@ -13,8 +14,6 @@ extern "C"
|
|||
#else
|
||||
#endif
|
||||
|
||||
typedef struct STRING_TOKEN_TAG* STRING_TOKENIZER_HANDLE;
|
||||
|
||||
MOCKABLE_FUNCTION(, STRING_TOKENIZER_HANDLE, STRING_TOKENIZER_create, STRING_HANDLE, handle);
|
||||
MOCKABLE_FUNCTION(, STRING_TOKENIZER_HANDLE, STRING_TOKENIZER_create_from_char, const char*, input);
|
||||
MOCKABLE_FUNCTION(, int, STRING_TOKENIZER_get_next_token, STRING_TOKENIZER_HANDLE, t, STRING_HANDLE, output, const char*, delimiters);
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
#ifndef STRING_TOKENIZER_TYPES_H
|
||||
#define STRING_TOKENIZER_TYPES_H
|
||||
|
||||
typedef struct STRING_TOKEN_TAG* STRING_TOKENIZER_HANDLE;
|
||||
|
||||
#endif /*STRING_TOKENIZER_TYPES_H*/
|
|
@ -4,6 +4,9 @@
|
|||
#ifndef STRINGS_H
|
||||
#define STRINGS_H
|
||||
|
||||
#include "azure_c_shared_utility/umock_c_prod.h"
|
||||
#include "azure_c_shared_utility/strings_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <cstddef>
|
||||
extern "C"
|
||||
|
@ -12,10 +15,6 @@ extern "C"
|
|||
#include <stddef.h>
|
||||
#endif
|
||||
|
||||
#include "azure_c_shared_utility/umock_c_prod.h"
|
||||
|
||||
typedef struct STRING_TAG* STRING_HANDLE;
|
||||
|
||||
MOCKABLE_FUNCTION(, STRING_HANDLE, STRING_new);
|
||||
MOCKABLE_FUNCTION(, STRING_HANDLE, STRING_clone, STRING_HANDLE, handle);
|
||||
MOCKABLE_FUNCTION(, STRING_HANDLE, STRING_construct, const char*, psz);
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
#ifndef STRINGS_TYPES_H
|
||||
#define STRINGS_TYPES_H
|
||||
|
||||
typedef struct STRING_TAG* STRING_HANDLE;
|
||||
|
||||
#endif /*STRINGS_TYPES_H*/
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
static void on_io_open_complete(void* context, IO_OPEN_RESULT open_result)
|
||||
{
|
||||
(void)context, open_result;
|
||||
(void)context, (void)open_result;
|
||||
(void)printf("Open complete called\r\n");
|
||||
|
||||
if (open_result == IO_OPEN_OK)
|
||||
|
@ -31,7 +31,7 @@ static void on_io_open_complete(void* context, IO_OPEN_RESULT open_result)
|
|||
|
||||
static void on_io_bytes_received(void* context, const unsigned char* buffer, size_t size)
|
||||
{
|
||||
(void)context, buffer;
|
||||
(void)context, (void)buffer;
|
||||
(void)printf("Received %zu bytes\r\n", size);
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ int main(int argc, char** argv)
|
|||
{
|
||||
int result;
|
||||
|
||||
(void)argc, argv;
|
||||
(void)argc, (void)argv;
|
||||
|
||||
if (platform_init() != 0)
|
||||
{
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
static void on_io_open_complete(void* context, IO_OPEN_RESULT open_result)
|
||||
{
|
||||
(void)context, open_result;
|
||||
(void)context, (void)open_result;
|
||||
(void)printf("Open complete called\r\n");
|
||||
|
||||
if (open_result == IO_OPEN_OK)
|
||||
|
@ -31,7 +31,7 @@ static void on_io_open_complete(void* context, IO_OPEN_RESULT open_result)
|
|||
|
||||
static void on_io_bytes_received(void* context, const unsigned char* buffer, size_t size)
|
||||
{
|
||||
(void)context, buffer;
|
||||
(void)context, (void)buffer;
|
||||
(void)printf("Received %zu bytes\r\n", size);
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ int main(int argc, char** argv)
|
|||
{
|
||||
int result;
|
||||
|
||||
(void)argc, argv;
|
||||
(void)argc, (void)argv;
|
||||
|
||||
if (platform_init() != 0)
|
||||
{
|
||||
|
|
|
@ -93,7 +93,7 @@ MAP_HANDLE my_Map_Clone(MAP_HANDLE sourceMap)
|
|||
MAP_RESULT my_Map_ContainsKey(MAP_HANDLE handle, const char* key, bool* keyExists)
|
||||
{
|
||||
MAP_RESULT result = currentMapResult;
|
||||
(void)handle, key;
|
||||
(void)handle, (void)key;
|
||||
if (result == MAP_OK)
|
||||
{
|
||||
*keyExists = true;
|
||||
|
@ -104,7 +104,7 @@ MAP_RESULT my_Map_ContainsKey(MAP_HANDLE handle, const char* key, bool* keyExist
|
|||
MAP_RESULT my_Map_ContainsValue(MAP_HANDLE handle, const char* value, bool* valueExists)
|
||||
{
|
||||
MAP_RESULT result = currentMapResult;
|
||||
(void)handle, value;
|
||||
(void)handle, (void)value;
|
||||
if (result == MAP_OK)
|
||||
{
|
||||
*valueExists = true;
|
||||
|
@ -115,7 +115,7 @@ MAP_RESULT my_Map_ContainsValue(MAP_HANDLE handle, const char* value, bool* valu
|
|||
const char* my_Map_GetValueFromKey(MAP_HANDLE sourceMap, const char* key)
|
||||
{
|
||||
const char* result;
|
||||
(void)key, sourceMap;
|
||||
(void)key, (void)sourceMap;
|
||||
if (currentMapResult == MAP_OK)
|
||||
{
|
||||
result = VALID_VALUE;
|
||||
|
|
|
@ -100,7 +100,7 @@ void my_STRING_delete(STRING_HANDLE handle)
|
|||
|
||||
STRING_HANDLE my_SASToken_Create(STRING_HANDLE key, STRING_HANDLE scope, STRING_HANDLE keyName, size_t expiry)
|
||||
{
|
||||
(void)key, scope, keyName, expiry;
|
||||
(void)key, (void)scope, (void)keyName, (void)expiry;
|
||||
return (STRING_HANDLE)malloc(1);
|
||||
}
|
||||
|
||||
|
@ -136,8 +136,8 @@ char* umocktypes_stringify_time_t(const time_t* value)
|
|||
{
|
||||
char temp_str[32];
|
||||
char* result;
|
||||
size_t length = snprintf(temp_str, sizeof(temp_str), "%d", (int)(*value));
|
||||
if (length < 0)
|
||||
int length = snprintf(temp_str, sizeof(temp_str), "%d", (int)(*value));
|
||||
if (length <= 0)
|
||||
{
|
||||
result = NULL;
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ static int my_mallocAndStrcpy_s(char** destination, const char* source)
|
|||
|
||||
static void* my_aCloneOption(const char* name, const void* value)
|
||||
{
|
||||
(void)(name, value);
|
||||
(void)name, (void)value;
|
||||
return my_gballoc_malloc(2);
|
||||
}
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ static BIO* my_BIO_new_mem_buf(const void * buf, int len)
|
|||
static BIO* my_BIO_new_mem_buf(void * buf, int len)
|
||||
#endif
|
||||
{
|
||||
(void)(len,buf);
|
||||
(void)len, (void)buf;
|
||||
return (BIO*)my_gballoc_malloc(sizeof(BIO));
|
||||
}
|
||||
|
||||
|
@ -102,13 +102,13 @@ static void my_X509_free(X509 * a)
|
|||
|
||||
static X509 * my_PEM_read_bio_X509(BIO * bp, X509 ** x, pem_password_cb * cb, void * u)
|
||||
{
|
||||
(void)(u,cb, x, bp);
|
||||
(void)u, (void)cb, (void)x, (void)bp;
|
||||
return (X509*)my_gballoc_malloc(sizeof(X509));
|
||||
}
|
||||
|
||||
static RSA * my_PEM_read_bio_RSAPrivateKey(BIO * bp, RSA ** x, pem_password_cb * cb, void * u)
|
||||
{
|
||||
(void)(u, cb, x, bp);
|
||||
(void)u, (void)cb, (void)x, (void)bp;
|
||||
return (RSA*)my_gballoc_malloc(sizeof(RSA));
|
||||
}
|
||||
|
||||
|
|
|
@ -122,7 +122,7 @@ static void on_umock_c_error(UMOCK_C_ERROR_CODE error_code)
|
|||
|
||||
static OPTIONHANDLER_HANDLE my_OptionHandler_Create(pfCloneOption cloneOption, pfDestroyOption destroyOption, pfSetOption setOption)
|
||||
{
|
||||
(void)(cloneOption, destroyOption, setOption);
|
||||
(void)cloneOption, (void)destroyOption, (void)setOption;
|
||||
return (OPTIONHANDLER_HANDLE)my_gballoc_malloc(1);
|
||||
}
|
||||
|
||||
|
@ -134,7 +134,7 @@ static OPTIONHANDLER_HANDLE my_test_xio_retrieveoptions(CONCRETE_IO_HANDLE handl
|
|||
|
||||
static OPTIONHANDLER_RESULT my_OptionHandler_AddOption(OPTIONHANDLER_HANDLE handle, const char* name, const void* value)
|
||||
{
|
||||
(void)(name, handle, value);
|
||||
(void)name, (void)handle, (void)value;
|
||||
/*if an option is added here, it is because it was cloned (malloc'd) so safe to free it here*/
|
||||
my_gballoc_free((void*)value);
|
||||
return OPTIONHANDLER_OK;
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 7a00db94231e2f4eff4f22755d07662e006fc712
|
||||
Subproject commit c45ba5bf3e2c7369bd5d75594ee0b1c7d2c66581
|
Загрузка…
Ссылка в новой задаче