Skip to content

Commit 1984cc2

Browse files
committed
chore: minor cleanup mode_t usage
`crate::mode_t` is almost never needed because it is part of prelude. Moreover, in many cases `mode_t` was already used without the prefix - thus confusing if they are different or not. Keeping it the same helps readability.
1 parent bf63904 commit 1984cc2

File tree

18 files changed

+212
-241
lines changed

18 files changed

+212
-241
lines changed

src/fuchsia/mod.rs

+28-34
Original file line numberDiff line numberDiff line change
@@ -1452,9 +1452,9 @@ pub const GRPQUOTA: c_int = 1;
14521452

14531453
pub const SIGIOT: c_int = 6;
14541454

1455-
pub const S_ISUID: crate::mode_t = 0o4000;
1456-
pub const S_ISGID: crate::mode_t = 0o2000;
1457-
pub const S_ISVTX: crate::mode_t = 0o1000;
1455+
pub const S_ISUID: mode_t = 0o4000;
1456+
pub const S_ISGID: mode_t = 0o2000;
1457+
pub const S_ISVTX: mode_t = 0o1000;
14581458

14591459
pub const IF_NAMESIZE: size_t = 16;
14601460
pub const IFNAMSIZ: size_t = IF_NAMESIZE;
@@ -1585,26 +1585,26 @@ pub const O_RDONLY: c_int = 0;
15851585
pub const O_WRONLY: c_int = 1;
15861586
pub const O_RDWR: c_int = 2;
15871587

