From: Simon Marchi Date: Fri, 4 Oct 2024 15:06:11 +0000 (-0400) Subject: lib: rename bt_clock_class_origin_is_{unknown,known} X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=33ecd814ea5e4a2f9b8227a38210a4fc0e0cb548;p=babeltrace.git lib: rename bt_clock_class_origin_is_{unknown,known} The "is unknown" getter leads to double negatives: if (!bt_clock_class_origin_is_unknown(cls)) ... which is not great for readability. Rename to bt_clock_class_origin_is_known(). Change-Id: I27a9c9fec80b0e23851ee62fd2c897a1c695d2b1 Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/13317 Reviewed-by: Philippe Proulx Tested-by: jenkins --- diff --git a/include/babeltrace2/trace-ir/clock-class.h b/include/babeltrace2/trace-ir/clock-class.h index 14b44fac..f1861dee 100644 --- a/include/babeltrace2/trace-ir/clock-class.h +++ b/include/babeltrace2/trace-ir/clock-class.h @@ -88,7 +88,7 @@ the clock's offset, which is itself relative to its origin. A clock's origin is one of, depending on its class:
-
If bt_clock_class_origin_is_unknown() returns #BT_TRUE
+
If bt_clock_class_origin_is_known() returns #BT_FALSE
Undefined. @@ -272,7 +272,7 @@ A clock class has the following properties:
Unknown origin
Use bt_clock_class_set_origin_unknown() and - bt_clock_class_origin_is_unknown(). + bt_clock_class_origin_is_known().
Unix epoch origin
@@ -747,8 +747,8 @@ See the \ref api-tir-clock-cls-prop-origin "origin" property. Makes the origin of a clock class the Unix epoch. @sa bt_clock_class_set_origin() — Sets the custom origin of a clock class. -@sa bt_clock_class_origin_is_unknown() — - Returns whether or not the origin of a clock class is unknown. +@sa bt_clock_class_origin_is_known() — + Returns whether or not the origin of a clock class is known. */ extern void bt_clock_class_set_origin_unknown(bt_clock_class *clock_class) __BT_NOEXCEPT; @@ -867,15 +867,15 @@ extern bt_clock_class_set_origin_status bt_clock_class_set_origin( /*! @brief Returns whether or not the \ref api-tir-clock-cls-origin "origin" - of the clock class \bt_p{clock_class} is unknown. + of the clock class \bt_p{clock_class} is known. See the \ref api-tir-clock-cls-prop-origin "origin" property. @param[in] clock_class - Clock class of which to get whether or not its origin is unknown. + Clock class of which to get whether or not its origin is known. @returns - #BT_TRUE if the origin of \bt_p{clock_class} is unknown. + #BT_TRUE if the origin of \bt_p{clock_class} is known. @bt_pre_not_null{clock_class} @@ -889,7 +889,7 @@ See the \ref api-tir-clock-cls-prop-origin "origin" property. @sa bt_clock_class_set_origin() — Sets the custom origin of a clock class. */ -extern bt_bool bt_clock_class_origin_is_unknown( +extern bt_bool bt_clock_class_origin_is_known( const bt_clock_class *clock_class) __BT_NOEXCEPT; /*! @@ -909,8 +909,8 @@ See the \ref api-tir-clock-cls-prop-origin "origin" property. @bt_pre_not_null{clock_class} -@sa bt_clock_class_origin_is_unknown() — - Returns whether or not the origin of a clock class is unknown. +@sa bt_clock_class_origin_is_known() — + Returns whether or not the origin of a clock class is known. @sa bt_clock_class_set_origin_unknown() — Makes the origin of a clock class unknown. @sa bt_clock_class_set_origin_unix_epoch() — diff --git a/src/cpp-common/bt2/clock-class.hpp b/src/cpp-common/bt2/clock-class.hpp index 76af9e4c..3024b1d5 100644 --- a/src/cpp-common/bt2/clock-class.hpp +++ b/src/cpp-common/bt2/clock-class.hpp @@ -406,9 +406,9 @@ public: return bt_clock_class_get_origin_uid(_mClkCls.libObjPtr()); } - bool isUnknown() const noexcept + bool isKnown() const noexcept { - return bt_clock_class_origin_is_unknown(_mClkCls.libObjPtr()); + return bt_clock_class_origin_is_known(_mClkCls.libObjPtr()); } bool isUnixEpoch() const noexcept diff --git a/src/lib/trace-ir/clock-class.c b/src/lib/trace-ir/clock-class.c index fea35c8d..70777b8c 100644 --- a/src/lib/trace-ir/clock-class.c +++ b/src/lib/trace-ir/clock-class.c @@ -432,12 +432,11 @@ bt_bool bt_clock_class_origin_is_unix_epoch(const struct bt_clock_class *clock_c } BT_EXPORT -bt_bool bt_clock_class_origin_is_unknown(const struct bt_clock_class *clock_class) +bt_bool bt_clock_class_origin_is_known(const struct bt_clock_class *clock_class) { BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_DEV_CLK_CLS_NON_NULL(clock_class); - return !clock_class->origin.ns && !clock_class->origin.name && - !clock_class->origin.uid; + return clock_class->origin.name && clock_class->origin.uid; } BT_EXPORT diff --git a/src/plugins/text/details/write.c b/src/plugins/text/details/write.c index f1c6203a..f1f0c5d8 100644 --- a/src/plugins/text/details/write.c +++ b/src/plugins/text/details/write.c @@ -1633,7 +1633,7 @@ void write_clock_class_prop_lines(struct details_write_ctx *ctx, write_int_prop_line(ctx, "Offset from origin (s)", offset_seconds); write_uint_prop_line(ctx, "Offset from origin (cycles)", offset_cycles); - if (!bt_clock_class_origin_is_unknown(cc)) { + if (bt_clock_class_origin_is_known(cc)) { write_prop_name_line(ctx, "Origin"); if (bt_clock_class_origin_is_unix_epoch(cc)) {