pw_status: Deprecate the all-caps aliases
Change-Id: If45e4be6f8b1691107fc540584ae7c1536235497
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/29263
Reviewed-by: Ewout van Bekkum <ewout@google.com>
Commit-Queue: Wyatt Hepler <hepler@google.com>
diff --git a/pw_status/public/pw_status/status.h b/pw_status/public/pw_status/status.h
index 33d0171..2629780 100644
--- a/pw_status/public/pw_status/status.h
+++ b/pw_status/public/pw_status/status.h
@@ -228,23 +228,25 @@
// For example, change Status::CANCELLED to Status::Cancelled().
//
// TODO(pwbug/268): Migrate to the helper functions and remove these aliases.
- static constexpr Code OK = PW_STATUS_OK;
- static constexpr Code CANCELLED = PW_STATUS_CANCELLED;
- static constexpr Code UNKNOWN = PW_STATUS_UNKNOWN;
- static constexpr Code INVALID_ARGUMENT = PW_STATUS_INVALID_ARGUMENT;
- static constexpr Code DEADLINE_EXCEEDED = PW_STATUS_DEADLINE_EXCEEDED;
- static constexpr Code NOT_FOUND = PW_STATUS_NOT_FOUND;
- static constexpr Code ALREADY_EXISTS = PW_STATUS_ALREADY_EXISTS;
- static constexpr Code PERMISSION_DENIED = PW_STATUS_PERMISSION_DENIED;
- static constexpr Code UNAUTHENTICATED = PW_STATUS_UNAUTHENTICATED;
- static constexpr Code RESOURCE_EXHAUSTED = PW_STATUS_RESOURCE_EXHAUSTED;
- static constexpr Code FAILED_PRECONDITION = PW_STATUS_FAILED_PRECONDITION;
- static constexpr Code ABORTED = PW_STATUS_ABORTED;
- static constexpr Code OUT_OF_RANGE = PW_STATUS_OUT_OF_RANGE;
- static constexpr Code UNIMPLEMENTED = PW_STATUS_UNIMPLEMENTED;
- static constexpr Code INTERNAL = PW_STATUS_INTERNAL;
- static constexpr Code UNAVAILABLE = PW_STATUS_UNAVAILABLE;
- static constexpr Code DATA_LOSS = PW_STATUS_DATA_LOSS;
+ // clang-format off
+ [[deprecated("Use pw::OkStatus()")]] static constexpr Code OK = PW_STATUS_OK;
+ [[deprecated("Use pw::Status::Cancelled()")]] static constexpr Code CANCELLED = PW_STATUS_CANCELLED;
+ [[deprecated("Use pw::Status::Unknown()")]] static constexpr Code UNKNOWN = PW_STATUS_UNKNOWN;
+ [[deprecated("Use pw::Status::InvalidArgument()")]] static constexpr Code INVALID_ARGUMENT = PW_STATUS_INVALID_ARGUMENT;
+ [[deprecated("Use pw::Status::DeadlineExceeded()")]] static constexpr Code DEADLINE_EXCEEDED = PW_STATUS_DEADLINE_EXCEEDED;
+ [[deprecated("Use pw::Status::NotFound()")]] static constexpr Code NOT_FOUND = PW_STATUS_NOT_FOUND;
+ [[deprecated("Use pw::Status::AlreadyExists()")]] static constexpr Code ALREADY_EXISTS = PW_STATUS_ALREADY_EXISTS;
+ [[deprecated("Use pw::Status::PermissionDenied()")]] static constexpr Code PERMISSION_DENIED = PW_STATUS_PERMISSION_DENIED;
+ [[deprecated("Use pw::Status::Unauthenticated()")]] static constexpr Code UNAUTHENTICATED = PW_STATUS_UNAUTHENTICATED;
+ [[deprecated("Use pw::Status::ResourceExhausted()")]] static constexpr Code RESOURCE_EXHAUSTED = PW_STATUS_RESOURCE_EXHAUSTED;
+ [[deprecated("Use pw::Status::FailedPrecondition()")]] static constexpr Code FAILED_PRECONDITION = PW_STATUS_FAILED_PRECONDITION;
+ [[deprecated("Use pw::Status::Aborted()")]] static constexpr Code ABORTED = PW_STATUS_ABORTED;
+ [[deprecated("Use pw::Status::OutOfRange()")]] static constexpr Code OUT_OF_RANGE = PW_STATUS_OUT_OF_RANGE;
+ [[deprecated("Use pw::Status::Unimplemented()")]] static constexpr Code UNIMPLEMENTED = PW_STATUS_UNIMPLEMENTED;
+ [[deprecated("Use pw::Status::Internal()")]] static constexpr Code INTERNAL = PW_STATUS_INTERNAL;
+ [[deprecated("Use pw::Status::Unavailable()")]] static constexpr Code UNAVAILABLE = PW_STATUS_UNAVAILABLE;
+ [[deprecated("Use pw::Status::DataLoss()")]] static constexpr Code DATA_LOSS = PW_STATUS_DATA_LOSS;
+ // clang-format on
// Functions that create a Status with the specified code.
// clang-format off
diff --git a/pw_status/public/pw_status/status_with_size.h b/pw_status/public/pw_status/status_with_size.h
index e305995..d48b0c7 100644
--- a/pw_status/public/pw_status/status_with_size.h
+++ b/pw_status/public/pw_status/status_with_size.h
@@ -81,22 +81,24 @@
// example, change StatusWithSize::NotFound() to StatusWithSize::NotFound().
//
// TODO(pwbug/268): Migrate to the functions and remove these constants.
- static constexpr Constant CANCELLED{Status::Cancelled()};
- static constexpr Constant UNKNOWN{Status::Unknown()};
- static constexpr Constant INVALID_ARGUMENT{Status::InvalidArgument()};
- static constexpr Constant DEADLINE_EXCEEDED{Status::DeadlineExceeded()};
- static constexpr Constant NOT_FOUND{Status::NotFound()};
- static constexpr Constant ALREADY_EXISTS{Status::AlreadyExists()};
- static constexpr Constant PERMISSION_DENIED{Status::PermissionDenied()};
- static constexpr Constant RESOURCE_EXHAUSTED{Status::ResourceExhausted()};
- static constexpr Constant FAILED_PRECONDITION{Status::FailedPrecondition()};
- static constexpr Constant ABORTED{Status::Aborted()};
- static constexpr Constant OUT_OF_RANGE{Status::OutOfRange()};
- static constexpr Constant UNIMPLEMENTED{Status::Unimplemented()};
- static constexpr Constant INTERNAL{Status::Internal()};
- static constexpr Constant UNAVAILABLE{Status::Unavailable()};
- static constexpr Constant DATA_LOSS{Status::DataLoss()};
- static constexpr Constant UNAUTHENTICATED{Status::Unauthenticated()};
+ // clang-format off
+ [[deprecated("Use pw::StatusWithSize::Cancelled()")]] static constexpr Constant CANCELLED{Status::Cancelled()};
+ [[deprecated("Use pw::StatusWithSize::Unknown()")]] static constexpr Constant UNKNOWN{Status::Unknown()};
+ [[deprecated("Use pw::StatusWithSize::InvalidArgument()")]] static constexpr Constant INVALID_ARGUMENT{Status::InvalidArgument()};
+ [[deprecated("Use pw::StatusWithSize::DeadlineExceeded()")]] static constexpr Constant DEADLINE_EXCEEDED{Status::DeadlineExceeded()};
+ [[deprecated("Use pw::StatusWithSize::NotFound()")]] static constexpr Constant NOT_FOUND{Status::NotFound()};
+ [[deprecated("Use pw::StatusWithSize::AlreadyExists()")]] static constexpr Constant ALREADY_EXISTS{Status::AlreadyExists()};
+ [[deprecated("Use pw::StatusWithSize::PermissionDenied()")]] static constexpr Constant PERMISSION_DENIED{Status::PermissionDenied()};
+ [[deprecated("Use pw::StatusWithSize::ResourceExhausted()")]] static constexpr Constant RESOURCE_EXHAUSTED{Status::ResourceExhausted()};
+ [[deprecated("Use pw::StatusWithSize::FailedPrecondition()")]] static constexpr Constant FAILED_PRECONDITION{Status::FailedPrecondition()};
+ [[deprecated("Use pw::StatusWithSize::Aborted()")]] static constexpr Constant ABORTED{Status::Aborted()};
+ [[deprecated("Use pw::StatusWithSize::OutOfRange()")]] static constexpr Constant OUT_OF_RANGE{Status::OutOfRange()};
+ [[deprecated("Use pw::StatusWithSize::Unimplemented()")]] static constexpr Constant UNIMPLEMENTED{Status::Unimplemented()};
+ [[deprecated("Use pw::StatusWithSize::Internal()")]] static constexpr Constant INTERNAL{Status::Internal()};
+ [[deprecated("Use pw::StatusWithSize::Unavailable()")]] static constexpr Constant UNAVAILABLE{Status::Unavailable()};
+ [[deprecated("Use pw::StatusWithSize::DataLoss()")]] static constexpr Constant DATA_LOSS{Status::DataLoss()};
+ [[deprecated("Use pw::StatusWithSize::Unauthenticated()")]] static constexpr Constant UNAUTHENTICATED{Status::Unauthenticated()};
+ // clang-format on
// Functions that create a StatusWithSize with the specified status code. For
// codes other than OK, the size defaults to 0.
diff --git a/pw_status/status_test.cc b/pw_status/status_test.cc
index d28017c..77bdd86 100644
--- a/pw_status/status_test.cc
+++ b/pw_status/status_test.cc
@@ -178,6 +178,8 @@
TEST(Status, DeprecatedAliases) {
// TODO(pwbug/268): Remove this test after migrating from these aliases.
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
static_assert(PW_STATUS_OK == OkStatus());
static_assert(PW_STATUS_CANCELLED == Status::CANCELLED);
static_assert(PW_STATUS_UNKNOWN == Status::UNKNOWN);
@@ -195,6 +197,7 @@
static_assert(PW_STATUS_UNAVAILABLE == Status::UNAVAILABLE);
static_assert(PW_STATUS_DATA_LOSS == Status::DATA_LOSS);
static_assert(PW_STATUS_UNAUTHENTICATED == Status::UNAUTHENTICATED);
+#pragma GCC diagnostic pop
}
// Functions for executing the C pw_Status tests.