Skip to content

Commit 50e0cd5

Browse files
use clang-format.sh to sanitize changes
1 parent b40a2d3 commit 50e0cd5

File tree

5 files changed

+51
-27
lines changed

5 files changed

+51
-27
lines changed

src/adu_types/inc/aduc/adu_types.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ typedef struct tagConnectionInfo
7373
char* certificateString; /**< x509 certificate in PEM format for the IoTHubClient to be used for authentication*/
7474
char* opensslEngine; /**< identifier for the OpenSSL Engine used for the certificate in certificateString*/
7575
char* opensslPrivateKey; /**< x509 private key in PEM format for the IoTHubClient to be used for authentication */
76-
char* clientCertificateString; /**< x509 certificate in PEM format for the IoTHubClient to be used for authentication*/
76+
char*
77+
clientCertificateString; /**< x509 certificate in PEM format for the IoTHubClient to be used for authentication*/
7778
} ADUC_ConnectionInfo;
7879

7980
/**

src/agent/src/health_management.c

+7-3
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,11 @@ bool GetConnectionInfoFromIdentityService(ADUC_ConnectionInfo* info);
6464
* @return true if connection info can be obtained
6565
*/
6666
bool GetConnectionInfoFromConnectionString(
67-
ADUC_ConnectionInfo* info, const char* connectionString,
68-
const char* const x509Cert, const char* const x509PrivateKey, const char* const x509CaCert);
67+
ADUC_ConnectionInfo* info,
68+
const char* connectionString,
69+
const char* const x509Cert,
70+
const char* const x509PrivateKey,
71+
const char* const x509CaCert);
6972

7073
/**
7174
* @brief Checks whether we can obtain a device or module connection string.
@@ -101,7 +104,8 @@ bool IsConnectionInfoValid(const ADUC_LaunchArguments* launchArgs, const ADUC_Co
101104
}
102105
else if (strcmp(agent->connectionType, "X509") == 0)
103106
{
104-
validInfo = GetConnectionInfoFromConnectionString(&info, agent->connectionData, agent->x509Cert, agent->x509PrivateKey, agent->x509CaCert);
107+
validInfo = GetConnectionInfoFromConnectionString(
108+
&info, agent->connectionData, agent->x509Cert, agent->x509PrivateKey, agent->x509CaCert);
105109
}
106110
else
107111
{

src/communication_managers/iothub_communication_manager/inc/aduc/iothub_communication_manager.h

+10-7
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,11 @@ ADUC_ConnType GetConnTypeFromConnectionString(const char* connectionString);
3131
* @return true if connection info can be obtained
3232
*/
3333
bool GetConnectionInfoFromConnectionString(
34-
ADUC_ConnectionInfo* info, const char* connectionString,
35-
const char* const x509Cert, const char* const x509PrivateKey, const char* const x509CaCert);
34+
ADUC_ConnectionInfo* info,
35+
const char* connectionString,
36+
const char* const x509Cert,
37+
const char* const x509PrivateKey,
38+
const char* const x509CaCert);
3639

3740
/**
3841
* @brief Get the Connection Info from Identity Service
@@ -66,11 +69,11 @@ typedef void (*ADUC_COMMUNICATION_MANAGER_CLIENT_HANDLE_UPDATED_CALLBACK)(ADUC_C
6669
*
6770
* @return 'true' if success.
6871
*/
69-
bool IoTHub_CommunicationManager_Init(ADUC_ClientHandle* handle_address,
70-
IOTHUB_CLIENT_DEVICE_TWIN_CALLBACK device_twin_callback,
71-
ADUC_COMMUNICATION_MANAGER_CLIENT_HANDLE_UPDATED_CALLBACK client_handle_updated_callback,
72-
ADUC_PnPComponentClient_PropertyUpdate_Context *property_update_context
73-
);
72+
bool IoTHub_CommunicationManager_Init(
73+
ADUC_ClientHandle* handle_address,
74+
IOTHUB_CLIENT_DEVICE_TWIN_CALLBACK device_twin_callback,
75+
ADUC_COMMUNICATION_MANAGER_CLIENT_HANDLE_UPDATED_CALLBACK client_handle_updated_callback,
76+
ADUC_PnPComponentClient_PropertyUpdate_Context* property_update_context);
7477

