pw_status: Remove all-caps aliases

The all-caps aliases did not follow the style guide and may conflict
with macro names.

Change-Id: Ifcf48c0060bb89a1c88a7ecfb52d3ad7480680a4
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/24482
Commit-Queue: Wyatt Hepler <hepler@google.com>
Reviewed-by: Keir Mierle <keir@google.com>
diff --git a/pw_status/public/pw_status/status.h b/pw_status/public/pw_status/status.h
index 2629780..ae3b852 100644
--- a/pw_status/public/pw_status/status.h
+++ b/pw_status/public/pw_status/status.h
@@ -180,38 +180,6 @@
 
 }  // extern "C"
 
-// This header violates the Pigweed style guide! It declares constants that use
-// macro naming style, rather than constant naming style (kConstant). This is
-// done for readability and for consistency with Google's standard status codes
-// (e.g. as in gRPC).
-//
-// The problem is that the status code names might overlap with macro
-// definitions. To workaround this, this header undefines any macros with these
-// names.
-//
-// If your project relies on a macro with one of these names (e.g. INTERNAL),
-// make sure it is included after status.h so that the macro is defined.
-//
-// TODO(pwbug/268): Remove these #undefs after removing the names that violate
-//     the style guide.
-#undef OK
-#undef CANCELLED
-#undef UNKNOWN
-#undef INVALID_ARGUMENT
-#undef DEADLINE_EXCEEDED
-#undef NOT_FOUND
-#undef ALREADY_EXISTS
-#undef PERMISSION_DENIED
-#undef UNAUTHENTICATED
-#undef RESOURCE_EXHAUSTED
-#undef FAILED_PRECONDITION
-#undef ABORTED
-#undef OUT_OF_RANGE
-#undef UNIMPLEMENTED
-#undef INTERNAL
-#undef UNAVAILABLE
-#undef DATA_LOSS
-
 namespace pw {
 
 // The Status class is a thin, zero-cost abstraction around the pw_Status enum.
@@ -221,38 +189,8 @@
  public:
   using Code = pw_Status;
 
-  // All of the pw_Status codes are available in the Status class as, e.g.
-  // pw::OkStatus() or pw::Status::OutOfRange().
-  //
-  // These aliases are DEPRECATED -- prefer using the helper functions below.
-  // For example, change Status::CANCELLED to Status::Cancelled().
-  //
-  // TODO(pwbug/268): Migrate to the helper functions and remove these aliases.
-  // 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
-  [[deprecated("Use pw::OkStatus()"), nodiscard]] static constexpr Status Ok() {
-    return PW_STATUS_OK;
-  }
   [[nodiscard]] static constexpr Status Cancelled() {
     return PW_STATUS_CANCELLED;
   }
diff --git a/pw_status/public/pw_status/status_with_size.h b/pw_status/public/pw_status/status_with_size.h
index d48b0c7..48b1496 100644
--- a/pw_status/public/pw_status/status_with_size.h
+++ b/pw_status/public/pw_status/status_with_size.h
@@ -20,24 +20,6 @@
 
 namespace pw {
 
-class StatusWithSize;
-
-namespace internal {
-
-// TODO(pwbug/268): Remove this class after migrating to the helper functions.
-template <int kStatusShift>
-class StatusWithSizeConstant {
- private:
-  friend class ::pw::StatusWithSize;
-
-  explicit constexpr StatusWithSizeConstant(Status value)
-      : value_(static_cast<size_t>(value.code()) << kStatusShift) {}
-
-  const size_t value_;
-};
-
-}  // namespace internal
-
 // StatusWithSize stores a status and an unsigned integer. The integer must not
 // exceed StatusWithSize::max_size(), which is 134,217,727 (2**27 - 1) on 32-bit
 // systems.
@@ -64,49 +46,7 @@
 //      increases code size.
 //
 class StatusWithSize {
- private:
-  static constexpr size_t kStatusBits = 5;
-  static constexpr size_t kSizeMask = ~static_cast<size_t>(0) >> kStatusBits;
-  static constexpr size_t kStatusMask = ~kSizeMask;
-  static constexpr size_t kStatusShift = sizeof(size_t) * 8 - kStatusBits;
-
-  using Constant = internal::StatusWithSizeConstant<kStatusShift>;
-
  public:
-  // Non-OK StatusWithSizes can be constructed from these constants, such as:
-  //
-  //   StatusWithSize result = StatusWithSize::NotFound();
-  //
-  // These constants are DEPRECATED! Use the helper functions below instead. For
-  // example, change StatusWithSize::NotFound() to StatusWithSize::NotFound().
-  //
-  // TODO(pwbug/268): Migrate to the functions and remove these constants.
-  // 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.
-  [[deprecated(
-      "Use the StatusWithSize constructor")]] static constexpr StatusWithSize
-  Ok(size_t size) {
-    return StatusWithSize(size);
-  }
   static constexpr StatusWithSize Cancelled(size_t size = 0) {
     return StatusWithSize(Status::Cancelled(), size);
   }
@@ -170,9 +110,6 @@
       : StatusWithSize((static_cast<size_t>(status.code()) << kStatusShift) |
                        size) {}
 
-  // Allow implicit conversions from the StatusWithSize constants.
-  constexpr StatusWithSize(Constant constant) : size_(constant.value_) {}
-
   constexpr StatusWithSize(const StatusWithSize&) = default;
   constexpr StatusWithSize& operator=(const StatusWithSize&) = default;
 
@@ -240,6 +177,11 @@
   }
 
  private:
+  static constexpr size_t kStatusBits = 5;
+  static constexpr size_t kSizeMask = ~static_cast<size_t>(0) >> kStatusBits;
+  static constexpr size_t kStatusMask = ~kSizeMask;
+  static constexpr size_t kStatusShift = sizeof(size_t) * 8 - kStatusBits;
+
   size_t size_;
 };
 
diff --git a/pw_status/status_test.cc b/pw_status/status_test.cc
index 77bdd86..0bf72f5 100644
--- a/pw_status/status_test.cc
+++ b/pw_status/status_test.cc
@@ -12,26 +12,6 @@
 // License for the specific language governing permissions and limitations under
 // the License.
 
-// Make sure status works if these macros are defined.
-// TODO(pwbug/268): Remove these macros after migrating from these aliases.
-#define OK Uh oh, this macro is defined !
-#define CANCELLED Uh oh, this macro is defined !
-#define UNKNOWN Uh oh, this macro is defined !
-#define INVALID_ARGUMENT Uh oh, this macro is defined !
-#define DEADLINE_EXCEEDED Uh oh, this macro is defined !
-#define NOT_FOUND Uh oh, this macro is defined !
-#define ALREADY_EXISTS Uh oh, this macro is defined !
-#define PERMISSION_DENIED Uh oh, this macro is defined !
-#define UNAUTHENTICATED Uh oh, this macro is defined !
-#define RESOURCE_EXHAUSTED Uh oh, this macro is defined !
-#define FAILED_PRECONDITION Uh oh, this macro is defined !
-#define ABORTED Uh oh, this macro is defined !
-#define OUT_OF_RANGE Uh oh, this macro is defined !
-#define UNIMPLEMENTED Uh oh, this macro is defined !
-#define INTERNAL Uh oh, this macro is defined !
-#define UNAVAILABLE Uh oh, this macro is defined !
-#define DATA_LOSS Uh oh, this macro is defined !
-
 #include "pw_status/status.h"
 
 #include "gtest/gtest.h"
@@ -176,30 +156,6 @@
   EXPECT_STREQ("INVALID STATUS", Status(kInvalidCode).str());
 }
 
-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);
-  static_assert(PW_STATUS_INVALID_ARGUMENT == Status::INVALID_ARGUMENT);
-  static_assert(PW_STATUS_DEADLINE_EXCEEDED == Status::DEADLINE_EXCEEDED);
-  static_assert(PW_STATUS_NOT_FOUND == Status::NOT_FOUND);
-  static_assert(PW_STATUS_ALREADY_EXISTS == Status::ALREADY_EXISTS);
-  static_assert(PW_STATUS_PERMISSION_DENIED == Status::PERMISSION_DENIED);
-  static_assert(PW_STATUS_RESOURCE_EXHAUSTED == Status::RESOURCE_EXHAUSTED);
-  static_assert(PW_STATUS_FAILED_PRECONDITION == Status::FAILED_PRECONDITION);
-  static_assert(PW_STATUS_ABORTED == Status::ABORTED);
-  static_assert(PW_STATUS_OUT_OF_RANGE == Status::OUT_OF_RANGE);
-  static_assert(PW_STATUS_UNIMPLEMENTED == Status::UNIMPLEMENTED);
-  static_assert(PW_STATUS_INTERNAL == Status::INTERNAL);
-  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.
 extern "C" {