Skip to content

Commit 77774e4

Browse files
committed
Use CString
1 parent 3281248 commit 77774e4

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/librustc_codegen_llvm/attributes.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,12 @@ pub fn set_instrument_function(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
8080

8181
// The function name varies on platforms.
8282
// See test/CodeGen/mcount.c in clang.
83-
use std::ffi::CStr;
84-
let target_mcount = format!("{}{}",
85-
&cx.sess().target.target.options.target_mcount, "\0");
86-
let mcount_name = CStr::from_bytes_with_nul(target_mcount.as_bytes()).unwrap();
83+
let mcount_name = CString::new(
84+
cx.sess().target.target.options.target_mcount.as_str().as_bytes()).unwrap();
8785

8886
llvm::AddFunctionAttrStringValue(
8987
llfn, llvm::AttributePlace::Function,
90-
const_cstr!("instrument-function-entry-inlined"), mcount_name);
88+
const_cstr!("instrument-function-entry-inlined"), &mcount_name);
9189
}
9290
}
9391

0 commit comments

Comments
 (0)