Skip to content

Commit

Permalink
reworking example code to avoid compiler warning (#23297)
Browse files Browse the repository at this point in the history
* reworking example code to avoid compiler warning

* Restyled by clang-format

Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Jul 31, 2023
1 parent b496a57 commit 4602121
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 31 deletions.
29 changes: 13 additions & 16 deletions examples/lighting-app/infineon/psoc6/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,18 +305,18 @@ void AppTask::AppTaskMain(void * pvParameter)

void AppTask::LightActionEventHandler(AppEvent * event)
{
bool initiated = false;
LightingManager::Action_t action;
int32_t actor = 0;
CHIP_ERROR err = CHIP_NO_ERROR;
int32_t actor;

if (event->Type == AppEvent::kEventType_Light)
switch (event->Type)
{
case AppEvent::kEventType_Light: {
action = static_cast<LightingManager::Action_t>(event->LightEvent.Action);
actor = event->LightEvent.Actor;
break;
}
else if (event->Type == AppEvent::kEventType_Button)
{

case AppEvent::kEventType_Button: {
if (LightMgr().IsLightOn())
{
action = LightingManager::OFF_ACTION;
Expand All @@ -325,21 +325,18 @@ void AppTask::LightActionEventHandler(AppEvent * event)
{
action = LightingManager::ON_ACTION;
}

actor = AppEvent::kEventType_Button;
break;
}
else
{
err = APP_ERROR_UNHANDLED_EVENT;

default:
return;
}

if (err == CHIP_NO_ERROR)
if (!LightMgr().InitiateAction(actor, action))
{
initiated = LightMgr().InitiateAction(actor, action);

if (!initiated)
{
P6_LOG("Action is already in progress or active.");
}
P6_LOG("Action is already in progress or active.");
}
}

Expand Down
27 changes: 12 additions & 15 deletions examples/lock-app/infineon/psoc6/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,18 +388,18 @@ void AppTask::AppTaskMain(void * pvParameter)

void AppTask::LockActionEventHandler(AppEvent * event)
{
bool initiated = false;
LockManager::Action_t action;
int32_t actor;
CHIP_ERROR err = CHIP_NO_ERROR;

if (event->Type == AppEvent::kEventType_Lock)
switch (event->Type)
{
case AppEvent::kEventType_Lock: {
action = static_cast<LockManager::Action_t>(event->LockEvent.Action);
actor = event->LockEvent.Actor;
break;
}
else if (event->Type == AppEvent::kEventType_Button)
{

case AppEvent::kEventType_Button: {
if (LockMgr().NextState() == true)
{
action = LockManager::LOCK_ACTION;
Expand All @@ -408,21 +408,18 @@ void AppTask::LockActionEventHandler(AppEvent * event)
{
action = LockManager::UNLOCK_ACTION;
}

actor = AppEvent::kEventType_Button;
break;
}
else
{
err = APP_ERROR_UNHANDLED_EVENT;

default:
return;
}

if (err == CHIP_NO_ERROR)
if (!LockMgr().InitiateAction(actor, action))
{
initiated = LockMgr().InitiateAction(actor, action);

if (!initiated)
{
P6_LOG("Action is already in progress or active.");
}
P6_LOG("Action is already in progress or active.");
}
}

Expand Down

0 comments on commit 4602121

Please sign in to comment.