7578
/**
7679
* @brief De-initialize the IoT Hub connection manager.

src/communication_managers/iothub_communication_manager/src/iothub_communication_manager.c

+13-6
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,8 @@ static bool ADUC_DeviceClient_Create(
346346
}
347347
else if (
348348
connInfo->clientCertificateString != NULL && connInfo->authType == ADUC_AuthType_X509
349-
&& (iothubResult = ClientHandle_SetOption(*outClientHandle, SU_OPTION_X509_CERT, connInfo->clientCertificateString))
349+
&& (iothubResult =
350+
ClientHandle_SetOption(*outClientHandle, SU_OPTION_X509_CERT, connInfo->clientCertificateString))
350351
!= IOTHUB_CLIENT_OK)
351352
{
352353
Log_Error("Unable to set client certificate, error=%d", iothubResult);
@@ -361,7 +362,8 @@ static bool ADUC_DeviceClient_Create(
361362
result = false;
362363
}
363364
else if (
364-
connInfo->certificateString != NULL && (connInfo->authType == ADUC_AuthType_NestedEdgeCert || connInfo->authType == ADUC_AuthType_X509)
365+
connInfo->certificateString != NULL
366+
&& (connInfo->authType == ADUC_AuthType_NestedEdgeCert || connInfo->authType == ADUC_AuthType_X509)
365367
&& (iothubResult = ClientHandle_SetOption(*outClientHandle, OPTION_TRUSTED_CERT, connInfo->certificateString))
366368
!= IOTHUB_CLIENT_OK)
367369
{
@@ -377,7 +379,8 @@ static bool ADUC_DeviceClient_Create(
377379
result = false;
378380
}
379381
else if (
380-
connInfo->opensslPrivateKey != NULL && ( connInfo->authType == ADUC_AuthType_SASCert || connInfo->authType == ADUC_AuthType_X509 )
382+
connInfo->opensslPrivateKey != NULL
383+
&& (connInfo->authType == ADUC_AuthType_SASCert || connInfo->authType == ADUC_AuthType_X509)
381384
&& (iothubResult =
382385
ClientHandle_SetOption(*outClientHandle, SU_OPTION_X509_PRIVATE_KEY, connInfo->opensslPrivateKey))
383386
!= IOTHUB_CLIENT_OK)
@@ -490,8 +493,11 @@ ADUC_ConnType GetConnTypeFromConnectionString(const char* connectionString)
490493
* @return true if connection info can be obtained
491494
*/
492495
bool GetConnectionInfoFromConnectionString(
493-
ADUC_ConnectionInfo* info, const char* connectionString,
494-
const char* const x509Cert, const char* const x509PrivateKey, const char* const x509CaCert)
496+
ADUC_ConnectionInfo* info,
497+
const char* connectionString,
498+
const char* const x509Cert,
499+
const char* const x509PrivateKey,
500+
const char* const x509CaCert)
495501
{
496502
bool succeeded = false;
497503
const ADUC_ConfigInfo* config = NULL;
@@ -649,7 +655,8 @@ bool GetAgentConfigInfo(ADUC_ConnectionInfo* info)
649655
}
650656
else if (strcmp(agent->connectionType, "X509") == 0)
651657
{
652-
if (!GetConnectionInfoFromConnectionString(info, agent->connectionData, agent->x509Cert, agent->x509PrivateKey, agent->x509CaCert))
658+
if (!GetConnectionInfoFromConnectionString(
659+
info, agent->connectionData, agent->x509Cert, agent->x509PrivateKey, agent->x509CaCert))
653660
{
654661
goto done;
655662
}

src/utils/config_utils/src/config_utils.c

+19-10
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
#include <aducpal/stdlib.h> // setenv
1515
#include <azure_c_shared_utility/crt_abstractions.h>
1616
#include <azure_c_shared_utility/strings_types.h>
17+
#include <errno.h>
1718
#include <parson.h>
1819
#include <parson_json_utils.h>
1920
#include <pthread.h>
2021
#include <stdbool.h>
2122
#include <stdlib.h>
2223
#include <string.h>
23-
#include <errno.h>
2424

2525
static pthread_mutex_t s_config_mutex = PTHREAD_MUTEX_INITIALIZER;
2626

@@ -68,8 +68,8 @@ static const char* INVALID_OR_MISSING_FIELD_ERROR_FMT = "Invalid json - '%s' mis
6868

6969
static void ADUC_AgentInfo_Free(ADUC_AgentInfo* agent);
7070

71-
72-
static char* ADUC_AgentInfo_Read_X509_File(const char* const x509_file_path) {
71+
static char* ADUC_AgentInfo_Read_X509_File(const char* const x509_file_path)
72+
{
7373
char* buffer = NULL;
7474
long ftellResult = 0;
7575
size_t bufferLength = 0;
@@ -118,7 +118,8 @@ static char* ADUC_AgentInfo_Read_X509_File(const char* const x509_file_path) {
118118
{
119119
Log_Error("Unexpected end of file while reading '%s' (bytesRead: %zu)!", x509_file_path, bytesRead);
120120
}
121-
else if (ferror(x509File)) {
121+
else if (ferror(x509File))
122+
{
122123
Log_Error("Error occurred while reading '%s' (bytesRead: %zu)!", x509_file_path, bytesRead);
123124
}
124125
else
@@ -191,8 +192,10 @@ static bool ADUC_AgentInfo_Init(ADUC_AgentInfo* agent, const JSON_Object* agent_
191192
connection_type = json_object_get_string(connection_source, CONFIG_CONNECTION_TYPE);
192193
connection_data = json_object_get_string(connection_source, CONFIG_CONNECTION_DATA);
193194
connection_x509_cert_file_path = json_object_get_string(connection_source, CONFIG_CONNECTION_X509_CERT_FILE_PATH);
194-
connection_x509_private_key_file_path = json_object_get_string(connection_source, CONFIG_CONNECTION_X509_PRIVATE_KEY_FILE_PATH);
195-
connection_x509_ca_cert_file_path = json_object_get_string(connection_source, CONFIG_CONNECTION_X509_CA_CERT_FILE_PATH);
195+
connection_x509_private_key_file_path =
196+
json_object_get_string(connection_source, CONFIG_CONNECTION_X509_PRIVATE_KEY_FILE_PATH);
197+
connection_x509_ca_cert_file_path =
198+
json_object_get_string(connection_source, CONFIG_CONNECTION_X509_CA_CERT_FILE_PATH);
196199

197200
// As these fields are mandatory, if any of the fields doesn't exist, the agent will fail to be constructed.
198201
if (name == NULL || runas == NULL || connection_type == NULL || connection_data == NULL || manufacturer == NULL
@@ -221,8 +224,11 @@ static bool ADUC_AgentInfo_Init(ADUC_AgentInfo* agent, const JSON_Object* agent_
221224
goto done;
222225
}
223226

224-
if (connection_x509_cert_file_path || connection_x509_private_key_file_path || connection_x509_ca_cert_file_path) {
225-
if(connection_x509_cert_file_path && connection_x509_private_key_file_path && connection_x509_ca_cert_file_path) {
227+
if (connection_x509_cert_file_path || connection_x509_private_key_file_path || connection_x509_ca_cert_file_path)
228+
{
229+
if (connection_x509_cert_file_path && connection_x509_private_key_file_path
230+
&& connection_x509_ca_cert_file_path)
231+
{
226232
agent->x509Cert = ADUC_AgentInfo_Read_X509_File(connection_x509_cert_file_path);
227233
if (!agent->x509Cert)
228234
{
@@ -238,8 +244,11 @@ static bool ADUC_AgentInfo_Init(ADUC_AgentInfo* agent, const JSON_Object* agent_
238244
{
239245
goto done;
240246
}
241-
} else {
242-
Log_Error("Incomplete X509 client certificate configuration! Cert file path or private key file path is missing.");
247+
}
248+
else
249+
{
250+
Log_Error(
251+
"Incomplete X509 client certificate configuration! Cert file path or private key file path is missing.");
243252
}
244253
}
245254

0 commit comments

Comments
 (0)