lib: rename bt_clock_class_origin_is_{unknown,known}
authorSimon Marchi <simon.marchi@efficios.com>
Fri, 4 Oct 2024 15:06:11 +0000 (11:06 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Wed, 9 Oct 2024 02:56:57 +0000 (22:56 -0400)
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 <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/13317
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
include/babeltrace2/trace-ir/clock-class.h
src/cpp-common/bt2/clock-class.hpp
src/lib/trace-ir/clock-class.c
src/plugins/text/details/write.c

index 14b44fac6c921d78b38ede8e6d4338dfb39daa5d..f1861dee9f976546e488d1826154886becf52850 100644 (file)
@@ -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:
 
 <dl>
-  <dt>If bt_clock_class_origin_is_unknown() returns #BT_TRUE</dt>
+  <dt>If bt_clock_class_origin_is_known() returns #BT_FALSE</dt>
   <dd>
     Undefined.
 
@@ -272,7 +272,7 @@ A clock class has the following properties:
           <dt>Unknown origin</dt>
           <dd>
             Use bt_clock_class_set_origin_unknown() and
-            bt_clock_class_origin_is_unknown().
+            bt_clock_class_origin_is_known().
           </dd>
 
           <dt>Unix epoch origin</dt>
@@ -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() &mdash;
     Sets the custom origin of a clock class.
-@sa bt_clock_class_origin_is_unknown() &mdash;
-    Returns whether or not the origin of a clock class is unknown.
+@sa bt_clock_class_origin_is_known() &mdash;
+    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() &mdash;
     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() &mdash;
-    Returns whether or not the origin of a clock class is unknown.
+@sa bt_clock_class_origin_is_known() &mdash;
+    Returns whether or not the origin of a clock class is known.
 @sa bt_clock_class_set_origin_unknown() &mdash;
     Makes the origin of a clock class unknown.
 @sa bt_clock_class_set_origin_unix_epoch() &mdash;
index 76af9e4c50156ee060f6f7365df5adb24bae8391..3024b1d56556c5fffdfe5ecd76cd6f2d33739bd6 100644 (file)
@@ -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
index fea35c8d62dda6b35cd818009d8d913bf176d6b3..70777b8cbe1ccd38d8d684af297476d2019f81dc 100644 (file)
@@ -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
index f1c6203a3ec7e3c70a1e22242e6bedd1db95815d..f1f0c5d8a4edb080793befcb882f5ba7037a619f 100644 (file)
@@ -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)) {
This page took 0.034168 seconds and 4 git commands to generate.