Skip to content

Commit

Permalink
Fix formatting wrt clanng format
Browse files Browse the repository at this point in the history
  • Loading branch information
tony-josi-aws committed Nov 20, 2024
1 parent f9fc03d commit 0e3ee43
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 47 deletions.
45 changes: 15 additions & 30 deletions source/fleetprovisioning/FleetProvisioning.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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());
Expand All @@ -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(
Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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());
Expand All @@ -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(
Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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());
Expand All @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions source/fleetprovisioning/FleetProvisioning.h
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,6 @@ namespace Aws
bool ObtainCertificateSerialID(const char *certPath);
};
} // namespace FleetProvisioningNS
} // namespace DeviceClient
} // namespace Iot
} // namespace DeviceClient
} // namespace Iot
} // namespace Aws
21 changes: 8 additions & 13 deletions source/jobs/JobsFeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<mutex> leakLock(updateJobExecutionPromisesLock);
for (auto keyPromise = updateJobExecutionPromises.cbegin(); keyPromise != updateJobExecutionPromises.cend();
Expand Down Expand Up @@ -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();
}

Expand All @@ -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);
Expand Down Expand Up @@ -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())
{
Expand Down Expand Up @@ -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())
{
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions source/jobs/JobsFeature.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,8 @@ namespace Aws
virtual std::shared_ptr<JobEngine> createJobEngine();
};
} // namespace Jobs
} // namespace DeviceClient
} // namespace Iot
} // namespace DeviceClient
} // namespace Iot
} // namespace Aws

#endif // DEVICE_CLIENT_JOBSFEATURE_H

0 comments on commit 0e3ee43

Please sign in to comment.