From 237e5f2c48cf6933200ec6efdbd371271f3ce3ed Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Fri, 3 May 2024 11:18:51 -0400 Subject: [PATCH] ccv: rename error type enumerators In the names of enumerators: - Replace "other" with "unknown" when referring to origins in clock correlation validator error types. The origin of a clock class is either known or unknown. As of MIP 0, the only way for a clock class origin to be known is for it to be the Unix epoch, so it's really either Unix epoch or unknown. With MIP 1, it will become possible to have known origins that are not the Unix epoch. Using the term "unknown" here makes it clear that we are not talking about that. - Replace "origin uuid" with "origin unknown with uuid", "origin no uuid" with "origin unknown without uuid". The formers make it sound like the origins have UUIDs, which is not the case. The clock class (which is implied in the name) has a UUID. - Make the enumerators extra explicit to avoid any ambiguity. Change-Id: I4e9f9e6caf4e09de2ff1a2d26fe10a1a5f343453 Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/12783 Reviewed-by: Philippe Proulx Tested-by: jenkins --- .../clock-correlation-validator.cpp | 57 +++++++++++-------- .../clock-correlation-validator.h | 19 ++++--- .../clock-correlation-validator.hpp | 43 +++++++------- src/lib/graph/iterator.c | 16 +++--- src/plugins/utils/muxer/msg-iter.cpp | 16 +++--- 5 files changed, 82 insertions(+), 69 deletions(-) diff --git a/src/clock-correlation-validator/clock-correlation-validator.cpp b/src/clock-correlation-validator/clock-correlation-validator.cpp index a0f015a5..88e9c89f 100644 --- a/src/clock-correlation-validator/clock-correlation-validator.cpp +++ b/src/clock-correlation-validator/clock-correlation-validator.cpp @@ -45,9 +45,9 @@ void ClockCorrelationValidator::_validate(const bt2::ConstMessage msg) if (clockCls->origin().isUnixEpoch()) { _mExpectation = PropsExpectation::OriginUnix; } else if (const auto uuid = clockCls->uuid()) { - _mExpectation = PropsExpectation::OriginOtherUuid; + _mExpectation = PropsExpectation::OriginUnknownWithUuid; } else { - _mExpectation = PropsExpectation::OriginOtherNoUuid; + _mExpectation = PropsExpectation::OriginUnknownWithoutUuid; } } else { _mExpectation = PropsExpectation::None; @@ -66,60 +66,67 @@ void ClockCorrelationValidator::_validate(const bt2::ConstMessage msg) case PropsExpectation::OriginUnix: if (!clockCls) { - throw ClockCorrelationError {ClockCorrelationError::Type::ExpectingOriginUnixGotNone, - {}, - *_mRefClockClass, - streamCls}; + throw ClockCorrelationError { + ClockCorrelationError::Type::ExpectingOriginUnixGotNoClockClass, + {}, + *_mRefClockClass, + streamCls}; } if (!clockCls->origin().isUnixEpoch()) { - throw ClockCorrelationError {ClockCorrelationError::Type::ExpectingOriginUnixGotOther, - *clockCls, *_mRefClockClass, streamCls}; + throw ClockCorrelationError { + ClockCorrelationError::Type::ExpectingOriginUnixGotUnknownOrigin, *clockCls, + *_mRefClockClass, streamCls}; } break; - case PropsExpectation::OriginOtherUuid: + case PropsExpectation::OriginUnknownWithUuid: { if (!clockCls) { - throw ClockCorrelationError {ClockCorrelationError::Type::ExpectingOriginUuidGotNone, - {}, - *_mRefClockClass, - streamCls}; + throw ClockCorrelationError { + ClockCorrelationError::Type::ExpectingOriginUnknownWithUuidGotNoClockClass, + {}, + *_mRefClockClass, + streamCls}; } if (clockCls->origin().isUnixEpoch()) { - throw ClockCorrelationError {ClockCorrelationError::Type::ExpectingOriginUuidGotUnix, - *clockCls, *_mRefClockClass, streamCls}; + throw ClockCorrelationError { + ClockCorrelationError::Type::ExpectingOriginUnknownWithUuidGotUnixOrigin, *clockCls, + *_mRefClockClass, streamCls}; } const auto uuid = clockCls->uuid(); if (!uuid) { - throw ClockCorrelationError {ClockCorrelationError::Type::ExpectingOriginUuidGotNoUuid, - *clockCls, *_mRefClockClass, streamCls}; + throw ClockCorrelationError { + ClockCorrelationError::Type::ExpectingOriginUnknownWithUuidGotWithoutUuid, + *clockCls, *_mRefClockClass, streamCls}; } if (*uuid != *_mRefClockClass->uuid()) { throw ClockCorrelationError { - ClockCorrelationError::Type::ExpectingOriginUuidGotOtherUuid, *clockCls, + ClockCorrelationError::Type::ExpectingOriginUnknownWithUuidGotOtherUuid, *clockCls, *_mRefClockClass, streamCls}; } break; } - case PropsExpectation::OriginOtherNoUuid: + case PropsExpectation::OriginUnknownWithoutUuid: if (!clockCls) { - throw ClockCorrelationError {ClockCorrelationError::Type::ExpectingOriginNoUuidGotNone, - {}, - *_mRefClockClass, - streamCls}; + throw ClockCorrelationError { + ClockCorrelationError::Type::ExpectingOriginUnknownWithoutUuidGotNoClockClass, + {}, + *_mRefClockClass, + streamCls}; } if (clockCls->libObjPtr() != _mRefClockClass->libObjPtr()) { - throw ClockCorrelationError {ClockCorrelationError::Type::ExpectingOriginNoUuidGotOther, - *clockCls, *_mRefClockClass, streamCls}; + throw ClockCorrelationError { + ClockCorrelationError::Type::ExpectingOriginUnknownWithoutUuidGotOtherClockClass, + *clockCls, *_mRefClockClass, streamCls}; } break; diff --git a/src/clock-correlation-validator/clock-correlation-validator.h b/src/clock-correlation-validator/clock-correlation-validator.h index bed3dbad..25d9b420 100644 --- a/src/clock-correlation-validator/clock-correlation-validator.h +++ b/src/clock-correlation-validator/clock-correlation-validator.h @@ -23,14 +23,17 @@ struct bt_message; enum bt_clock_correlation_validator_error_type { BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_NO_CLOCK_CLASS_GOT_ONE, - BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UNIX_GOT_NONE, - BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UNIX_GOT_OTHER, - BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UUID_GOT_NONE, - BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UUID_GOT_UNIX, - BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UUID_GOT_NO_UUID, - BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UUID_GOT_OTHER_UUID, - BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_NO_UUID_GOT_NONE, - BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_NO_UUID_GOT_OTHER, + + BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UNIX_GOT_NO_CLOCK_CLASS, + BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UNIX_GOT_UNKNOWN_ORIGIN, + + BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UNKNOWN_WITH_UUID_GOT_NO_CLOCK_CLASS, + BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UNKNOWN_WITH_UUID_GOT_UNIX_ORIGIN, + BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UNKNOWN_WITH_UUID_GOT_WITHOUT_UUID, + BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UNKNOWN_WITH_UUID_GOT_OTHER_UUID, + + BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UNKNOWN_WITHOUT_UUID_GOT_NO_CLOCK_CLASS, + BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UNKNOWN_WITHOUT_UUID_GOT_OTHER_CLOCK_CLASS, }; struct bt_clock_correlation_validator *bt_clock_correlation_validator_create( diff --git a/src/clock-correlation-validator/clock-correlation-validator.hpp b/src/clock-correlation-validator/clock-correlation-validator.hpp index 0e066428..4326bdb3 100644 --- a/src/clock-correlation-validator/clock-correlation-validator.hpp +++ b/src/clock-correlation-validator/clock-correlation-validator.hpp @@ -20,22 +20,25 @@ public: { ExpectingNoClockClassGotOne = BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_NO_CLOCK_CLASS_GOT_ONE, - ExpectingOriginUnixGotNone = - BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UNIX_GOT_NONE, - ExpectingOriginUnixGotOther = - BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UNIX_GOT_OTHER, - ExpectingOriginUuidGotNone = - BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UUID_GOT_NONE, - ExpectingOriginUuidGotUnix = - BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UUID_GOT_UNIX, - ExpectingOriginUuidGotNoUuid = - BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UUID_GOT_NO_UUID, - ExpectingOriginUuidGotOtherUuid = - BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UUID_GOT_OTHER_UUID, - ExpectingOriginNoUuidGotNone = - BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_NO_UUID_GOT_NONE, - ExpectingOriginNoUuidGotOther = - BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_NO_UUID_GOT_OTHER, + + ExpectingOriginUnixGotNoClockClass = + BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UNIX_GOT_NO_CLOCK_CLASS, + ExpectingOriginUnixGotUnknownOrigin = + BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UNIX_GOT_UNKNOWN_ORIGIN, + + ExpectingOriginUnknownWithUuidGotNoClockClass = + BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UNKNOWN_WITH_UUID_GOT_NO_CLOCK_CLASS, + ExpectingOriginUnknownWithUuidGotUnixOrigin = + BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UNKNOWN_WITH_UUID_GOT_UNIX_ORIGIN, + ExpectingOriginUnknownWithUuidGotWithoutUuid = + BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UNKNOWN_WITH_UUID_GOT_WITHOUT_UUID, + ExpectingOriginUnknownWithUuidGotOtherUuid = + BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UNKNOWN_WITH_UUID_GOT_OTHER_UUID, + + ExpectingOriginUnknownWithoutUuidGotNoClockClass = + BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UNKNOWN_WITHOUT_UUID_GOT_NO_CLOCK_CLASS, + ExpectingOriginUnknownWithoutUuidGotOtherClockClass = + BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UNKNOWN_WITHOUT_UUID_GOT_OTHER_CLOCK_CLASS, }; explicit ClockCorrelationError( @@ -90,11 +93,11 @@ private: /* Expect a clock with a Unix epoch origin. */ OriginUnix, - /* Expect a clock without a Unix epoch origin, but with a UUID. */ - OriginOtherUuid, + /* Expect a clock with an unknown origin, but with a UUID. */ + OriginUnknownWithUuid, - /* Expect a clock without a Unix epoch origin and without a UUID. */ - OriginOtherNoUuid, + /* Expect a clock with an unknown origin and without a UUID. */ + OriginUnknownWithoutUuid, }; public: diff --git a/src/lib/graph/iterator.c b/src/lib/graph/iterator.c index d27f3284..d7119ee0 100644 --- a/src/lib/graph/iterator.c +++ b/src/lib/graph/iterator.c @@ -697,41 +697,41 @@ void assert_post_dev_clock_classes_are_compatible_one( BT_ASSERT_POST_DEV(NEXT_METHOD_NAME, "stream-class-has-no-clock-class", false, "Expecting no clock class, got one."); - case BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UNIX_GOT_NONE: + case BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UNIX_GOT_NO_CLOCK_CLASS: BT_ASSERT_POST_DEV(NEXT_METHOD_NAME, "stream-class-has-clock-class-with-unix-epoch-origin", false, "Expecting a clock class, got none."); - case BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UNIX_GOT_OTHER: + case BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UNIX_GOT_UNKNOWN_ORIGIN: BT_ASSERT_POST_DEV(NEXT_METHOD_NAME, "clock-class-has-unix-epoch-origin", false, "Expecting a clock class with Unix epoch origin: %![cc-]+K", actual_clock_cls); - case BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UUID_GOT_NONE: + case BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UNKNOWN_WITH_UUID_GOT_NO_CLOCK_CLASS: BT_ASSERT_POST_DEV(NEXT_METHOD_NAME, "stream-class-has-clock-class-with-uuid", false, "Expecting a clock class, got none."); - case BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UUID_GOT_UNIX: + case BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UNKNOWN_WITH_UUID_GOT_UNIX_ORIGIN: BT_ASSERT_POST_DEV(NEXT_METHOD_NAME, "clock-class-has-non-unix-epoch-origin", false, "Expecting a clock class without Unix epoch origin: %![cc-]+K", actual_clock_cls); - case BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UUID_GOT_NO_UUID: + case BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UNKNOWN_WITH_UUID_GOT_WITHOUT_UUID: BT_ASSERT_POST_DEV(NEXT_METHOD_NAME, "clock-class-has-uuid", false, "Expecting a clock class with UUID: %![cc-]+K", actual_clock_cls); - case BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UUID_GOT_OTHER_UUID: + case BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UNKNOWN_WITH_UUID_GOT_OTHER_UUID: BT_ASSERT_POST_DEV(NEXT_METHOD_NAME, "clock-class-has-expected-uuid", false, "Expecting a clock class with UUID, got one with a different UUID: " "%![cc-]+K, expected-uuid=%!u", actual_clock_cls, bt_clock_class_get_uuid(ref_clock_cls)); - case BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_NO_UUID_GOT_NONE: + case BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UNKNOWN_WITHOUT_UUID_GOT_NO_CLOCK_CLASS: BT_ASSERT_POST_DEV(NEXT_METHOD_NAME, "stream-class-has-clock-class", false, "Expecting a clock class, got none."); - case BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_NO_UUID_GOT_OTHER: + case BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UNKNOWN_WITHOUT_UUID_GOT_OTHER_CLOCK_CLASS: BT_ASSERT_POST_DEV(NEXT_METHOD_NAME, "clock-class-is-expected", false, "Unexpected clock class: %![expected-cc-]+K, %![actual-cc-]+K", diff --git a/src/plugins/utils/muxer/msg-iter.cpp b/src/plugins/utils/muxer/msg-iter.cpp index 2da2b8d0..cc719898 100644 --- a/src/plugins/utils/muxer/msg-iter.cpp +++ b/src/plugins/utils/muxer/msg-iter.cpp @@ -260,9 +260,9 @@ void MsgIter::_validateMsgClkCls(const bt2::ConstMessage msg) "Expecting no clock class, but got one: clock-class-addr={}, clock-class-name={}", fmt::ptr(actualClkCls->libObjPtr()), actualClkCls->name()); - case Type::ExpectingOriginUnixGotNone: - case Type::ExpectingOriginUuidGotNone: - case Type::ExpectingOriginNoUuidGotNone: + case Type::ExpectingOriginUnixGotNoClockClass: + case Type::ExpectingOriginUnknownWithUuidGotNoClockClass: + case Type::ExpectingOriginUnknownWithoutUuidGotNoClockClass: BT_CPPLOGE_APPEND_CAUSE_AND_THROW( bt2::Error, "Expecting a clock class, but got none: stream-class-addr={}, " @@ -270,14 +270,14 @@ void MsgIter::_validateMsgClkCls(const bt2::ConstMessage msg) fmt::ptr(error.streamCls()->libObjPtr()), error.streamCls()->name(), error.streamCls()->id()); - case Type::ExpectingOriginUnixGotOther: + case Type::ExpectingOriginUnixGotUnknownOrigin: BT_CPPLOGE_APPEND_CAUSE_AND_THROW( bt2::Error, "Expecting a clock class having a Unix epoch origin, but got one not having a Unix " "epoch origin: clock-class-addr={}, clock-class-name={}", fmt::ptr(actualClkCls->libObjPtr()), actualClkCls->name()); - case Type::ExpectingOriginUuidGotUnix: + case Type::ExpectingOriginUnknownWithUuidGotUnixOrigin: BT_CPPLOGE_APPEND_CAUSE_AND_THROW( bt2::Error, "Expecting a clock class not having a Unix epoch origin, " @@ -285,14 +285,14 @@ void MsgIter::_validateMsgClkCls(const bt2::ConstMessage msg) "clock-class-addr={}, clock-class-name={}", fmt::ptr(actualClkCls->libObjPtr()), actualClkCls->name()); - case Type::ExpectingOriginUuidGotNoUuid: + case Type::ExpectingOriginUnknownWithUuidGotWithoutUuid: BT_CPPLOGE_APPEND_CAUSE_AND_THROW( bt2::Error, "Expecting a clock class with a UUID, but got one without a UUID: " "clock-class-addr={}, clock-class-name={}", fmt::ptr(actualClkCls->libObjPtr()), actualClkCls->name()); - case Type::ExpectingOriginUuidGotOtherUuid: + case Type::ExpectingOriginUnknownWithUuidGotOtherUuid: BT_CPPLOGE_APPEND_CAUSE_AND_THROW( bt2::Error, "Expecting a clock class with a specific UUID, but got one with a different UUID: " @@ -300,7 +300,7 @@ void MsgIter::_validateMsgClkCls(const bt2::ConstMessage msg) fmt::ptr(actualClkCls->libObjPtr()), actualClkCls->name(), *refClkCls->uuid(), *actualClkCls->uuid()); - case Type::ExpectingOriginNoUuidGotOther: + case Type::ExpectingOriginUnknownWithoutUuidGotOtherClockClass: BT_CPPLOGE_APPEND_CAUSE_AND_THROW( bt2::Error, "Unexpected clock class: " -- 2.34.1