Use null()/null_mut() instead of 0 as *const T/0 as *mut T
This commit is contained in:
parent
3903ea96f5
commit
06fb196256
22 changed files with 65 additions and 52 deletions
|
|
@ -18,6 +18,7 @@ use std::io;
|
|||
use std::mem;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::{Command, Output, Stdio};
|
||||
use std::ptr;
|
||||
use std::str;
|
||||
|
||||
use libc;
|
||||
|
|
@ -449,7 +450,7 @@ impl<'a> ArchiveBuilder<'a> {
|
|||
}
|
||||
|
||||
let name = try!(CString::new(child_name));
|
||||
members.push(llvm::LLVMRustArchiveMemberNew(0 as *const _,
|
||||
members.push(llvm::LLVMRustArchiveMemberNew(ptr::null(),
|
||||
name.as_ptr(),
|
||||
child.raw()));
|
||||
strings.push(name);
|
||||
|
|
@ -462,7 +463,7 @@ impl<'a> ArchiveBuilder<'a> {
|
|||
let name = try!(CString::new(name_in_archive));
|
||||
members.push(llvm::LLVMRustArchiveMemberNew(path.as_ptr(),
|
||||
name.as_ptr(),
|
||||
0 as *mut _));
|
||||
ptr::null_mut()));
|
||||
strings.push(path);
|
||||
strings.push(name);
|
||||
}
|
||||
|
|
@ -472,7 +473,7 @@ impl<'a> ArchiveBuilder<'a> {
|
|||
if skip(child_name) { continue }
|
||||
|
||||
let name = try!(CString::new(child_name));
|
||||
let m = llvm::LLVMRustArchiveMemberNew(0 as *const _,
|
||||
let m = llvm::LLVMRustArchiveMemberNew(ptr::null(),
|
||||
name.as_ptr(),
|
||||
child.raw());
|
||||
members.push(m);
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ use std::io;
|
|||
use std::ffi::{OsString, OsStr};
|
||||
use std::os::windows::prelude::*;
|
||||
use std::ops::RangeFrom;
|
||||
use std::ptr;
|
||||
use libc::{DWORD, LPCWSTR, LONG, LPDWORD, LPBYTE, ERROR_SUCCESS};
|
||||
use libc::c_void;
|
||||
|
||||
|
|
@ -88,7 +89,7 @@ impl RegistryKey {
|
|||
|
||||
pub fn open(&self, key: &OsStr) -> io::Result<RegistryKey> {
|
||||
let key = key.encode_wide().chain(Some(0)).collect::<Vec<_>>();
|
||||
let mut ret = 0 as *mut _;
|
||||
let mut ret = ptr::null_mut();
|
||||
let err = unsafe {
|
||||
RegOpenKeyExW(self.raw(), key.as_ptr(), 0,
|
||||
KEY_READ | KEY_WOW64_32KEY, &mut ret)
|
||||
|
|
@ -110,8 +111,8 @@ impl RegistryKey {
|
|||
let mut len = 0;
|
||||
let mut kind = 0;
|
||||
unsafe {
|
||||
let err = RegQueryValueExW(self.raw(), name.as_ptr(), 0 as *mut _,
|
||||
&mut kind, 0 as *mut _, &mut len);
|
||||
let err = RegQueryValueExW(self.raw(), name.as_ptr(), ptr::null_mut(),
|
||||
&mut kind, ptr::null_mut(), &mut len);
|
||||
if err != ERROR_SUCCESS {
|
||||
return Err(io::Error::from_raw_os_error(err as i32))
|
||||
}
|
||||
|
|
@ -124,8 +125,8 @@ impl RegistryKey {
|
|||
// characters so we need to be sure to halve it for the capacity
|
||||
// passed in.
|
||||
let mut v = Vec::with_capacity(len as usize / 2);
|
||||
let err = RegQueryValueExW(self.raw(), name.as_ptr(), 0 as *mut _,
|
||||
0 as *mut _, v.as_mut_ptr() as *mut _,
|
||||
let err = RegQueryValueExW(self.raw(), name.as_ptr(), ptr::null_mut(),
|
||||
ptr::null_mut(), v.as_mut_ptr() as *mut _,
|
||||
&mut len);
|
||||
if err != ERROR_SUCCESS {
|
||||
return Err(io::Error::from_raw_os_error(err as i32))
|
||||
|
|
@ -156,8 +157,8 @@ impl<'a> Iterator for Iter<'a> {
|
|||
let mut v = Vec::with_capacity(256);
|
||||
let mut len = v.capacity() as DWORD;
|
||||
let ret = RegEnumKeyExW(self.key.raw(), i, v.as_mut_ptr(), &mut len,
|
||||
0 as *mut _, 0 as *mut _, 0 as *mut _,
|
||||
0 as *mut _);
|
||||
ptr::null_mut(), ptr::null_mut(), ptr::null_mut(),
|
||||
ptr::null_mut());
|
||||
if ret == ERROR_NO_MORE_ITEMS as LONG {
|
||||
None
|
||||
} else if ret != ERROR_SUCCESS {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue