Skip to content

Commit

Permalink
Clean up temporary error code macros added in PR#7916 (project-chip#8119
Browse files Browse the repository at this point in the history
)

* #### Problem

PR project-chip#7916 _Consolidate error types_ included some temporary
definitions to avoid breaking any PRs in flight.

#### Change overview

- Removed the temporary definitions.
- Updated names in recent PRs.

#### Testing

No changes to functionality.

* missed esp32 example

* missed Mbed mutex

* missed chip-tool and more Mbed
  • Loading branch information
kpschoedel authored and Nikita committed Sep 23, 2021
1 parent c8cd5fe commit c4097ef
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 78 deletions.
2 changes: 1 addition & 1 deletion examples/all-clusters-app/esp32/main/DeviceCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ void DeviceCallbacks::OnLevelControlAttributeChangeCallback(EndpointId endpointI
return;
}

void IdentifyTimerHandler(Layer * systemLayer, void * appState, Error error)
void IdentifyTimerHandler(Layer * systemLayer, void * appState, CHIP_ERROR error)
{
statusLED1.Animate();

Expand Down
2 changes: 1 addition & 1 deletion examples/chip-tool/commands/common/Command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ void Command::WaitForResponse(uint16_t seconds)

#else // CONFIG_USE_SEPARATE_EVENTLOOP

static void OnResponseTimeout(chip::System::Layer *, void *, chip::System::Error)
static void OnResponseTimeout(chip::System::Layer *, void *, CHIP_ERROR)
{
ChipLogError(chipTool, "No response from device");

Expand Down
14 changes: 0 additions & 14 deletions src/ble/BleError.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,20 +310,6 @@
* @}
*/

// !!!!! IMPORTANT !!!!!
// These definitions are present temporarily in order to reduce breakage for PRs in flight.
// TODO: remove compatibility definitions
#define BLE_ERROR CHIP_ERROR
#define BLE_NO_ERROR CHIP_NO_ERROR
#define BLE_ERROR_BAD_ARGS CHIP_ERROR_INVALID_ARGUMENT
#define BLE_ERROR_INCORRECT_STATE CHIP_ERROR_INCORRECT_STATE
#define BLE_ERROR_MESSAGE_INCOMPLETE CHIP_ERROR_MESSAGE_INCOMPLETE
#define BLE_ERROR_NOT_IMPLEMENTED CHIP_ERROR_NOT_IMPLEMENTED
#define BLE_ERROR_NO_ENDPOINTS CHIP_ERROR_ENDPOINT_POOL_FULL
#define BLE_ERROR_NO_MEMORY CHIP_ERROR_NO_MEMORY
#define BLE_ERROR_OUTBOUND_MESSAGE_TOO_BIG CHIP_ERROR_OUTBOUND_MESSAGE_TOO_BIG
#define BLE_ERROR_RECEIVED_MESSAGE_TOO_BIG CHIP_ERROR_INBOUND_MESSAGE_TOO_BIG

// clang-format on

namespace chip {
Expand Down
4 changes: 2 additions & 2 deletions src/inet/IPEndPointBasis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1424,7 +1424,7 @@ CHIP_ERROR IPEndPointBasis::StartListener()
case nw_listener_state_cancelled:
ChipLogDetail(Inet, "Listener: Cancelled");
if (res == CHIP_NO_ERROR)
res = INET_ERROR_CONNECTION_ABORTED;
res = CHIP_ERROR_CONNECTION_ABORTED;

dispatch_semaphore_signal(mListenerSemaphore);
break;
Expand Down Expand Up @@ -1480,7 +1480,7 @@ CHIP_ERROR IPEndPointBasis::StartConnection(nw_connection_t & aConnection)
case nw_connection_state_cancelled:
ChipLogDetail(Inet, "Connection: Cancelled");
if (res == CHIP_NO_ERROR)
res = INET_ERROR_CONNECTION_ABORTED;
res = CHIP_ERROR_CONNECTION_ABORTED;

dispatch_semaphore_signal(mConnectionSemaphore);
break;
Expand Down
16 changes: 0 additions & 16 deletions src/inet/InetError.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,22 +236,6 @@
* @}
*/

// !!!!! IMPORTANT !!!!!
// These definitions are present temporarily in order to reduce breakage for PRs in flight.
// TODO: remove compatibility definitions
#define INET_ERROR CHIP_ERROR
#define INET_NO_ERROR CHIP_NO_ERROR
#define INET_ERROR_BAD_ARGS CHIP_ERROR_INVALID_ARGUMENT
#define INET_ERROR_INBOUND_MESSAGE_TOO_BIG CHIP_ERROR_INBOUND_MESSAGE_TOO_BIG
#define INET_ERROR_INCORRECT_STATE CHIP_ERROR_INCORRECT_STATE
#define INET_ERROR_MESSAGE_TOO_LONG CHIP_ERROR_MESSAGE_TOO_LONG
#define INET_ERROR_NO_CONNECTION_HANDLER CHIP_ERROR_NO_CONNECTION_HANDLER
#define INET_ERROR_NO_ENDPOINTS CHIP_ERROR_ENDPOINT_POOL_FULL
#define INET_ERROR_NOT_IMPLEMENTED CHIP_ERROR_NOT_IMPLEMENTED
#define INET_ERROR_NOT_SUPPORTED CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE
#define INET_ERROR_NO_MEMORY CHIP_ERROR_NO_MEMORY
#define INET_ERROR_CONNECTION_ABORTED CHIP_ERROR_CONNECTION_ABORTED

// clang-format on

namespace chip {
Expand Down
6 changes: 0 additions & 6 deletions src/lib/asn1/ASN1Error.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,6 @@ namespace ASN1 {
* @}
*/

// !!!!! IMPORTANT !!!!!
// These definitions are present temporarily in order to reduce breakage for PRs in flight.
// TODO: remove compatibility definitions
#define ASN1_ERROR CHIP_ERROR
#define ASN1_NO_ERROR CHIP_NO_ERROR

// clang-format on

bool FormatASN1Error(char * buf, uint16_t bufSize, int32_t err);
Expand Down
2 changes: 1 addition & 1 deletion src/messaging/tests/TestReliableMessageProtocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ void CheckDuplicateMessage(nlTestSuite * inSuite, void * inContext)

// 1 tick is 64 ms, sleep 65 ms to trigger first re-transmit
test_os_sleep_ms(65);
ReliableMessageMgr::Timeout(&ctx.GetSystemLayer(), rm, CHIP_SYSTEM_NO_ERROR);
ReliableMessageMgr::Timeout(&ctx.GetSystemLayer(), rm, CHIP_NO_ERROR);

// Ensure the retransmit message was sent and the ack was sent
// and retransmit table was cleared
Expand Down
6 changes: 0 additions & 6 deletions src/platform/mbed/BLEManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,6 @@
// Show BLE status with LEDs
#define _BLEMGRIMPL_USE_LEDS 0

/* Undefine the BLE_ERROR_NOT_IMPLEMENTED macro provided by CHIP's
* src/ble/BleError.h to avoid a name conflict with Mbed-OS ble_error_t
* enum value. For the enum values, see:
* mbed-os/connectivity/FEATURE_BLE/include/ble/common/blecommon.h
*/
#undef BLE_ERROR_NOT_IMPLEMENTED
// mbed-os headers
#include "ble/BLE.h"
#include "ble/Gap.h"
Expand Down
28 changes: 14 additions & 14 deletions src/platform/mbed/SystemTimeSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,54 +60,54 @@ uint64_t GetClock_MonotonicHiRes()

// Platform-specific function for getting the current real (civil) time in microsecond Unix time format,
// where |curTime| argument is the current time, expressed as Unix time scaled to microseconds.
// Returns CHIP_SYSTEM_NO_ERROR if the method succeeded.
Error GetClock_RealTime(uint64_t & curTime)
// Returns CHIP_NO_ERROR if the method succeeded.
CHIP_ERROR GetClock_RealTime(uint64_t & curTime)
{
struct timeval tv;
int res = gettimeofday(&tv, NULL);
if (res != 0)
{
return CHIP_SYSTEM_ERROR_UNEXPECTED_STATE;
return CHIP_ERROR_INCORRECT_STATE;
}
if (tv.tv_sec < CHIP_SYSTEM_CONFIG_VALID_REAL_TIME_THRESHOLD)
{
return CHIP_SYSTEM_ERROR_REAL_TIME_NOT_SYNCED;
return CHIP_ERROR_REAL_TIME_NOT_SYNCED;
}
curTime = (tv.tv_sec * UINT64_C(1000000)) + tv.tv_usec;
return CHIP_SYSTEM_NO_ERROR;
return CHIP_NO_ERROR;
}

// Platform-specific function for getting the current real (civil) time in millisecond Unix time
// where |curTimeMS| is the current time, expressed as Unix time scaled to milliseconds.
// Returns CHIP_SYSTEM_NO_ERROR if the method succeeded.
Error GetClock_RealTimeMS(uint64_t & curTimeMS)
// Returns CHIP_NO_ERROR if the method succeeded.
CHIP_ERROR GetClock_RealTimeMS(uint64_t & curTimeMS)
{
struct timeval tv;
int res = gettimeofday(&tv, NULL);
if (res != 0)
{
return CHIP_SYSTEM_ERROR_UNEXPECTED_STATE;
return CHIP_ERROR_INCORRECT_STATE;
}
if (tv.tv_sec < CHIP_SYSTEM_CONFIG_VALID_REAL_TIME_THRESHOLD)
{
return CHIP_SYSTEM_ERROR_REAL_TIME_NOT_SYNCED;
return CHIP_ERROR_REAL_TIME_NOT_SYNCED;
}
curTimeMS = (tv.tv_sec * UINT64_C(1000)) + (tv.tv_usec / 1000);
return CHIP_SYSTEM_NO_ERROR;
return CHIP_NO_ERROR;
}

// Platform-specific function for setting the current real (civil) time
// where |newCurTime| is the new current time, expressed as Unix time scaled to microseconds.
// Returns CHIP_SYSTEM_NO_ERROR if the method succeeded.
Error SetClock_RealTime(uint64_t newCurTime)
// Returns CHIP_NO_ERROR if the method succeeded.
CHIP_ERROR SetClock_RealTime(uint64_t newCurTime)
{
struct timeval tv;
tv.tv_sec = static_cast<time_t>(newCurTime / UINT64_C(1000000));
tv.tv_usec = static_cast<long>(newCurTime % UINT64_C(1000000));
int res = settimeofday(&tv, NULL);
if (res != 0)
{
return CHIP_SYSTEM_ERROR_UNEXPECTED_STATE;
return CHIP_ERROR_INCORRECT_STATE;
}
#if CHIP_PROGRESS_LOGGING
{
Expand All @@ -120,7 +120,7 @@ Error SetClock_RealTime(uint64_t newCurTime)
tv.tv_sec, year, month, dayOfMonth, hour, minute, second);
}
#endif // CHIP_PROGRESS_LOGGING
return CHIP_SYSTEM_NO_ERROR;
return CHIP_NO_ERROR;
}

} // namespace Layer
Expand Down
15 changes: 0 additions & 15 deletions src/system/SystemError.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,6 @@ extern bool FormatLwIPError(char * buf, uint16_t bufSize, CHIP_ERROR err);

