Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • Trac Trac
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Issues 246
    • Issues 246
    • List
    • Boards
    • Service Desk
    • Milestones
  • Monitor
    • Monitor
    • Metrics
    • Incidents
  • Analytics
    • Analytics
    • Value stream
  • Wiki
    • Wiki
  • Activity
  • Create a new issue
  • Issue Boards
Collapse sidebar
  • Legacy
  • TracTrac
  • Issues
  • #24794

Closed (moved)
(moved)
Open
Created Jan 04, 2018 by Nick Mathewson@nickm🍬

smartlist.rs: do not use i8 interchangeably with libc::c_char

I tried to look at why our arm rust builds are failing, and found these warnings:

20:53:59   --> /srv/jenkins-workspace/workspace/tor-ci-linux-master-rust-arm/ARCHITECTURE/armhf/SUITE/sid/tor/src/rust/smartlist/smartlist.rs:37:44
20:53:59    |
20:53:59 37 |             unsafe { slice::from_raw_parts(self.list, self.num_used as usize) };
20:53:59    |                                            ^^^^^^^^^ expected i8, found u8
20:53:59    |
20:53:59    = note: expected type `*const *const i8`
20:53:59               found type `*const *const u8`
20:53:59 
20:53:59 error[E0308]: mismatched types
20:53:59   --> /srv/jenkins-workspace/workspace/tor-ci-linux-master-rust-arm/ARCHITECTURE/armhf/SUITE/sid/tor/src/rust/smartlist/smartlist.rs:46:52
20:53:59    |
20:53:59 46 |             let c_string = unsafe { CStr::from_ptr(*elem) };
20:53:59    |                                                    ^^^^^ expected u8, found i8
20:53:59    |
20:53:59    = note: expected type `*const u8`
20:53:59               found type `*const i8`
20:53:59 

They happen because we're declaring Stringlist::list as c_char, but we're declaring elems as i8. That's fine on platforms where C's char is signed, but on other platforms, char is unsigned, and libc::c_char is u8.

I believe we can fix this by changing i8 to c_char on this line:

        let elems: &[*const i8] =
            unsafe { slice::from_raw_parts(self.list, self.num_used as usize) };
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking