Skip to content

Commit 4f1e3da

Browse files
committed
Use c_schar instead of c_char
The signedness of the C type 'char' is implementation defined. The rust type c_schar exists for this reason. Use it.
1 parent 6320ed2 commit 4f1e3da

17 files changed

+33
-33
lines changed

src/codegen/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2138,7 +2138,7 @@ impl ToRustTy for Type {
21382138
TypeKind::Int(ik) => {
21392139
match ik {
21402140
IntKind::Bool => aster::ty::TyBuilder::new().bool(),
2141-
IntKind::Char => raw_type(ctx, "c_char"),
2141+
IntKind::Char => raw_type(ctx, "c_schar"),
21422142
IntKind::UChar => raw_type(ctx, "c_uchar"),
21432143
IntKind::Short => raw_type(ctx, "c_short"),
21442144
IntKind::UShort => raw_type(ctx, "c_ushort"),

tests/expectations/tests/arg_keyword.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66

77
extern "C" {
88
#[link_name = "_Z3fooPKc"]
9-
pub fn foo(type_: *const ::std::os::raw::c_char);
9+
pub fn foo(type_: *const ::std::os::raw::c_schar);
1010
}

tests/expectations/tests/bitfield-enum-basic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ impl ::std::ops::BitOr<Buz> for Buz {
3333
}
3434
#[repr(C)]
3535
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
36-
pub struct Buz(pub ::std::os::raw::c_char);
36+
pub struct Buz(pub ::std::os::raw::c_schar);
3737
pub const NS_FOO: _bindgen_ty_1 = _bindgen_ty_1(1);
3838
pub const NS_BAR: _bindgen_ty_1 = _bindgen_ty_1(2);
3939
impl ::std::ops::BitOr<_bindgen_ty_1> for _bindgen_ty_1 {

tests/expectations/tests/class.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ impl <T> ::std::fmt::Debug for __BindgenUnionField<T> {
6464
#[repr(C)]
6565
pub struct C {
6666
pub a: ::std::os::raw::c_int,
67-
pub big_array: [::std::os::raw::c_char; 33usize],
67+
pub big_array: [::std::os::raw::c_schar; 33usize],
6868
}
6969
#[test]
7070
fn bindgen_test_layout_C() {
@@ -88,8 +88,8 @@ impl Default for C {
8888
#[repr(C)]
8989
pub struct C_with_zero_length_array {
9090
pub a: ::std::os::raw::c_int,
91-
pub big_array: [::std::os::raw::c_char; 33usize],
92-
pub zero_length_array: __IncompleteArrayField<::std::os::raw::c_char>,
91+
pub big_array: [::std::os::raw::c_schar; 33usize],
92+
pub zero_length_array: __IncompleteArrayField<::std::os::raw::c_schar>,
9393
}
9494
#[test]
9595
fn bindgen_test_layout_C_with_zero_length_array() {
@@ -124,8 +124,8 @@ impl Default for C_with_zero_length_array {
124124
#[repr(C)]
125125
pub struct C_with_incomplete_array {
126126
pub a: ::std::os::raw::c_int,
127-
pub big_array: [::std::os::raw::c_char; 33usize],
128-
pub incomplete_array: __IncompleteArrayField<::std::os::raw::c_char>,
127+
pub big_array: [::std::os::raw::c_schar; 33usize],
128+
pub incomplete_array: __IncompleteArrayField<::std::os::raw::c_schar>,
129129
}
130130
#[test]
131131
fn bindgen_test_layout_C_with_incomplete_array() {
@@ -142,9 +142,9 @@ impl Default for C_with_incomplete_array {
142142
#[repr(C)]
143143
pub struct C_with_zero_length_array_and_incomplete_array {
144144
pub a: ::std::os::raw::c_int,
145-
pub big_array: [::std::os::raw::c_char; 33usize],
146-
pub zero_length_array: __IncompleteArrayField<::std::os::raw::c_char>,
147-
pub incomplete_array: __IncompleteArrayField<::std::os::raw::c_char>,
145+
pub big_array: [::std::os::raw::c_schar; 33usize],
146+
pub zero_length_array: __IncompleteArrayField<::std::os::raw::c_schar>,
147+
pub incomplete_array: __IncompleteArrayField<::std::os::raw::c_schar>,
148148
}
149149
#[test]
150150
fn bindgen_test_layout_C_with_zero_length_array_and_incomplete_array() {

tests/expectations/tests/class_with_typedef.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub struct C {
1515
pub other_ptr: *mut AnotherInt,
1616
}
1717
pub type C_MyInt = ::std::os::raw::c_int;
18-
pub type C_Lookup = *const ::std::os::raw::c_char;
18+
pub type C_Lookup = *const ::std::os::raw::c_schar;
1919
#[test]
2020
fn bindgen_test_layout_C() {
2121
assert_eq!(::std::mem::size_of::<C>() , 72usize , concat ! (

tests/expectations/tests/constant-evaluate.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub const k: EasyToOverflow = 2147483648;
1414
pub const k_expr: EasyToOverflow = 0;
1515
pub const BAZ: ::std::os::raw::c_longlong = 24;
1616
pub const fuzz: f64 = 51.;
17-
pub const BAZZ: ::std::os::raw::c_char = 53;
18-
pub const WAT: ::std::os::raw::c_char = 0;
17+
pub const BAZZ: ::std::os::raw::c_schar = 53;
18+
pub const WAT: ::std::os::raw::c_schar = 0;
1919
pub const bytestring: &'static [u8; 4usize] = b"Foo\x00";
2020
pub const NOT_UTF8: [u8; 5usize] = [240, 40, 140, 40, 0];

tests/expectations/tests/inline_namespace_whitelist.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ pub mod root {
1010
pub mod std {
1111
#[allow(unused_imports)]
1212
use self::super::super::root;
13-
pub type string = *const ::std::os::raw::c_char;
13+
pub type string = *const ::std::os::raw::c_schar;
1414
}
1515
}

tests/expectations/tests/issue-493.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub struct basic_string<_CharT, _Traits, _Allocator> {
3737
pub _phantom_2: ::std::marker::PhantomData<_Allocator>,
3838
}
3939
pub type basic_string_size_type = ::std::os::raw::c_ulonglong;
40-
pub type basic_string_value_type = ::std::os::raw::c_char;
40+
pub type basic_string_value_type = ::std::os::raw::c_schar;
4141
pub type basic_string_pointer = *mut basic_string_value_type;
4242
#[repr(C)]
4343
#[derive(Debug, Copy, Clone)]

tests/expectations/tests/layout.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl <T> ::std::marker::Copy for __IncompleteArrayField<T> { }
4040
#[repr(C, packed)]
4141
#[derive(Debug, Default, Copy)]
4242
pub struct header {
43-
pub proto: ::std::os::raw::c_char,
43+
pub proto: ::std::os::raw::c_schar,
4444
pub size: ::std::os::raw::c_uint,
4545
pub data: __IncompleteArrayField<::std::os::raw::c_uchar>,
4646
pub __bindgen_padding_0: [u8; 11usize],

tests/expectations/tests/layout_array.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ pub type rte_mempool_get_count =
5858
#[derive(Debug, Copy)]
5959
pub struct rte_mempool_ops {
6060
/**< Name of mempool ops struct. */
61-
pub name: [::std::os::raw::c_char; 32usize],
61+
pub name: [::std::os::raw::c_schar; 32usize],
6262
/**< Allocate private data. */
6363
pub alloc: rte_mempool_alloc_t,
6464
/**< Free the external pool. */

0 commit comments

Comments
 (0)