mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Fix various build warnings.
This commit is contained in:
parent
717805a593
commit
1604515fd9
16 changed files with 32 additions and 35 deletions
|
@ -99,7 +99,7 @@ impl CallbackInterface {
|
|||
-> Result<JSVal, ()> {
|
||||
let mut callable = UndefinedValue();
|
||||
unsafe {
|
||||
let name = CString::from_slice(name.as_bytes());
|
||||
let name = CString::new(name).unwrap();
|
||||
if JS_GetProperty(cx, self.callback(), name.as_ptr(), &mut callable) == 0 {
|
||||
return Err(());
|
||||
}
|
||||
|
|
|
@ -122,7 +122,7 @@ pub fn report_pending_exception(cx: *mut JSContext, obj: *mut JSObject) {
|
|||
pub fn throw_not_in_union(cx: *mut JSContext, names: &'static str) -> JSBool {
|
||||
assert!(unsafe { JS_IsExceptionPending(cx) } == 0);
|
||||
let message = format!("argument could not be converted to any of: {}", names);
|
||||
let string = CString::from_slice(message.as_bytes());
|
||||
let string = CString::new(message).unwrap();
|
||||
unsafe { ReportError(cx, string.as_ptr()) };
|
||||
return 0;
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ unsafe extern fn get_error_message(_user_ref: *mut libc::c_void,
|
|||
|
||||
/// Throw a `TypeError` with the given message.
|
||||
pub fn throw_type_error(cx: *mut JSContext, error: &str) {
|
||||
let error = CString::from_slice(error.as_bytes());
|
||||
let error = CString::new(error).unwrap();
|
||||
unsafe {
|
||||
JS_ReportErrorNumber(cx,
|
||||
Some(get_error_message as
|
||||
|
|
|
@ -92,7 +92,7 @@ pub fn trace_jsval(tracer: *mut JSTracer, description: &str, val: JSVal) {
|
|||
}
|
||||
|
||||
unsafe {
|
||||
let name = CString::from_slice(description.as_bytes());
|
||||
let name = CString::new(description).unwrap();
|
||||
(*tracer).debugPrinter = None;
|
||||
(*tracer).debugPrintIndex = -1;
|
||||
(*tracer).debugPrintArg = name.as_ptr() as *const libc::c_void;
|
||||
|
@ -110,7 +110,7 @@ pub fn trace_reflector(tracer: *mut JSTracer, description: &str, reflector: &Ref
|
|||
/// Trace a `JSObject`.
|
||||
pub fn trace_object(tracer: *mut JSTracer, description: &str, obj: *mut JSObject) {
|
||||
unsafe {
|
||||
let name = CString::from_slice(description.as_bytes());
|
||||
let name = CString::new(description).unwrap();
|
||||
(*tracer).debugPrinter = None;
|
||||
(*tracer).debugPrintIndex = -1;
|
||||
(*tracer).debugPrintArg = name.as_ptr() as *const libc::c_void;
|
||||
|
|
|
@ -197,7 +197,7 @@ pub fn do_create_interface_objects(cx: *mut JSContext, global: *mut JSObject,
|
|||
|
||||
match constructor {
|
||||
Some((native, name, nargs)) => {
|
||||
let s = CString::from_slice(name.as_bytes());
|
||||
let s = CString::new(name).unwrap();
|
||||
create_interface_object(cx, global, receiver,
|
||||
native, nargs, proto,
|
||||
members, s.as_ptr())
|
||||
|
@ -516,7 +516,7 @@ pub fn get_dictionary_property(cx: *mut JSContext,
|
|||
}
|
||||
}
|
||||
|
||||
let property = CString::from_slice(property.as_bytes());
|
||||
let property = CString::new(property).unwrap();
|
||||
if object.is_null() {
|
||||
return Ok(None);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue