On 9/23/25 21:23, Stefan Hajnoczi wrote:
+    out('// SPDX-License-Identifier: GPL-2.0-or-later',
+        '// This file is @generated by tracetool, do not edit.',
+        '',
+        '#[allow(unused_imports)]',
+        'use std::ffi::c_char;',
+        '#[allow(unused_imports)]',
+        'use util::bindings;',
+        '',
+        '#[inline(always)]',
+        'fn trace_event_get_state_dynamic_by_id(_id: u16) -> bool {',
+        '    unsafe { (trace_events_enabled_count != 0) && (_id != 0) }',
+        '}',

This was translated to Rust from:

   /* it's on fast path, avoid consistency checks (asserts) */
   #define trace_event_get_state_dynamic_by_id(id) \
       (unlikely(trace_events_enabled_count) && _ ## id ## _DSTATE)

The _id != 0 expression is incorrect. The purpose was to check whether
the trace event is currently enabled (i.e. dynamically at runtime).

The expression is correct, but the function and argument names are not. It should be

fn trace_event_state_is_enabled(dstate: u16) -> bool {
     unsafe { trace_events_enabled_count } != 0 && dstate != 0
}

+    # static state
+    for e in events:
+        if 'disable' in e.properties:
+            enabled = "false"
+        else:
+            enabled = "true"

What is the purpose of this loop? The variable enabled is unused so I
think it can be deleted.

The Rust code generator is not emitting any code for disabled tracepoints. Unlike C, where the disabled tracepoints can produce e.g. -Wformat warnings, there's no real benefit here.

In the RFC the "enabled" variable was used to produce a const for the static state; it had no user so I removed it, but I left behind this dead Python code. Sorry about that!

Paolo


Reply via email to