1588-
pub const S_IFIFO: crate::mode_t = 0o1_0000;
1589-
pub const S_IFCHR: crate::mode_t = 0o2_0000;
1590-
pub const S_IFBLK: crate::mode_t = 0o6_0000;
1591-
pub const S_IFDIR: crate::mode_t = 0o4_0000;
1592-
pub const S_IFREG: crate::mode_t = 0o10_0000;
1593-
pub const S_IFLNK: crate::mode_t = 0o12_0000;
1594-
pub const S_IFSOCK: crate::mode_t = 0o14_0000;
1595-
pub const S_IFMT: crate::mode_t = 0o17_0000;
1596-
pub const S_IRWXU: crate::mode_t = 0o0700;
1597-
pub const S_IXUSR: crate::mode_t = 0o0100;
1598-
pub const S_IWUSR: crate::mode_t = 0o0200;
1599-
pub const S_IRUSR: crate::mode_t = 0o0400;
1600-
pub const S_IRWXG: crate::mode_t = 0o0070;
1601-
pub const S_IXGRP: crate::mode_t = 0o0010;
1602-
pub const S_IWGRP: crate::mode_t = 0o0020;
1603-
pub const S_IRGRP: crate::mode_t = 0o0040;
1604-
pub const S_IRWXO: crate::mode_t = 0o0007;
1605-
pub const S_IXOTH: crate::mode_t = 0o0001;
1606-
pub const S_IWOTH: crate::mode_t = 0o0002;
1607-
pub const S_IROTH: crate::mode_t = 0o0004;
1588+
pub const S_IFIFO: mode_t = 0o1_0000;
1589+
pub const S_IFCHR: mode_t = 0o2_0000;
1590+
pub const S_IFBLK: mode_t = 0o6_0000;
1591+
pub const S_IFDIR: mode_t = 0o4_0000;
1592+
pub const S_IFREG: mode_t = 0o10_0000;
1593+
pub const S_IFLNK: mode_t = 0o12_0000;
1594+
pub const S_IFSOCK: mode_t = 0o14_0000;
1595+
pub const S_IFMT: mode_t = 0o17_0000;
1596+
pub const S_IRWXU: mode_t = 0o0700;
1597+
pub const S_IXUSR: mode_t = 0o0100;
1598+
pub const S_IWUSR: mode_t = 0o0200;
1599+
pub const S_IRUSR: mode_t = 0o0400;
1600+
pub const S_IRWXG: mode_t = 0o0070;
1601+
pub const S_IXGRP: mode_t = 0o0010;
1602+
pub const S_IWGRP: mode_t = 0o0020;
1603+
pub const S_IRGRP: mode_t = 0o0040;
1604+
pub const S_IRWXO: mode_t = 0o0007;
1605+
pub const S_IXOTH: mode_t = 0o0001;
1606+
pub const S_IWOTH: mode_t = 0o0002;
1607+
pub const S_IROTH: mode_t = 0o0004;
16081608
pub const F_OK: c_int = 0;
16091609
pub const R_OK: c_int = 4;
16101610
pub const W_OK: c_int = 2;
@@ -3726,12 +3726,7 @@ extern "C" {
37263726
pub fn rewinddir(dirp: *mut crate::DIR);
37273727

37283728
pub fn openat(dirfd: c_int, pathname: *const c_char, flags: c_int, ...) -> c_int;
3729-
pub fn fchmodat(
3730-
dirfd: c_int,
3731-
pathname: *const c_char,
3732-
mode: crate::mode_t,
3733-
flags: c_int,
3734-
) -> c_int;
3729+
pub fn fchmodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, flags: c_int) -> c_int;
37353730
pub fn fchown(fd: c_int, owner: crate::uid_t, group: crate::gid_t) -> c_int;
37363731
pub fn fchownat(
37373732
dirfd: c_int,
@@ -3748,7 +3743,7 @@ extern "C" {
37483743
newpath: *const c_char,
37493744
flags: c_int,
37503745
) -> c_int;
3751-
pub fn mkdirat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t) -> c_int;
3746+
pub fn mkdirat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int;
37523747
pub fn readlinkat(
37533748
dirfd: c_int,
37543749
pathname: *const c_char,
@@ -3959,7 +3954,7 @@ extern "C" {
39593954
pub fn gmtime(time_p: *const time_t) -> *mut tm;
39603955
pub fn localtime(time_p: *const time_t) -> *mut tm;
39613956

3962-
pub fn mknod(pathname: *const c_char, mode: crate::mode_t, dev: crate::dev_t) -> c_int;
3957+
pub fn mknod(pathname: *const c_char, mode: mode_t, dev: crate::dev_t) -> c_int;
39633958
pub fn uname(buf: *mut crate::utsname) -> c_int;
39643959
pub fn gethostname(name: *mut c_char, len: size_t) -> c_int;
39653960
pub fn getservbyname(name: *const c_char, proto: *const c_char) -> *mut servent;
@@ -4079,8 +4074,7 @@ extern "C" {
40794074

40804075
pub fn fdopendir(fd: c_int) -> *mut crate::DIR;
40814076

4082-
pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t, dev: dev_t)
4083-
-> c_int;
4077+
pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int;
40844078
pub fn pthread_condattr_getclock(
40854079
attr: *const pthread_condattr_t,
40864080
clock_id: *mut clockid_t,
@@ -4205,7 +4199,7 @@ extern "C" {
42054199
pub fn setfsuid(uid: crate::uid_t) -> c_int;
42064200

42074201
// Not available now on Android
4208-
pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t) -> c_int;
4202+
pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int;
42094203
pub fn if_nameindex() -> *mut if_nameindex;
42104204
pub fn if_freenameindex(ptr: *mut if_nameindex);
42114205
pub fn sync_file_range(fd: c_int, offset: off64_t, nbytes: off64_t, flags: c_uint) -> c_int;

src/unix/aix/mod.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -2877,9 +2877,8 @@ extern "C" {
28772877
) -> *mut c_void;
28782878
pub fn memset_s(s: *mut c_void, smax: size_t, c: c_int, n: size_t) -> c_int;
28792879
pub fn mincore(addr: *const c_void, len: size_t, vec: *mut c_char) -> c_int;
2880-
pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t) -> c_int;
2881-
pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t, dev: dev_t)
2882-
-> c_int;
2880+
pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int;
2881+
pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int;
28832882
pub fn mount(device: *const c_char, path: *const c_char, flags: c_int) -> c_int;
28842883
pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) -> c_int;
28852884
pub fn mq_close(mqd: crate::mqd_t) -> c_int;
@@ -2973,7 +2972,7 @@ extern "C" {
29732972
fd: c_int,
29742973
path: *const c_char,
29752974
oflag: c_int,
2976-
mode: crate::mode_t,
2975+
mode: mode_t,
29772976
) -> c_int;
29782977
pub fn posix_spawn_file_actions_destroy(actions: *mut posix_spawn_file_actions_t) -> c_int;
29792978
pub fn posix_spawn_file_actions_init(actions: *mut posix_spawn_file_actions_t) -> c_int;
@@ -3138,7 +3137,7 @@ extern "C" {
31383137
pub fn shmdt(shmaddr: *const c_void) -> c_int;
31393138
pub fn shmctl(shmid: c_int, cmd: c_int, buf: *mut crate::shmid_ds) -> c_int;
31403139
pub fn shmget(key: key_t, size: size_t, shmflg: c_int) -> c_int;
3141-
pub fn shm_open(name: *const c_char, oflag: c_int, mode: crate::mode_t) -> c_int;
3140+
pub fn shm_open(name: *const c_char, oflag: c_int, mode: mode_t) -> c_int;
31423141
pub fn shm_unlink(name: *const c_char) -> c_int;
31433142
pub fn splice(socket1: c_int, socket2: c_int, flags: c_int) -> c_int;
31443143
pub fn srand(seed: c_uint);

src/unix/bsd/apple/mod.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ s! {
739739
pub gid: crate::gid_t,
740740
pub cuid: crate::uid_t,
741741
pub cgid: crate::gid_t,
742-
pub mode: crate::mode_t,
742+
pub mode: mode_t,
743743
pub _seq: c_ushort,
744744
pub _key: crate::key_t,
745745
}
@@ -6151,7 +6151,7 @@ extern "C" {
61516151
fd: c_int,
61526152
path: *const c_char,
61536153
oflag: c_int,
6154-
mode: crate::mode_t,
6154+
mode: mode_t,
61556155
) -> c_int;
61566156
pub fn posix_spawn_file_actions_addclose(
61576157
actions: *mut posix_spawn_file_actions_t,
@@ -6449,9 +6449,8 @@ extern "C" {
64496449
pub fn dirname(path: *mut c_char) -> *mut c_char;
64506450
pub fn basename(path: *mut c_char) -> *mut c_char;
64516451

6452-
pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t) -> c_int;
6453-
pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t, dev: dev_t)
6454-
-> c_int;
6452+
pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int;
6453+
pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int;
64556454
pub fn freadlink(fd: c_int, buf: *mut c_char, size: size_t) -> c_int;
64566455
pub fn execvP(
64576456
file: *const c_char,

src/unix/bsd/freebsdlike/mod.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ s! {
378378
pub cgid: crate::gid_t,
379379
pub uid: crate::uid_t,
380380
pub gid: crate::gid_t,
381-
pub mode: crate::mode_t,
381+
pub mode: mode_t,
382382
pub seq: c_ushort,
383383
pub key: crate::key_t,
384384
}
@@ -1598,13 +1598,12 @@ extern "C" {
15981598
pub fn lchflags(path: *const c_char, flags: c_ulong) -> c_int;
15991599
pub fn lutimes(file: *const c_char, times: *const crate::timeval) -> c_int;
16001600
pub fn memrchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void;
1601-
pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t) -> c_int;
1601+
pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int;
16021602
#[cfg_attr(
16031603
all(target_os = "freebsd", any(freebsd11, freebsd10)),
16041604
link_name = "mknodat@FBSD_1.1"
16051605
)]
1606-
pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t, dev: dev_t)
1607-
-> c_int;
1606+
pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int;
16081607
pub fn malloc_usable_size(ptr: *const c_void) -> size_t;
16091608
pub fn mincore(addr: *const c_void, len: size_t, vec: *mut c_char) -> c_int;
16101609
pub fn newlocale(mask: c_int, locale: *const c_char, base: crate::locale_t) -> crate::locale_t;
@@ -1726,7 +1725,7 @@ extern "C" {
17261725
pub fn setresuid(ruid: crate::uid_t, euid: crate::uid_t, suid: crate::uid_t) -> c_int;
17271726
pub fn settimeofday(tv: *const crate::timeval, tz: *const crate::timezone) -> c_int;
17281727
pub fn setutxent();
1729-
pub fn shm_open(name: *const c_char, oflag: c_int, mode: crate::mode_t) -> c_int;
1728+
pub fn shm_open(name: *const c_char, oflag: c_int, mode: mode_t) -> c_int;
17301729
pub fn sigtimedwait(
17311730
set: *const sigset_t,
17321731
info: *mut siginfo_t,
@@ -1868,7 +1867,7 @@ extern "C" {
18681867
fd: c_int,
18691868
path: *const c_char,
18701869
oflag: c_int,
1871-
mode: crate::mode_t,
1870+
mode: mode_t,
18721871
) -> c_int;
18731872
pub fn posix_spawn_file_actions_addclose(
18741873
actions: *mut posix_spawn_file_actions_t,

src/unix/bsd/netbsdlike/mod.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ s! {
7878
pub cgid: crate::gid_t,
7979
pub uid: crate::uid_t,
8080
pub gid: crate::gid_t,
81-
pub mode: crate::mode_t,
81+
pub mode: mode_t,
8282
#[cfg(target_os = "openbsd")]
8383
pub seq: c_ushort,
8484
#[cfg(target_os = "netbsd")]
@@ -687,7 +687,7 @@ extern "C" {
687687
#[cfg_attr(target_os = "netbsd", link_name = "__clock_settime50")]
688688
pub fn clock_settime(clk_id: crate::clockid_t, tp: *const crate::timespec) -> c_int;
689689
pub fn __errno() -> *mut c_int;
690-
pub fn shm_open(name: *const c_char, oflag: c_int, mode: crate::mode_t) -> c_int;
690+
pub fn shm_open(name: *const c_char, oflag: c_int, mode: mode_t) -> c_int;
691691
pub fn memrchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void;
692692
pub fn mkostemp(template: *mut c_char, flags: c_int) -> c_int;
693693
pub fn mkostemps(template: *mut c_char, suffixlen: c_int, flags: c_int) -> c_int;
@@ -705,9 +705,8 @@ extern "C" {
705705
pub fn getpriority(which: c_int, who: crate::id_t) -> c_int;
706706
pub fn setpriority(which: c_int, who: crate::id_t, prio: c_int) -> c_int;
707707

708-
pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t, dev: dev_t)
709-
-> c_int;
710-
pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t) -> c_int;
708+
pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int;
709+
pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int;
711710
pub fn sem_timedwait(sem: *mut sem_t, abstime: *const crate::timespec) -> c_int;
712711
pub fn sem_getvalue(sem: *mut sem_t, sval: *mut c_int) -> c_int;
713712
pub fn pthread_condattr_setclock(
@@ -825,7 +824,7 @@ extern "C" {
825824
fd: c_int,
826825
path: *const c_char,
827826
oflag: c_int,
828-
mode: crate::mode_t,
827+
mode: mode_t,
829828
) -> c_int;
830829
pub fn posix_spawn_file_actions_addclose(
831830
actions: *mut posix_spawn_file_actions_t,

src/unix/haiku/mod.rs

+26-27
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ s! {
420420
pub gid: crate::gid_t,
421421
pub cuid: crate::uid_t,
422422
pub cgid: crate::gid_t,
423-
pub mode: crate::mode_t,
423+
pub mode: mode_t,
424424
}
425425

426426
pub struct sembuf {
@@ -774,27 +774,27 @@ pub const O_NOFOLLOW: c_int = 0x00080000;
774774
pub const O_NOCACHE: c_int = 0x00100000;
775775
pub const O_DIRECTORY: c_int = 0x00200000;
776776

777-
pub const S_IFIFO: crate::mode_t = 0o1_0000;
778-
pub const S_IFCHR: crate::mode_t = 0o2_0000;
779-
pub const S_IFBLK: crate::mode_t = 0o6_0000;
780-
pub const S_IFDIR: crate::mode_t = 0o4_0000;
781-
pub const S_IFREG: crate::mode_t = 0o10_0000;
782-
pub const S_IFLNK: crate::mode_t = 0o12_0000;
783-
pub const S_IFSOCK: crate::mode_t = 0o14_0000;
784-
pub const S_IFMT: crate::mode_t = 0o17_0000;
785-
786-
pub const S_IRWXU: crate::mode_t = 0o0700;
787-
pub const S_IRUSR: crate::mode_t = 0o0400;
788-
pub const S_IWUSR: crate::mode_t = 0o0200;
789-
pub const S_IXUSR: crate::mode_t = 0o0100;
790-
pub const S_IRWXG: crate::mode_t = 0o0070;
791-
pub const S_IRGRP: crate::mode_t = 0o0040;
792-
pub const S_IWGRP: crate::mode_t = 0o0020;
793-
pub const S_IXGRP: crate::mode_t = 0o0010;
794-
pub const S_IRWXO: crate::mode_t = 0o0007;
795-
pub const S_IROTH: crate::mode_t = 0o0004;
796-
pub const S_IWOTH: crate::mode_t = 0o0002;
797-
pub const S_IXOTH: crate::mode_t = 0o0001;
777+
pub const S_IFIFO: mode_t = 0o1_0000;
778+
pub const S_IFCHR: mode_t = 0o2_0000;
779+
pub const S_IFBLK: mode_t = 0o6_0000;
780+
pub const S_IFDIR: mode_t = 0o4_0000;
781+
pub const S_IFREG: mode_t = 0o10_0000;
782+
pub const S_IFLNK: mode_t = 0o12_0000;
783+
pub const S_IFSOCK: mode_t = 0o14_0000;
784+
pub const S_IFMT: mode_t = 0o17_0000;
785+
786+
pub const S_IRWXU: mode_t = 0o0700;
787+
pub const S_IRUSR: mode_t = 0o0400;
788+
pub const S_IWUSR: mode_t = 0o0200;
789+
pub const S_IXUSR: mode_t = 0o0100;
790+
pub const S_IRWXG: mode_t = 0o0070;
791+
pub const S_IRGRP: mode_t = 0o0040;
792+
pub const S_IWGRP: mode_t = 0o0020;
793+
pub const S_IXGRP: mode_t = 0o0010;
794+
pub const S_IRWXO: mode_t = 0o0007;
795+
pub const S_IROTH: mode_t = 0o0004;
796+
pub const S_IWOTH: mode_t = 0o0002;
797+
pub const S_IXOTH: mode_t = 0o0001;
798798

799799
pub const F_OK: c_int = 0;
800800
pub const R_OK: c_int = 4;
@@ -1731,9 +1731,8 @@ extern "C" {
17311731
bufferSize: size_t,
17321732
res: *mut *mut spwd,
17331733
) -> c_int;
1734-
pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t) -> c_int;
1735-
pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t, dev: dev_t)
1736-
-> c_int;
1734+
pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int;
1735+
pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int;
17371736
pub fn sem_destroy(sem: *mut sem_t) -> c_int;
17381737
pub fn sem_init(sem: *mut sem_t, pshared: c_int, value: c_uint) -> c_int;
17391738

@@ -1811,7 +1810,7 @@ extern "C" {
18111810
pub fn posix_fadvise(fd: c_int, offset: off_t, len: off_t, advice: c_int) -> c_int;
18121811
pub fn posix_fallocate(fd: c_int, offset: off_t, len: off_t) -> c_int;
18131812

1814-
pub fn shm_open(name: *const c_char, oflag: c_int, mode: crate::mode_t) -> c_int;
1813+
pub fn shm_open(name: *const c_char, oflag: c_int, mode: mode_t) -> c_int;
18151814
pub fn shm_unlink(name: *const c_char) -> c_int;
18161815

18171816
pub fn seekdir(dirp: *mut crate::DIR, loc: c_long);
@@ -2027,7 +2026,7 @@ extern "C" {
20272026
fildes: c_int,
20282027
path: *const c_char,
20292028
oflag: c_int,
2030-
mode: crate::mode_t,
2029+
mode: mode_t,
20312030
) -> c_int;
20322031
pub fn posix_spawn_file_actions_addclose(
20332032
file_actions: *mut posix_spawn_file_actions_t,

0 commit comments

Comments
 (0)