From 0e3ee43d3ac7cac8f1ff4ef84d42f300c7ef8236 Mon Sep 17 00:00:00 2001 From: tony-josi-aws Date: Wed, 20 Nov 2024 13:34:26 +0530 Subject: [PATCH] Fix formatting wrt clanng format --- .../fleetprovisioning/FleetProvisioning.cpp | 45 +++++++------------ source/fleetprovisioning/FleetProvisioning.h | 4 +- source/jobs/JobsFeature.cpp | 21 ++++----- source/jobs/JobsFeature.h | 4 +- 4 files changed, 27 insertions(+), 47 deletions(-) diff --git a/source/fleetprovisioning/FleetProvisioning.cpp b/source/fleetprovisioning/FleetProvisioning.cpp index b815536f..3d6c7575 100644 --- a/source/fleetprovisioning/FleetProvisioning.cpp +++ b/source/fleetprovisioning/FleetProvisioning.cpp @@ -120,8 +120,7 @@ bool FleetProvisioning::WriteCSRCertToDirectory(CreateCertificateFromCsrResponse bool FleetProvisioning::CreateCertificateAndKey(Iotidentity::IotIdentityClient identityClient) { LOG_INFO(TAG, "Provisioning new device certificate and private key using CreateKeysAndCertificate API"); - auto onKeysAcceptedSubAck = [this](int ioErr) - { + auto onKeysAcceptedSubAck = [this](int ioErr) { if (ioErr != AWS_OP_SUCCESS) { LOGM_ERROR( @@ -133,8 +132,7 @@ bool FleetProvisioning::CreateCertificateAndKey(Iotidentity::IotIdentityClient i keysAcceptedCompletedPromise.set_value(ioErr == AWS_OP_SUCCESS); }; - auto onKeysRejectedSubAck = [this](int ioErr) - { + auto onKeysRejectedSubAck = [this](int ioErr) { if (ioErr != AWS_OP_SUCCESS) { LOGM_ERROR( @@ -146,8 +144,7 @@ bool FleetProvisioning::CreateCertificateAndKey(Iotidentity::IotIdentityClient i keysRejectedCompletedPromise.set_value(ioErr == AWS_OP_SUCCESS); }; - auto onKeysPublishSubAck = [this](int ioErr) - { + auto onKeysPublishSubAck = [this](int ioErr) { if (ioErr != AWS_OP_SUCCESS) { LOGM_ERROR( @@ -159,8 +156,7 @@ bool FleetProvisioning::CreateCertificateAndKey(Iotidentity::IotIdentityClient i keysPublishCompletedPromise.set_value(ioErr == AWS_OP_SUCCESS); }; - auto onKeysAccepted = [this](CreateKeysAndCertificateResponse *response, int ioErr) - { + auto onKeysAccepted = [this](CreateKeysAndCertificateResponse *response, int ioErr) { if (ioErr == AWS_OP_SUCCESS) { LOGM_INFO(TAG, "CreateKeysAndCertificateResponse certificateId: %s.", response->CertificateId->c_str()); @@ -181,8 +177,7 @@ bool FleetProvisioning::CreateCertificateAndKey(Iotidentity::IotIdentityClient i } }; - auto onKeysRejected = [this](ErrorResponse *error, int ioErr) - { + auto onKeysRejected = [this](ErrorResponse *error, int ioErr) { if (ioErr == AWS_OP_SUCCESS) { LOGM_ERROR( @@ -257,8 +252,7 @@ bool FleetProvisioning::CreateCertificateAndKey(Iotidentity::IotIdentityClient i bool FleetProvisioning::CreateCertificateUsingCSR(Iotidentity::IotIdentityClient identityClient) { LOG_INFO(TAG, "Provisioning new device certificate using CreateCertificateFromCsr API"); - auto onCsrAcceptedSubAck = [this](int ioErr) - { + auto onCsrAcceptedSubAck = [this](int ioErr) { if (ioErr != AWS_OP_SUCCESS) { LOGM_ERROR( @@ -270,8 +264,7 @@ bool FleetProvisioning::CreateCertificateUsingCSR(Iotidentity::IotIdentityClient csrAcceptedCompletedPromise.set_value(ioErr == AWS_OP_SUCCESS); }; - auto onCsrRejectedSubAck = [this](int ioErr) - { + auto onCsrRejectedSubAck = [this](int ioErr) { if (ioErr != AWS_OP_SUCCESS) { LOGM_ERROR( @@ -283,8 +276,7 @@ bool FleetProvisioning::CreateCertificateUsingCSR(Iotidentity::IotIdentityClient csrRejectedCompletedPromise.set_value(ioErr == AWS_OP_SUCCESS); }; - auto onCsrPublishSubAck = [this](int ioErr) - { + auto onCsrPublishSubAck = [this](int ioErr) { if (ioErr != AWS_OP_SUCCESS) { LOGM_ERROR( @@ -296,8 +288,7 @@ bool FleetProvisioning::CreateCertificateUsingCSR(Iotidentity::IotIdentityClient csrPublishCompletedPromise.set_value(ioErr == AWS_OP_SUCCESS); }; - auto onCsrAccepted = [this](CreateCertificateFromCsrResponse *response, int ioErr) - { + auto onCsrAccepted = [this](CreateCertificateFromCsrResponse *response, int ioErr) { if (ioErr == AWS_OP_SUCCESS) { LOGM_INFO(TAG, "CreateCertificateFromCsrResponse certificateId: %s. ***", response->CertificateId->c_str()); @@ -318,8 +309,7 @@ bool FleetProvisioning::CreateCertificateUsingCSR(Iotidentity::IotIdentityClient } }; - auto onCsrRejected = [this](ErrorResponse *error, int ioErr) - { + auto onCsrRejected = [this](ErrorResponse *error, int ioErr) { if (ioErr == AWS_OP_SUCCESS) { LOGM_ERROR( @@ -397,8 +387,7 @@ bool FleetProvisioning::CreateCertificateUsingCSR(Iotidentity::IotIdentityClient } bool FleetProvisioning::RegisterThing(Iotidentity::IotIdentityClient identityClient) { - auto onRegisterAcceptedSubAck = [this](int ioErr) - { + auto onRegisterAcceptedSubAck = [this](int ioErr) { if (ioErr != AWS_OP_SUCCESS) { LOGM_ERROR( @@ -410,8 +399,7 @@ bool FleetProvisioning::RegisterThing(Iotidentity::IotIdentityClient identityCli registerAcceptedCompletedPromise.set_value(ioErr == AWS_OP_SUCCESS); }; - auto onRegisterRejectedSubAck = [this](int ioErr) - { + auto onRegisterRejectedSubAck = [this](int ioErr) { if (ioErr != AWS_OP_SUCCESS) { LOGM_ERROR( @@ -423,8 +411,7 @@ bool FleetProvisioning::RegisterThing(Iotidentity::IotIdentityClient identityCli registerRejectedCompletedPromise.set_value(ioErr == AWS_OP_SUCCESS); }; - auto onRegisterPublishSubAck = [this](int ioErr) - { + auto onRegisterPublishSubAck = [this](int ioErr) { if (ioErr != AWS_OP_SUCCESS) { LOGM_ERROR( @@ -436,8 +423,7 @@ bool FleetProvisioning::RegisterThing(Iotidentity::IotIdentityClient identityCli registerPublishCompletedPromise.set_value(ioErr == AWS_OP_SUCCESS); }; - auto onRegisterAccepted = [this](RegisterThingResponse *response, int ioErr) - { + auto onRegisterAccepted = [this](RegisterThingResponse *response, int ioErr) { if (ioErr == AWS_OP_SUCCESS) { LOGM_INFO(TAG, "RegisterThingResponse ThingName: %s.", response->ThingName->c_str()); @@ -452,8 +438,7 @@ bool FleetProvisioning::RegisterThing(Iotidentity::IotIdentityClient identityCli registerThingCompletedPromise.set_value(ioErr == AWS_OP_SUCCESS); }; - auto onRegisterRejected = [this](ErrorResponse *error, int ioErr) - { + auto onRegisterRejected = [this](ErrorResponse *error, int ioErr) { if (ioErr == AWS_OP_SUCCESS) { LOGM_ERROR( diff --git a/source/fleetprovisioning/FleetProvisioning.h b/source/fleetprovisioning/FleetProvisioning.h index 57982000..1bcfc3e5 100644 --- a/source/fleetprovisioning/FleetProvisioning.h +++ b/source/fleetprovisioning/FleetProvisioning.h @@ -278,6 +278,6 @@ namespace Aws bool ObtainCertificateSerialID(const char *certPath); }; } // namespace FleetProvisioningNS - } // namespace DeviceClient - } // namespace Iot + } // namespace DeviceClient + } // namespace Iot } // namespace Aws diff --git a/source/jobs/JobsFeature.cpp b/source/jobs/JobsFeature.cpp index 0b00048a..bb2d6666 100644 --- a/source/jobs/JobsFeature.cpp +++ b/source/jobs/JobsFeature.cpp @@ -425,8 +425,7 @@ void JobsFeature::publishUpdateJobExecutionStatusWithRetry( retryConfig.needStopFlag = nullptr; } - auto publishLambda = [this, data, statusInfo, statusDetails]() -> bool - { + auto publishLambda = [this, data, statusInfo, statusDetails]() -> bool { // We first need to make sure that we haven't previously leaked any promises into our map unique_lock leakLock(updateJobExecutionPromisesLock); for (auto keyPromise = updateJobExecutionPromises.cbegin(); keyPromise != updateJobExecutionPromises.cend(); @@ -514,9 +513,9 @@ void JobsFeature::publishUpdateJobExecutionStatusWithRetry( this->updateJobExecutionPromises.erase(clientToken.c_str()); return finished; }; - std::thread updateJobExecutionThread( - [retryConfig, publishLambda, onCompleteCallback] - { Retry::exponentialBackoff(retryConfig, publishLambda, onCompleteCallback); }); + std::thread updateJobExecutionThread([retryConfig, publishLambda, onCompleteCallback] { + Retry::exponentialBackoff(retryConfig, publishLambda, onCompleteCallback); + }); updateJobExecutionThread.detach(); } @@ -537,8 +536,7 @@ bool JobsFeature::compareJobDocuments(const Aws::Crt::JsonObject &job1, const Aw std::regex s3UrlRegex(R"((https://[^.\s"]+\.s3[.-](?:[^.\s"]+\.)?amazonaws\.com/[^?\s"]+)(\?[^"\s]+)?)"); // Function to replace only the pre-signed portion of S3 URLs - auto processPresignedUrls = [&s3UrlRegex](std::string &s) -> int - { + auto processPresignedUrls = [&s3UrlRegex](std::string &s) -> int { int count = 0; std::string result; std::sregex_iterator it(s.begin(), s.end(), s3UrlRegex); @@ -610,8 +608,7 @@ bool JobsFeature::isDuplicateNotification(JobExecutionData job) void JobsFeature::initJob(const JobExecutionData &job) { - auto shutdownHandler = [this]() -> void - { + auto shutdownHandler = [this]() -> void { handlingJob.store(false); if (needStop.load()) { @@ -642,8 +639,7 @@ void JobsFeature::executeJob(const Iotjobs::JobExecutionData &job, const PlainJo { LOGM_INFO(TAG, "Executing job: %s", job.JobId->c_str()); - auto shutdownHandler = [this]() -> void - { + auto shutdownHandler = [this]() -> void { handlingJob.store(false); if (needStop.load()) { @@ -652,8 +648,7 @@ void JobsFeature::executeJob(const Iotjobs::JobExecutionData &job, const PlainJo } }; // TODO: Add support for checking condition - auto runJob = [this, job, jobDocument, shutdownHandler]() - { + auto runJob = [this, job, jobDocument, shutdownHandler]() { auto engine = createJobEngine(); // execute all action steps in sequence as provided in job document int executionStatus = engine->exec_steps(jobDocument, jobHandlerDir); diff --git a/source/jobs/JobsFeature.h b/source/jobs/JobsFeature.h index 05786afc..1dcf7a6d 100644 --- a/source/jobs/JobsFeature.h +++ b/source/jobs/JobsFeature.h @@ -339,8 +339,8 @@ namespace Aws virtual std::shared_ptr createJobEngine(); }; } // namespace Jobs - } // namespace DeviceClient - } // namespace Iot + } // namespace DeviceClient + } // namespace Iot } // namespace Aws #endif // DEVICE_CLIENT_JOBSFEATURE_H