// clang-format off

// !!!!! IMPORTANT !!!!!
// These definitions are present temporarily in order to reduce breakage for PRs in flight.
// TODO: remove compatibility definitions
using Error = CHIP_ERROR;
#define CHIP_SYSTEM_NO_ERROR CHIP_NO_ERROR
#define CHIP_SYSTEM_ERROR_ACCESS_DENIED CHIP_ERROR_ACCESS_DENIED
#define CHIP_SYSTEM_ERROR_BAD_ARGS CHIP_ERROR_INVALID_ARGUMENT
#define CHIP_SYSTEM_ERROR_NOT_SUPPORTED CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE
#define CHIP_SYSTEM_ERROR_NO_MEMORY CHIP_ERROR_NO_MEMORY
#define CHIP_SYSTEM_ERROR_REAL_TIME_NOT_SYNCED CHIP_ERROR_REAL_TIME_NOT_SYNCED
#define CHIP_SYSTEM_ERROR_UNEXPECTED_EVENT CHIP_ERROR_UNEXPECTED_EVENT
#define CHIP_SYSTEM_ERROR_UNEXPECTED_STATE CHIP_ERROR_INCORRECT_STATE

// clang-format on

} // namespace System
} // namespace chip

Expand Down
4 changes: 2 additions & 2 deletions src/system/SystemMutex.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,11 @@ inline void Mutex::Unlock(void)
#endif // CHIP_SYSTEM_CONFIG_FREERTOS_LOCKING

#if CHIP_SYSTEM_CONFIG_MBED_LOCKING
inline Error Mutex::Init(Mutex & aMutex)
inline CHIP_ERROR Mutex::Init(Mutex & aMutex)
{
// The mutex is initialized when constructed and generates
// a runtime error in case of failure.
return CHIP_SYSTEM_NO_ERROR;
return CHIP_NO_ERROR;
}

inline void Mutex::Lock()
Expand Down

0 comments on commit c4097ef

Please sign in to comment.