Skip to content

Commit 9ef6466

Browse files
committed
refactor: use c"something" styled string literals, instead of b"something\0"
1 parent d93cee4 commit 9ef6466

File tree

1 file changed

+12
-12
lines changed
  • gems/codetracer-ruby-recorder/ext/native_tracer/src

1 file changed

+12
-12
lines changed

gems/codetracer-ruby-recorder/ext/native_tracer/src/lib.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ unsafe extern "C" fn recorder_free(ptr: *mut c_void) {
174174
}
175175

176176
static mut RECORDER_TYPE: rb_data_type_t = rb_data_type_t {
177-
wrap_struct_name: b"Recorder\0".as_ptr() as *const c_char,
177+
wrap_struct_name: c"Recorder".as_ptr() as *const c_char,
178178
function: rb_data_type_struct__bindgen_ty_1 {
179179
dmark: None,
180180
dfree: Some(recorder_free),
@@ -193,7 +193,7 @@ unsafe fn get_recorder(obj: VALUE) -> *mut Recorder {
193193
if ptr.is_null() {
194194
rb_raise(
195195
rb_eIOError,
196-
b"Invalid recorder object\0".as_ptr() as *const c_char,
196+
c"Invalid recorder object".as_ptr() as *const c_char,
197197
);
198198
}
199199
ptr as *mut Recorder
@@ -610,7 +610,7 @@ unsafe extern "C" fn initialize(self_val: VALUE, out_dir: VALUE, format: VALUE)
610610
"binaryv0" => runtime_tracing::TraceEventsFileFormat::BinaryV0,
611611
"binary" | "bin" => runtime_tracing::TraceEventsFileFormat::Binary,
612612
"json" => runtime_tracing::TraceEventsFileFormat::Json,
613-
_ => rb_raise(rb_eIOError, b"Unknown format\0".as_ptr() as *const c_char),
613+
_ => rb_raise(rb_eIOError, c"Unknown format".as_ptr() as *const c_char),
614614
}
615615
} else {
616616
runtime_tracing::TraceEventsFileFormat::Json
@@ -665,7 +665,7 @@ unsafe extern "C" fn initialize(self_val: VALUE, out_dir: VALUE, format: VALUE)
665665
.unwrap_or_else(|_| std::ffi::CString::new("unknown error").unwrap());
666666
rb_raise(
667667
rb_eIOError,
668-
b"Failed to flush trace: %s\0".as_ptr() as *const c_char,
668+
c"Failed to flush trace: %s".as_ptr() as *const c_char,
669669
msg.as_ptr(),
670670
);
671671
}
@@ -676,7 +676,7 @@ unsafe extern "C" fn initialize(self_val: VALUE, out_dir: VALUE, format: VALUE)
676676
.unwrap_or_else(|_| std::ffi::CString::new("invalid utf8").unwrap());
677677
rb_raise(
678678
rb_eIOError,
679-
b"Invalid UTF-8 in path: %s\0".as_ptr() as *const c_char,
679+
c"Invalid UTF-8 in path: %s".as_ptr() as *const c_char,
680680
msg.as_ptr(),
681681
)
682682
}
@@ -694,7 +694,7 @@ unsafe extern "C" fn flush_trace(self_val: VALUE) -> VALUE {
694694
.unwrap_or_else(|_| std::ffi::CString::new("unknown error").unwrap());
695695
rb_raise(
696696
rb_eIOError,
697-
b"Failed to flush trace: %s\0".as_ptr() as *const c_char,
697+
c"Failed to flush trace: %s".as_ptr() as *const c_char,
698698
msg.as_ptr(),
699699
);
700700
}
@@ -834,38 +834,38 @@ unsafe extern "C" fn event_hook_raw(data: VALUE, arg: *mut rb_trace_arg_t) {
834834
pub extern "C" fn Init_codetracer_ruby_recorder() {
835835
unsafe {
836836
let class = rb_define_class(
837-
b"CodeTracerNativeRecorder\0".as_ptr() as *const c_char,
837+
c"CodeTracerNativeRecorder".as_ptr() as *const c_char,
838838
rb_cObject,
839839
);
840840
rb_define_alloc_func(class, Some(ruby_recorder_alloc));
841841

842842
rb_define_method(
843843
class,
844-
b"initialize\0".as_ptr() as *const c_char,
844+
c"initialize".as_ptr() as *const c_char,
845845
Some(std::mem::transmute(initialize as *const ())),
846846
2,
847847
);
848848
rb_define_method(
849849
class,
850-
b"enable_tracing\0".as_ptr() as *const c_char,
850+
c"enable_tracing".as_ptr() as *const c_char,
851851
Some(std::mem::transmute(enable_tracing as *const ())),
852852
0,
853853
);
854854
rb_define_method(
855855
class,
856-
b"disable_tracing\0".as_ptr() as *const c_char,
856+
c"disable_tracing".as_ptr() as *const c_char,
857857
Some(std::mem::transmute(disable_tracing as *const ())),
858858
0,
859859
);
860860
rb_define_method(
861861
class,
862-
b"flush_trace\0".as_ptr() as *const c_char,
862+
c"flush_trace".as_ptr() as *const c_char,
863863
Some(std::mem::transmute(flush_trace as *const ())),
864864
0,
865865
);
866866
rb_define_method(
867867
class,
868-
b"record_event\0".as_ptr() as *const c_char,
868+
c"record_event".as_ptr() as *const c_char,
869869
Some(std::mem::transmute(record_event_api as *const ())),
870870
3,
871871
);

0 commit comments

Comments
 (0)