Browse Source

Some type signature fixes found using script in #111

Ian Douglas Scott 6 years ago
parent
commit
fdd966629d
4 changed files with 19 additions and 19 deletions
  1. 1 1
      src/header/regex/mod.rs
  2. 4 4
      src/header/stdio/mod.rs
  3. 12 12
      src/header/string/mod.rs
  4. 2 2
      src/header/sys_mman/mod.rs

+ 1 - 1
src/header/regex/mod.rs

@@ -149,7 +149,7 @@ pub extern "C" fn regexec(
 
 #[no_mangle]
 #[linkage = "weak"] // redefined in GIT
-pub extern "C" fn regerror(code: c_int, _regex: *const regex_t, out: *mut c_char, max: c_int) {
+pub extern "C" fn regerror(code: c_int, _regex: *const regex_t, out: *mut c_char, max: size_t) {
     let string = match code {
         0 => "No error\0",
         REG_NOMATCH => "No match\0",

+ 4 - 4
src/header/stdio/mod.rs

@@ -560,10 +560,10 @@ pub unsafe extern "C" fn funlockfile(file: *mut FILE) {
 #[no_mangle]
 pub extern "C" fn fwrite(
     ptr: *const c_void,
-    size: usize,
-    count: usize,
+    size: size_t,
+    count: size_t,
     stream: *mut FILE,
-) -> usize {
+) -> size_t {
     let mut stream = unsafe { &mut *stream }.lock();
     let buf = unsafe { slice::from_raw_parts_mut(ptr as *mut u8, size as usize * count as usize) };
     let mut written = 0;
@@ -926,7 +926,7 @@ pub unsafe extern "C" fn vprintf(format: *const c_char, ap: va_list) -> c_int {
 #[no_mangle]
 pub unsafe extern "C" fn vsnprintf(
     s: *mut c_char,
-    n: usize,
+    n: size_t,
     format: *const c_char,
     ap: va_list,
 ) -> c_int {

+ 12 - 12
src/header/string/mod.rs

@@ -16,7 +16,7 @@ pub unsafe extern "C" fn memccpy(
     dest: *mut c_void,
     src: *const c_void,
     c: c_int,
-    n: usize,
+    n: size_t,
 ) -> *mut c_void {
     let to = memchr(src, c, n);
     if to.is_null() {
@@ -30,7 +30,7 @@ pub unsafe extern "C" fn memccpy(
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn memchr(s: *const c_void, c: c_int, n: usize) -> *mut c_void {
+pub unsafe extern "C" fn memchr(s: *const c_void, c: c_int, n: size_t) -> *mut c_void {
     let mut s = s as *const u8;
     let c = c as u8;
     let mut n = n;
@@ -72,7 +72,7 @@ pub unsafe extern "C" fn memchr(s: *const c_void, c: c_int, n: usize) -> *mut c_
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn memcmp(s1: *const c_void, s2: *const c_void, n: usize) -> c_int {
+pub unsafe extern "C" fn memcmp(s1: *const c_void, s2: *const c_void, n: size_t) -> c_int {
     let (div, rem) = (n / mem::size_of::<usize>(), n % mem::size_of::<usize>());
     let mut a = s1 as *const usize;
     let mut b = s2 as *const usize;
@@ -104,7 +104,7 @@ pub unsafe extern "C" fn memcmp(s1: *const c_void, s2: *const c_void, n: usize)
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn memcpy(s1: *mut c_void, s2: *const c_void, n: usize) -> *mut c_void {
+pub unsafe extern "C" fn memcpy(s1: *mut c_void, s2: *const c_void, n: size_t) -> *mut c_void {
     let mut i = 0;
     while i + 7 < n {
         *(s1.offset(i as isize) as *mut u64) = *(s2.offset(i as isize) as *const u64);
@@ -118,7 +118,7 @@ pub unsafe extern "C" fn memcpy(s1: *mut c_void, s2: *const c_void, n: usize) ->
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn memmove(s1: *mut c_void, s2: *const c_void, n: usize) -> *mut c_void {
+pub unsafe extern "C" fn memmove(s1: *mut c_void, s2: *const c_void, n: size_t) -> *mut c_void {
     if s2 < s1 as *const c_void {
         // copy from end
         let mut i = n;
@@ -138,7 +138,7 @@ pub unsafe extern "C" fn memmove(s1: *mut c_void, s2: *const c_void, n: usize) -
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn memset(s: *mut c_void, c: c_int, n: usize) -> *mut c_void {
+pub unsafe extern "C" fn memset(s: *mut c_void, c: c_int, n: size_t) -> *mut c_void {
     let mut i = 0;
     while i < n {
         *(s as *mut u8).offset(i as isize) = c as u8;
@@ -231,7 +231,7 @@ pub unsafe extern "C" fn strdup(s1: *const c_char) -> *mut c_char {
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn strndup(s1: *const c_char, size: usize) -> *mut c_char {
+pub unsafe extern "C" fn strndup(s1: *const c_char, size: size_t) -> *mut c_char {
     let len = strnlen(s1, size);
 
     // the "+ 1" is to account for the NUL byte
@@ -272,7 +272,7 @@ pub unsafe extern "C" fn strlen(s: *const c_char) -> size_t {
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn strnlen(s: *const c_char, size: usize) -> size_t {
+pub unsafe extern "C" fn strnlen(s: *const c_char, size: size_t) -> size_t {
     let mut i = 0;
     while i < size {
         if *s.offset(i as isize) == 0 {
@@ -284,7 +284,7 @@ pub unsafe extern "C" fn strnlen(s: *const c_char, size: usize) -> size_t {
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn strncat(s1: *mut c_char, s2: *const c_char, n: usize) -> *mut c_char {
+pub unsafe extern "C" fn strncat(s1: *mut c_char, s2: *const c_char, n: size_t) -> *mut c_char {
     let mut idx = strlen(s1 as *const _) as isize;
     for i in 0..n as isize {
         if *s2.offset(i) == 0 {
@@ -300,7 +300,7 @@ pub unsafe extern "C" fn strncat(s1: *mut c_char, s2: *const c_char, n: usize) -
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn strncmp(s1: *const c_char, s2: *const c_char, n: usize) -> c_int {
+pub unsafe extern "C" fn strncmp(s1: *const c_char, s2: *const c_char, n: size_t) -> c_int {
     let s1 = core::slice::from_raw_parts(s1 as *const c_uchar, n);
     let s2 = core::slice::from_raw_parts(s2 as *const c_uchar, n);
 
@@ -315,7 +315,7 @@ pub unsafe extern "C" fn strncmp(s1: *const c_char, s2: *const c_char, n: usize)
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn strncpy(dst: *mut c_char, src: *const c_char, n: usize) -> *mut c_char {
+pub unsafe extern "C" fn strncpy(dst: *mut c_char, src: *const c_char, n: size_t) -> *mut c_char {
     let mut i = 0;
 
     while *src.offset(i) != 0 && (i as usize) < n {
@@ -446,7 +446,7 @@ pub extern "C" fn strtok_r(
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn strxfrm(s1: *mut c_char, s2: *const c_char, n: usize) -> size_t {
+pub unsafe extern "C" fn strxfrm(s1: *mut c_char, s2: *const c_char, n: size_t) -> size_t {
     // relibc has no locale stuff (yet)
     let len = strlen(s2);
     if len < n {

+ 2 - 2
src/header/sys_mman/mod.rs

@@ -24,7 +24,7 @@ pub extern "C" fn mlockall(flags: c_int) -> c_int {
 #[no_mangle]
 pub unsafe extern "C" fn mmap(
     addr: *mut c_void,
-    len: usize,
+    len: size_t,
     prot: c_int,
     flags: c_int,
     fildes: c_int,
@@ -54,7 +54,7 @@ pub extern "C" fn munlockall() -> c_int {
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn munmap(addr: *mut c_void, len: usize) -> c_int {
+pub unsafe extern "C" fn munmap(addr: *mut c_void, len: size_t) -> c_int {
     Sys::munmap(addr, len)
 }