Skip to content

Commit 3fae7e9

Browse files
committed
Fix style
1 parent 3a8521a commit 3fae7e9

File tree

48 files changed

+958
-3985
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+958
-3985
lines changed

build.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@ fn main() {
66
// Avoid unnecessary re-building.
77
println!("cargo:rerun-if-changed=build.rs");
88

9-
let (rustc_minor_ver, is_nightly) =
10-
rustc_minor_nightly().expect("Failed to get rustc version");
9+
let (rustc_minor_ver, is_nightly) = rustc_minor_nightly().expect("Failed to get rustc version");
1110
let rustc_dep_of_std = env::var("CARGO_FEATURE_RUSTC_DEP_OF_STD").is_ok();
1211
let align_cargo_feature = env::var("CARGO_FEATURE_ALIGN").is_ok();
13-
let const_extern_fn_cargo_feature =
14-
env::var("CARGO_FEATURE_CONST_EXTERN_FN").is_ok();
12+
let const_extern_fn_cargo_feature = env::var("CARGO_FEATURE_CONST_EXTERN_FN").is_ok();
1513
let libc_ci = env::var("LIBC_CI").is_ok();
1614
let target = env::var("TARGET").unwrap();
1715

libc-test/build.rs

Lines changed: 43 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ fn do_semver() {
7878
let target_env = env::var("CARGO_CFG_TARGET_ENV").unwrap();
7979

8080
// `libc-test/semver` dir.
81-
let mut semver_root =
82-
PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
81+
let mut semver_root = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
8382
semver_root.push("semver");
8483

8584
// NOTE: Windows has the same `family` as `os`, no point in including it
@@ -103,11 +102,7 @@ fn do_semver() {
103102
}
104103
}
105104

106-
fn process_semver_file<W: Write, P: AsRef<Path>>(
107-
output: &mut W,
108-
path: &mut PathBuf,
109-
file: P,
110-
) {
105+
fn process_semver_file<W: Write, P: AsRef<Path>>(output: &mut W, path: &mut PathBuf, file: P) {
111106
// NOTE: `path` is reused between calls, so always remove the file again.
112107
path.push(file);
113108
path.set_extension("txt");
@@ -321,9 +316,7 @@ fn test_apple(target: &str) {
321316
cfg.volatile_item(|i| {
322317
use ctest::VolatileItemKind::*;
323318
match i {
324-
StructField(ref n, ref f) if n == "aiocb" && f == "aio_buf" => {
325-
true
326-
}
319+
StructField(ref n, ref f) if n == "aiocb" && f == "aio_buf" => true,
327320
_ => false,
328321
}
329322
});
@@ -351,9 +344,7 @@ fn test_apple(target: &str) {
351344
// FIXME: sigaction actually contains a union with two variants:
352345
// a sa_sigaction with type: (*)(int, struct __siginfo *, void *)
353346
// a sa_handler with type sig_t
354-
"sa_sigaction" if struct_ == "sigaction" => {
355-
"sa_handler".to_string()
356-
}
347+
"sa_sigaction" if struct_ == "sigaction" => "sa_handler".to_string(),
357348
s => s.to_string(),
358349
}
359350
});
@@ -475,9 +466,7 @@ fn test_openbsd(target: &str) {
475466
cfg.type_name(move |ty, is_struct, is_union| {
476467
match ty {
477468
// Just pass all these through, no need for a "struct" prefix
478-
"FILE" | "DIR" | "Dl_info" | "Elf32_Phdr" | "Elf64_Phdr" => {
479-
ty.to_string()
480-
}
469+
"FILE" | "DIR" | "Dl_info" | "Elf32_Phdr" | "Elf64_Phdr" => ty.to_string(),
481470

482471
// OSX calls this something else
483472
"sighandler_t" => "sig_t".to_string(),
@@ -490,15 +479,9 @@ fn test_openbsd(target: &str) {
490479
});
491480

492481
cfg.field_name(move |struct_, field| match field {
493-
"st_birthtime" if struct_.starts_with("stat") => {
494-
"__st_birthtime".to_string()
495-
}
496-
"st_birthtime_nsec" if struct_.starts_with("stat") => {
497-
"__st_birthtimensec".to_string()
498-
}
499-
s if s.ends_with("_nsec") && struct_.starts_with("stat") => {
500-
s.replace("e_nsec", ".tv_nsec")
501-
}
482+
"st_birthtime" if struct_.starts_with("stat") => "__st_birthtime".to_string(),
483+
"st_birthtime_nsec" if struct_.starts_with("stat") => "__st_birthtimensec".to_string(),
484+
s if s.ends_with("_nsec") && struct_.starts_with("stat") => s.replace("e_nsec", ".tv_nsec"),
502485
"sa_sigaction" if struct_ == "sigaction" => "sa_handler".to_string(),
503486
s => s.to_string(),
504487
});
@@ -788,18 +771,17 @@ fn test_solarish(target: &str) {
788771
});
789772

790773
cfg.skip_const(move |name| match name {
791-
"DT_FIFO" | "DT_CHR" | "DT_DIR" | "DT_BLK" | "DT_REG" | "DT_LNK"
792-
| "DT_SOCK" | "USRQUOTA" | "GRPQUOTA" | "PRIO_MIN" | "PRIO_MAX" => {
793-
true
794-
}
774+
"DT_FIFO" | "DT_CHR" | "DT_DIR" | "DT_BLK" | "DT_REG" | "DT_LNK" | "DT_SOCK"
775+
| "USRQUOTA" | "GRPQUOTA" | "PRIO_MIN" | "PRIO_MAX" => true,
795776

796777
// skip sighandler_t assignments
797778
"SIG_DFL" | "SIG_ERR" | "SIG_IGN" => true,
798779

799780
"DT_UNKNOWN" => true,
800781

801-
"_UTX_LINESIZE" | "_UTX_USERSIZE" | "_UTX_PADSIZE" | "_UTX_IDSIZE"
802-
| "_UTX_HOSTSIZE" => true,
782+
"_UTX_LINESIZE" | "_UTX_USERSIZE" | "_UTX_PADSIZE" | "_UTX_IDSIZE" | "_UTX_HOSTSIZE" => {
783+
true
784+
}
803785

804786
"EADI" | "EXTPROC" | "IPC_SEAT" => true,
805787

@@ -872,9 +854,7 @@ fn test_solarish(target: &str) {
872854
"cfmakeraw" | "cfsetspeed" => true,
873855

874856
// const-ness issues
875-
"execv" | "execve" | "execvp" | "settimeofday" | "sethostname" => {
876-
true
877-
}
857+
"execv" | "execve" | "execvp" | "settimeofday" | "sethostname" => true,
878858

879859
// Solaris-different
880860
"getpwent_r" | "getgrent_r" | "updwtmpx" if is_illumos => true,
@@ -979,10 +959,9 @@ fn test_netbsd(target: &str) {
979959
cfg.type_name(move |ty, is_struct, is_union| {
980960
match ty {
981961
// Just pass all these through, no need for a "struct" prefix
982-
"FILE" | "fd_set" | "Dl_info" | "DIR" | "Elf32_Phdr"
983-
| "Elf64_Phdr" | "Elf32_Shdr" | "Elf64_Shdr" | "Elf32_Sym"
984-
| "Elf64_Sym" | "Elf32_Ehdr" | "Elf64_Ehdr" | "Elf32_Chdr"
985-
| "Elf64_Chdr" => ty.to_string(),
962+
"FILE" | "fd_set" | "Dl_info" | "DIR" | "Elf32_Phdr" | "Elf64_Phdr" | "Elf32_Shdr"
963+
| "Elf64_Shdr" | "Elf32_Sym" | "Elf64_Sym" | "Elf32_Ehdr" | "Elf64_Ehdr"
964+
| "Elf32_Chdr" | "Elf64_Chdr" => ty.to_string(),
986965

987966
// OSX calls this something else
988967
"sighandler_t" => "sig_t".to_string(),
@@ -1187,10 +1166,9 @@ fn test_dragonflybsd(target: &str) {
11871166
cfg.type_name(move |ty, is_struct, is_union| {
11881167
match ty {
11891168
// Just pass all these through, no need for a "struct" prefix
1190-
"FILE" | "fd_set" | "Dl_info" | "DIR" | "Elf32_Phdr"
1191-
| "Elf64_Phdr" | "Elf32_Shdr" | "Elf64_Shdr" | "Elf32_Sym"
1192-
| "Elf64_Sym" | "Elf32_Ehdr" | "Elf64_Ehdr" | "Elf32_Chdr"
1193-
| "Elf64_Chdr" => ty.to_string(),
1169+
"FILE" | "fd_set" | "Dl_info" | "DIR" | "Elf32_Phdr" | "Elf64_Phdr" | "Elf32_Shdr"
1170+
| "Elf64_Shdr" | "Elf32_Sym" | "Elf64_Sym" | "Elf32_Ehdr" | "Elf64_Ehdr"
1171+
| "Elf32_Chdr" | "Elf64_Chdr" => ty.to_string(),
11941172

11951173
// FIXME: OSX calls this something else
11961174
"sighandler_t" => "sig_t".to_string(),
@@ -1269,10 +1247,7 @@ fn test_dragonflybsd(target: &str) {
12691247

12701248
// These are defined for Solaris 11, but the crate is tested on
12711249
// illumos, where they are currently not defined
1272-
"EADI"
1273-
| "PORT_SOURCE_POSTWAIT"
1274-
| "PORT_SOURCE_SIGNAL"
1275-
| "PTHREAD_STACK_MIN" => true,
1250+
"EADI" | "PORT_SOURCE_POSTWAIT" | "PORT_SOURCE_SIGNAL" | "PTHREAD_STACK_MIN" => true,
12761251

12771252
_ => false,
12781253
}
@@ -1551,9 +1526,7 @@ fn test_android(target: &str) {
15511526
match field {
15521527
// Our stat *_nsec fields normally don't actually exist but are part
15531528
// of a timeval struct
1554-
s if s.ends_with("_nsec") && struct_.starts_with("stat") => {
1555-
s.to_string()
1556-
}
1529+
s if s.ends_with("_nsec") && struct_.starts_with("stat") => s.to_string(),
15571530
// FIXME: appears that `epoll_event.data` is an union
15581531
"u64" if struct_ == "epoll_event" => "data.u64".to_string(),
15591532
s => s.to_string(),
@@ -1767,8 +1740,7 @@ fn test_freebsd(target: &str) {
17671740
cfg.type_name(move |ty, is_struct, is_union| {
17681741
match ty {
17691742
// Just pass all these through, no need for a "struct" prefix
1770-
"FILE" | "fd_set" | "Dl_info" | "DIR" | "Elf32_Phdr"
1771-
| "Elf64_Phdr" => ty.to_string(),
1743+
"FILE" | "fd_set" | "Dl_info" | "DIR" | "Elf32_Phdr" | "Elf64_Phdr" => ty.to_string(),
17721744

17731745
// FIXME: https://github.com/rust-lang/libc/issues/1273
17741746
"sighandler_t" => "sig_t".to_string(),
@@ -1804,8 +1776,8 @@ fn test_freebsd(target: &str) {
18041776
cfg.skip_const(move |name| {
18051777
match name {
18061778
// These constants are to be introduced in yet-unreleased FreeBSD 12.2.
1807-
"F_ADD_SEALS" | "F_GET_SEALS" | "F_SEAL_SEAL"
1808-
| "F_SEAL_SHRINK" | "F_SEAL_GROW" | "F_SEAL_WRITE"
1779+
"F_ADD_SEALS" | "F_GET_SEALS" | "F_SEAL_SEAL" | "F_SEAL_SHRINK" | "F_SEAL_GROW"
1780+
| "F_SEAL_WRITE"
18091781
if Some(12) <= freebsd_ver =>
18101782
{
18111783
true
@@ -1921,9 +1893,7 @@ fn test_freebsd(target: &str) {
19211893
"execv" | "execve" | "execvp" | "execvpe" | "fexecve" => true,
19221894

19231895
// These functions were added in FreeBSD 11:
1924-
"fdatasync" | "mq_getfd_np" | "sendmmsg" | "recvmmsg"
1925-
if Some(10) == freebsd_ver =>
1926-
{
1896+
"fdatasync" | "mq_getfd_np" | "sendmmsg" | "recvmmsg" if Some(10) == freebsd_ver => {
19271897
true
19281898
}
19291899

@@ -1959,9 +1929,7 @@ fn test_freebsd(target: &str) {
19591929
match i {
19601930
// aio_buf is a volatile void** but since we cannot express that in
19611931
// Rust types, we have to explicitly tell the checker about it here:
1962-
StructField(ref n, ref f) if n == "aiocb" && f == "aio_buf" => {
1963-
true
1964-
}
1932+
StructField(ref n, ref f) if n == "aiocb" && f == "aio_buf" => true,
19651933
_ => false,
19661934
}
19671935
});
@@ -2288,9 +2256,7 @@ fn test_vxworks(target: &str) {
22882256
});
22892257

22902258
cfg.skip_field_type(move |struct_, field| match (struct_, field) {
2291-
("siginfo_t", "si_value")
2292-
| ("stat", "st_size")
2293-
| ("sigaction", "sa_u") => true,
2259+
("siginfo_t", "si_value") | ("stat", "st_size") | ("sigaction", "sa_u") => true,
22942260
_ => false,
22952261
});
22962262

@@ -2525,10 +2491,9 @@ fn test_linux(target: &str) {
25252491
cfg.type_name(move |ty, is_struct, is_union| {
25262492
match ty {
25272493
// Just pass all these through, no need for a "struct" prefix
2528-
"FILE" | "fd_set" | "Dl_info" | "DIR" | "Elf32_Phdr"
2529-
| "Elf64_Phdr" | "Elf32_Shdr" | "Elf64_Shdr" | "Elf32_Sym"
2530-
| "Elf64_Sym" | "Elf32_Ehdr" | "Elf64_Ehdr" | "Elf32_Chdr"
2531-
| "Elf64_Chdr" => ty.to_string(),
2494+
"FILE" | "fd_set" | "Dl_info" | "DIR" | "Elf32_Phdr" | "Elf64_Phdr" | "Elf32_Shdr"
2495+
| "Elf64_Shdr" | "Elf32_Sym" | "Elf64_Sym" | "Elf32_Ehdr" | "Elf64_Ehdr"
2496+
| "Elf32_Chdr" | "Elf64_Chdr" => ty.to_string(),
25322497

25332498
t if is_union => format!("union {}", t),
25342499

@@ -2861,9 +2826,7 @@ fn test_linux(target: &str) {
28612826
match i {
28622827
// aio_buf is a volatile void** but since we cannot express that in
28632828
// Rust types, we have to explicitly tell the checker about it here:
2864-
StructField(ref n, ref f) if n == "aiocb" && f == "aio_buf" => {
2865-
true
2866-
}
2829+
StructField(ref n, ref f) if n == "aiocb" && f == "aio_buf" => true,
28672830
_ => false,
28682831
}
28692832
});
@@ -2911,11 +2874,7 @@ fn test_linux(target: &str) {
29112874
// FIXME: This is actually a union.
29122875
"fpreg_t" if s390x => true,
29132876

2914-
"sockaddr_un" | "sembuf" | "ff_constant_effect"
2915-
if mips32 && (gnu || musl) =>
2916-
{
2917-
true
2918-
}
2877+
"sockaddr_un" | "sembuf" | "ff_constant_effect" if mips32 && (gnu || musl) => true,
29192878
"ipv6_mreq"
29202879
| "ip_mreq_source"
29212880
| "sockaddr_in6"
@@ -2991,9 +2950,8 @@ fn test_linux_like_apis(target: &str) {
29912950
.skip_fn(|_| true)
29922951
.skip_const(move |name| match name {
29932952
// test fcntl constants:
2994-
"F_CANCELLK" | "F_ADD_SEALS" | "F_GET_SEALS"
2995-
| "F_SEAL_SEAL" | "F_SEAL_SHRINK" | "F_SEAL_GROW"
2996-
| "F_SEAL_WRITE" => false,
2953+
"F_CANCELLK" | "F_ADD_SEALS" | "F_GET_SEALS" | "F_SEAL_SEAL" | "F_SEAL_SHRINK"
2954+
| "F_SEAL_GROW" | "F_SEAL_WRITE" => false,
29972955
_ => true,
29982956
})
29992957
.type_name(move |ty, is_struct, is_union| match ty {
@@ -3285,12 +3243,12 @@ fn test_haiku(target: &str) {
32853243
cfg.skip_const(move |name| {
32863244
match name {
32873245
// FIXME: these constants do not exist on Haiku
3288-
"DT_UNKNOWN" | "DT_FIFO" | "DT_CHR" | "DT_DIR" | "DT_BLK"
3289-
| "DT_REG" | "DT_LNK" | "DT_SOCK" => true,
3246+
"DT_UNKNOWN" | "DT_FIFO" | "DT_CHR" | "DT_DIR" | "DT_BLK" | "DT_REG" | "DT_LNK"
3247+
| "DT_SOCK" => true,
32903248
"USRQUOTA" | "GRPQUOTA" => true,
32913249
"SIGIOT" => true,
3292-
"ARPOP_REQUEST" | "ARPOP_REPLY" | "ATF_COM" | "ATF_PERM"
3293-
| "ATF_PUBL" | "ATF_USETRAILERS" => true,
3250+
"ARPOP_REQUEST" | "ARPOP_REPLY" | "ATF_COM" | "ATF_PERM" | "ATF_PUBL"
3251+
| "ATF_USETRAILERS" => true,
32943252
// Haiku does not have MAP_FILE, but rustc requires it
32953253
"MAP_FILE" => true,
32963254
// The following does not exist on Haiku but is required by
@@ -3343,11 +3301,10 @@ fn test_haiku(target: &str) {
33433301
cfg.type_name(move |ty, is_struct, is_union| {
33443302
match ty {
33453303
// Just pass all these through, no need for a "struct" prefix
3346-
"area_info" | "port_info" | "port_message_info" | "team_info"
3347-
| "sem_info" | "team_usage_info" | "thread_info" | "cpu_info"
3348-
| "system_info" | "object_wait_info" | "image_info"
3349-
| "attr_info" | "index_info" | "fs_info" | "FILE" | "DIR"
3350-
| "Dl_info" => ty.to_string(),
3304+
"area_info" | "port_info" | "port_message_info" | "team_info" | "sem_info"
3305+
| "team_usage_info" | "thread_info" | "cpu_info" | "system_info"
3306+
| "object_wait_info" | "image_info" | "attr_info" | "index_info" | "fs_info"
3307+
| "FILE" | "DIR" | "Dl_info" => ty.to_string(),
33513308

33523309
// is actually a union
33533310
"sigval" => format!("union sigval"),

libc-test/test/cmsg.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@ mod t {
1111

1212
extern "C" {
1313
pub fn cmsg_firsthdr(msgh: *const msghdr) -> *mut cmsghdr;
14-
pub fn cmsg_nxthdr(
15-
mhdr: *const msghdr,
16-
cmsg: *const cmsghdr,
17-
) -> *mut cmsghdr;
14+
pub fn cmsg_nxthdr(mhdr: *const msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr;
1815
pub fn cmsg_space(length: c_uint) -> usize;
1916
pub fn cmsg_len(length: c_uint) -> usize;
2017
pub fn cmsg_data(cmsg: *const cmsghdr) -> *mut c_uchar;

0 commit comments

Comments
 (0)