Browse Source

Make the naming of variables more obvious.

nwin 11 năm trước cách đây
mục cha
commit
586c7dd30b
2 tập tin đã thay đổi với 6 bổ sung4 xóa
  1. 3 2
      src/xattr/xattr_darwin.rs
  2. 3 2
      src/xattr/xattr_linux.rs

+ 3 - 2
src/xattr/xattr_darwin.rs

@@ -64,10 +64,11 @@ impl Attribute {
                 let mut names = Vec::new();
                 let mut start = 0;
                 for end in idx {
+                    let c_end = end + 1; // end of the c-string (including 0)
                     let size = unsafe {
                         getxattr(
                             c_path.as_ptr(),
-                            buf[start..end+1].as_ptr() as *const c_char,
+                            buf[start..c_end].as_ptr() as *const c_char,
                             ptr::null_mut(), 0, 0, c_flags
                         )
                     };
@@ -81,7 +82,7 @@ impl Attribute {
                             size: size as usize
                         });
                     }
-                    start = end + 1;
+                    start = c_end;
                 }
                 Ok(names)
             } else {

+ 3 - 2
src/xattr/xattr_linux.rs

@@ -59,10 +59,11 @@ impl Attribute {
                 let mut names = Vec::new();
                 let mut start = 0;
                 for end in idx {
+                    let c_end = end + 1; // end of the c-string (including 0)
                     let size = unsafe {
                         getxattr(
                             c_path.as_ptr(),
-                            buf[start..end+1].as_ptr() as *const c_char,
+                            buf[start..c_end].as_ptr() as *const c_char,
                             ptr::null_mut(), 0
                         )
                     };
@@ -72,7 +73,7 @@ impl Attribute {
                             size: size as usize
                         });
                     }
-                    start = end + 1;
+                    start = c_end;
                 }
                 Ok(names)
             } else {